diff --git a/bundles/org.openhab.binding.openwebnet/README.md b/bundles/org.openhab.binding.openwebnet/README.md index d4f3d6ca0755b..7455d1a279912 100644 --- a/bundles/org.openhab.binding.openwebnet/README.md +++ b/bundles/org.openhab.binding.openwebnet/README.md @@ -228,6 +228,7 @@ OPEN command to execute: *5*8#134## | `battery` | `bus_alarm_system` | String | Alarm system battery state (`OK`, `FAULT`, `UNLOADED`) | R | | `armed` | `bus_alarm_system` | Switch | Alarm system is armed (`ON`) or disarmed (`OFF`) | R | | `alarm` | `bus_alarm_zone` | String | Current alarm for the zone (`SILENT`, `INTRUSION`, `TAMPERING`, `ANTI_PANIC`) | R | +| `timestamp` | `bus_alarm_zone` | DateTime | Current date and time of the zone's alarm event (YY/MM/DD hh:mm:ss) | R | ### Thermo channels diff --git a/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/internal/OpenWebNetBindingConstants.java b/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/internal/OpenWebNetBindingConstants.java index 7cbf637c32e3f..69e69633494a2 100644 --- a/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/internal/OpenWebNetBindingConstants.java +++ b/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/internal/OpenWebNetBindingConstants.java @@ -173,6 +173,7 @@ public class OpenWebNetBindingConstants { public static final String CHANNEL_ALARM_SYSTEM_BATTERY = "battery"; public static final String CHANNEL_ALARM_ZONE_STATE = "state"; public static final String CHANNEL_ALARM_ZONE_ALARM = "alarm"; + public static final String CHANNEL_ALARM_ZONE_ALARM_TIMESTAMP = "timestamp"; // devices config properties public static final String CONFIG_PROPERTY_WHERE = "where"; diff --git a/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/internal/handler/OpenWebNetAlarmHandler.java b/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/internal/handler/OpenWebNetAlarmHandler.java index e6abefe6be882..8c945200fdf5b 100644 --- a/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/internal/handler/OpenWebNetAlarmHandler.java +++ b/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/internal/handler/OpenWebNetAlarmHandler.java @@ -19,6 +19,7 @@ import org.eclipse.jdt.annotation.NonNullByDefault; import org.openhab.binding.openwebnet.internal.OpenWebNetBindingConstants; +import org.openhab.core.library.types.DateTimeType; import org.openhab.core.library.types.OnOffType; import org.openhab.core.library.types.StringType; import org.openhab.core.thing.ChannelUID; @@ -43,6 +44,7 @@ * {@link OpenWebNetThingHandler}. * * @author Massimo Valla - Initial contribution + * @author Giovanni Fabiani - Add zone alarm's tismestamp feature */ @NonNullByDefault public class OpenWebNetAlarmHandler extends OpenWebNetThingHandler { @@ -79,6 +81,8 @@ public void initialize() { // initially set zone alarm to NONE (it will be set if specific alarm message is // received) updateState(CHANNEL_ALARM_ZONE_ALARM, new StringType(ALARM_NONE)); + // initializing timestamp + updateState(CHANNEL_ALARM_ZONE_ALARM_TIMESTAMP, new DateTimeType()); } } @@ -122,7 +126,7 @@ protected void refreshDevice(boolean refreshAll) { send(Alarm.requestSystemStatus()); lastAllDevicesRefreshTS = System.currentTimeMillis(); } catch (OWNException e) { - logger.warn("Excpetion while requesting alarm system status: {}", e.getMessage()); + logger.warn("Exception while requesting alarm system status: {}", e.getMessage()); } } else { logger.debug("--- refreshDevice() : refreshing SINGLE... ({})", thing.getUID()); @@ -218,6 +222,7 @@ private void updateZone(Alarm msg) { case ZONE_ALARM_TECHNICAL: case ZONE_ALARM_TECHNICAL_RESET: updateZoneAlarm(w); + updateState(CHANNEL_ALARM_ZONE_ALARM_TIMESTAMP, new DateTimeType()); break; default: logger.debug("Alarm.updateZone() Ignoring unsupported WHAT {}. Frame={}", msg.getWhat(), msg); @@ -257,6 +262,7 @@ private void updateZoneAlarm(WhatAlarm w) { private void resetAllZonesAlarmState() { for (OpenWebNetAlarmHandler h : zoneHandlers) { h.updateState(CHANNEL_ALARM_ZONE_ALARM, new StringType(ALARM_NONE)); + h.updateState(CHANNEL_ALARM_ZONE_ALARM_TIMESTAMP, new DateTimeType()); } } diff --git a/bundles/org.openhab.binding.openwebnet/src/main/resources/OH-INF/i18n/openwebnet.properties b/bundles/org.openhab.binding.openwebnet/src/main/resources/OH-INF/i18n/openwebnet.properties index a417faa795d90..4b15aba1f51b8 100644 --- a/bundles/org.openhab.binding.openwebnet/src/main/resources/OH-INF/i18n/openwebnet.properties +++ b/bundles/org.openhab.binding.openwebnet/src/main/resources/OH-INF/i18n/openwebnet.properties @@ -285,6 +285,8 @@ channel-type.openwebnet.zoneAlarm.state.option.SILENT = Silent channel-type.openwebnet.zoneAlarm.state.option.TECHNICAL = Technical channel-type.openwebnet.zoneAlarm.state.option.TECHNICAL_RESET = Technical Reset channel-type.openwebnet.zoneAlarm.state.option.NONE = None +channel-type.openwebnet.zoneAlarmTimestamp.label = Zone Alarm Timestamp +channel-type.openwebnet.zoneAlarmTimestamp.description = Current alarm's timestamp for the zone (read only). # thing status descriptions diff --git a/bundles/org.openhab.binding.openwebnet/src/main/resources/OH-INF/thing/BusAlarmZone.xml b/bundles/org.openhab.binding.openwebnet/src/main/resources/OH-INF/thing/BusAlarmZone.xml index 3a0b84b9b1a5f..9fcb938e2c9b5 100644 --- a/bundles/org.openhab.binding.openwebnet/src/main/resources/OH-INF/thing/BusAlarmZone.xml +++ b/bundles/org.openhab.binding.openwebnet/src/main/resources/OH-INF/thing/BusAlarmZone.xml @@ -17,12 +17,14 @@ + BTicino/Legrand Alarm zone as configured in the Alarm System Unit 5200 + 1 ownId diff --git a/bundles/org.openhab.binding.openwebnet/src/main/resources/OH-INF/thing/channels.xml b/bundles/org.openhab.binding.openwebnet/src/main/resources/OH-INF/thing/channels.xml index be9b6843b582a..779d9ebf1352e 100644 --- a/bundles/org.openhab.binding.openwebnet/src/main/resources/OH-INF/thing/channels.xml +++ b/bundles/org.openhab.binding.openwebnet/src/main/resources/OH-INF/thing/channels.xml @@ -461,6 +461,15 @@ + + DateTime + + Current alarm's timestamp for the zone (read only). + Time + + + + Switch diff --git a/bundles/org.openhab.binding.openwebnet/src/main/resources/OH-INF/update/update.xml b/bundles/org.openhab.binding.openwebnet/src/main/resources/OH-INF/update/update.xml new file mode 100644 index 0000000000000..900a8bd44c526 --- /dev/null +++ b/bundles/org.openhab.binding.openwebnet/src/main/resources/OH-INF/update/update.xml @@ -0,0 +1,13 @@ + + + + + + openwebnet:zoneAlarmTimestamp + + + + +