|
19 | 19 |
|
20 | 20 | import org.eclipse.jdt.annotation.NonNullByDefault;
|
21 | 21 | import org.openhab.binding.openwebnet.internal.OpenWebNetBindingConstants;
|
| 22 | +import org.openhab.core.library.types.DateTimeType; |
22 | 23 | import org.openhab.core.library.types.OnOffType;
|
23 | 24 | import org.openhab.core.library.types.StringType;
|
24 | 25 | import org.openhab.core.thing.ChannelUID;
|
|
43 | 44 | * {@link OpenWebNetThingHandler}.
|
44 | 45 | *
|
45 | 46 | * @author Massimo Valla - Initial contribution
|
| 47 | + * @author Giovanni Fabiani - Add zone alarm's tismestamp feature |
46 | 48 | */
|
47 | 49 | @NonNullByDefault
|
48 | 50 | public class OpenWebNetAlarmHandler extends OpenWebNetThingHandler {
|
@@ -79,6 +81,8 @@ public void initialize() {
|
79 | 81 | // initially set zone alarm to NONE (it will be set if specific alarm message is
|
80 | 82 | // received)
|
81 | 83 | updateState(CHANNEL_ALARM_ZONE_ALARM, new StringType(ALARM_NONE));
|
| 84 | + // initializing timestamp |
| 85 | + updateState(CHANNEL_ALARM_ZONE_ALARM_TIMESTAMP, new DateTimeType()); |
82 | 86 | }
|
83 | 87 | }
|
84 | 88 |
|
@@ -122,7 +126,7 @@ protected void refreshDevice(boolean refreshAll) {
|
122 | 126 | send(Alarm.requestSystemStatus());
|
123 | 127 | lastAllDevicesRefreshTS = System.currentTimeMillis();
|
124 | 128 | } catch (OWNException e) {
|
125 |
| - logger.warn("Excpetion while requesting alarm system status: {}", e.getMessage()); |
| 129 | + logger.warn("Exception while requesting alarm system status: {}", e.getMessage()); |
126 | 130 | }
|
127 | 131 | } else {
|
128 | 132 | logger.debug("--- refreshDevice() : refreshing SINGLE... ({})", thing.getUID());
|
@@ -218,6 +222,7 @@ private void updateZone(Alarm msg) {
|
218 | 222 | case ZONE_ALARM_TECHNICAL:
|
219 | 223 | case ZONE_ALARM_TECHNICAL_RESET:
|
220 | 224 | updateZoneAlarm(w);
|
| 225 | + updateState(CHANNEL_ALARM_ZONE_ALARM_TIMESTAMP, new DateTimeType()); |
221 | 226 | break;
|
222 | 227 | default:
|
223 | 228 | logger.debug("Alarm.updateZone() Ignoring unsupported WHAT {}. Frame={}", msg.getWhat(), msg);
|
@@ -257,6 +262,7 @@ private void updateZoneAlarm(WhatAlarm w) {
|
257 | 262 | private void resetAllZonesAlarmState() {
|
258 | 263 | for (OpenWebNetAlarmHandler h : zoneHandlers) {
|
259 | 264 | h.updateState(CHANNEL_ALARM_ZONE_ALARM, new StringType(ALARM_NONE));
|
| 265 | + h.updateState(CHANNEL_ALARM_ZONE_ALARM_TIMESTAMP, new DateTimeType()); |
260 | 266 | }
|
261 | 267 | }
|
262 | 268 |
|
|
0 commit comments