]> git.basschouten.com Git - openhab-addons.git/commitdiff
[openwebnet] Final review (#14819)
authorGiovanni Fabiani <fabiani.giovanni@gmail.com>
Fri, 5 May 2023 14:14:59 +0000 (16:14 +0200)
committerGitHub <noreply@github.com>
Fri, 5 May 2023 14:14:59 +0000 (16:14 +0200)
This reverts commit 3807c80eee9a3df26773860472b422d4e72d16d6.

Signed-off-by: Giovanni Fabiani <fabiani.giovanni@gmail.com>
bundles/org.openhab.binding.openwebnet/README.md
bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/internal/OpenWebNetBindingConstants.java
bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/internal/handler/OpenWebNetAlarmHandler.java
bundles/org.openhab.binding.openwebnet/src/main/resources/OH-INF/i18n/openwebnet.properties
bundles/org.openhab.binding.openwebnet/src/main/resources/OH-INF/thing/BusAlarmZone.xml
bundles/org.openhab.binding.openwebnet/src/main/resources/OH-INF/thing/channels.xml
bundles/org.openhab.binding.openwebnet/src/main/resources/OH-INF/update/update.xml [new file with mode: 0644]

index d4f3d6ca0755b39dc003a85f370d870b52288d86..7455d1a2799122cfb70c33d3ab428620af53fb1d 100644 (file)
@@ -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
 
index 7cbf637c32e3f600aed3e1b8b66d5bce8d550cac..69e69633494a2a327690c807c919718f74c860d0 100644 (file)
@@ -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";
index e6abefe6be8824ae6e760b8a4ebb0f0306096dc2..8c945200fdf5b7c63b4e5404626431b12c7ac78b 100644 (file)
@@ -19,6 +19,7 @@ import java.util.Set;
 
 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 @@ import org.slf4j.LoggerFactory;
  * {@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 class OpenWebNetAlarmHandler extends OpenWebNetThingHandler {
             // 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 @@ public class OpenWebNetAlarmHandler extends OpenWebNetThingHandler {
                 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 @@ public class OpenWebNetAlarmHandler extends OpenWebNetThingHandler {
             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 @@ public class OpenWebNetAlarmHandler extends OpenWebNetThingHandler {
     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());
         }
     }
 
index a417faa795d902aebc01189b99a67a99acb72c30..4b15aba1f51b81490b7b66f54b2404df3588169b 100644 (file)
@@ -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
 
index 3a0b84b9b1a5f269e9c514fd6c44da9e31ff7006..9fcb938e2c9b517cc6d2383a57386ac98a8209dc 100644 (file)
                        <!-- read only -->
                        <channel id="state" typeId="alarmZoneState"/>
                        <channel id="alarm" typeId="zoneAlarm"/>
+                       <channel id="timestamp" typeId="zoneAlarmTimestamp"/>
                </channels>
 
                <properties>
                        <property name="vendor">BTicino/Legrand</property>
                        <property name="model">Alarm zone as configured in the Alarm System Unit</property>
                        <property name="ownDeviceType">5200</property>
+                       <property name="thingTypeVersion">1</property>
                </properties>
 
                <representation-property>ownId</representation-property>
index be9b6843b582a6d50a6c92b32bb242c322b3bbdf..779d9ebf1352eb1d71045499ed2d7ca906a3d235 100644 (file)
                </state>
        </channel-type>
 
+       <channel-type id="zoneAlarmTimestamp">
+               <item-type>DateTime</item-type>
+               <label>Zone Alarm Timestamp</label>
+               <description>Current alarm's timestamp for the zone (read only).</description>
+               <category>Time</category>
+               <state readOnly="true"/>
+       </channel-type>
+
+
        <channel-type id="alarmZoneState">
                <item-type>Switch</item-type>
                <label>Alarm Zone State</label>
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 (file)
index 0000000..900a8bd
--- /dev/null
@@ -0,0 +1,13 @@
+<update:update-descriptions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:update="https://openhab.org/schemas/update-description/v1.0.0"
+       xsi:schemaLocation="https://openhab.org/schemas/update-description/v1.0.0 https://openhab.org/schemas/update-description-1.0.0.xsd">
+
+       <thing-type uid="openwebnet:bus_alarm_zone">
+               <instruction-set targetVersion="1">
+                       <add-channel id="timestamp">
+                               <type>openwebnet:zoneAlarmTimestamp</type>
+                       </add-channel>
+               </instruction-set>
+       </thing-type>
+
+</update:update-descriptions>