Skip to content

Commit 7bcf2e7

Browse files
authored
[openwebnet] Final review (openhab#14819)
This reverts commit 3807c80. Signed-off-by: Giovanni Fabiani <[email protected]>
1 parent 58470ca commit 7bcf2e7

File tree

7 files changed

+35
-1
lines changed

7 files changed

+35
-1
lines changed

bundles/org.openhab.binding.openwebnet/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ OPEN command to execute: *5*8#134##
228228
| `battery` | `bus_alarm_system` | String | Alarm system battery state (`OK`, `FAULT`, `UNLOADED`) | R |
229229
| `armed` | `bus_alarm_system` | Switch | Alarm system is armed (`ON`) or disarmed (`OFF`) | R |
230230
| `alarm` | `bus_alarm_zone` | String | Current alarm for the zone (`SILENT`, `INTRUSION`, `TAMPERING`, `ANTI_PANIC`) | R |
231+
| `timestamp` | `bus_alarm_zone` | DateTime | Current date and time of the zone's alarm event (YY/MM/DD hh:mm:ss) | R |
231232

232233
### Thermo channels
233234

bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/internal/OpenWebNetBindingConstants.java

+1
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ public class OpenWebNetBindingConstants {
173173
public static final String CHANNEL_ALARM_SYSTEM_BATTERY = "battery";
174174
public static final String CHANNEL_ALARM_ZONE_STATE = "state";
175175
public static final String CHANNEL_ALARM_ZONE_ALARM = "alarm";
176+
public static final String CHANNEL_ALARM_ZONE_ALARM_TIMESTAMP = "timestamp";
176177

177178
// devices config properties
178179
public static final String CONFIG_PROPERTY_WHERE = "where";

bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/internal/handler/OpenWebNetAlarmHandler.java

+7-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
import org.eclipse.jdt.annotation.NonNullByDefault;
2121
import org.openhab.binding.openwebnet.internal.OpenWebNetBindingConstants;
22+
import org.openhab.core.library.types.DateTimeType;
2223
import org.openhab.core.library.types.OnOffType;
2324
import org.openhab.core.library.types.StringType;
2425
import org.openhab.core.thing.ChannelUID;
@@ -43,6 +44,7 @@
4344
* {@link OpenWebNetThingHandler}.
4445
*
4546
* @author Massimo Valla - Initial contribution
47+
* @author Giovanni Fabiani - Add zone alarm's tismestamp feature
4648
*/
4749
@NonNullByDefault
4850
public class OpenWebNetAlarmHandler extends OpenWebNetThingHandler {
@@ -79,6 +81,8 @@ public void initialize() {
7981
// initially set zone alarm to NONE (it will be set if specific alarm message is
8082
// received)
8183
updateState(CHANNEL_ALARM_ZONE_ALARM, new StringType(ALARM_NONE));
84+
// initializing timestamp
85+
updateState(CHANNEL_ALARM_ZONE_ALARM_TIMESTAMP, new DateTimeType());
8286
}
8387
}
8488

@@ -122,7 +126,7 @@ protected void refreshDevice(boolean refreshAll) {
122126
send(Alarm.requestSystemStatus());
123127
lastAllDevicesRefreshTS = System.currentTimeMillis();
124128
} 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());
126130
}
127131
} else {
128132
logger.debug("--- refreshDevice() : refreshing SINGLE... ({})", thing.getUID());
@@ -218,6 +222,7 @@ private void updateZone(Alarm msg) {
218222
case ZONE_ALARM_TECHNICAL:
219223
case ZONE_ALARM_TECHNICAL_RESET:
220224
updateZoneAlarm(w);
225+
updateState(CHANNEL_ALARM_ZONE_ALARM_TIMESTAMP, new DateTimeType());
221226
break;
222227
default:
223228
logger.debug("Alarm.updateZone() Ignoring unsupported WHAT {}. Frame={}", msg.getWhat(), msg);
@@ -257,6 +262,7 @@ private void updateZoneAlarm(WhatAlarm w) {
257262
private void resetAllZonesAlarmState() {
258263
for (OpenWebNetAlarmHandler h : zoneHandlers) {
259264
h.updateState(CHANNEL_ALARM_ZONE_ALARM, new StringType(ALARM_NONE));
265+
h.updateState(CHANNEL_ALARM_ZONE_ALARM_TIMESTAMP, new DateTimeType());
260266
}
261267
}
262268

bundles/org.openhab.binding.openwebnet/src/main/resources/OH-INF/i18n/openwebnet.properties

+2
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,8 @@ channel-type.openwebnet.zoneAlarm.state.option.SILENT = Silent
285285
channel-type.openwebnet.zoneAlarm.state.option.TECHNICAL = Technical
286286
channel-type.openwebnet.zoneAlarm.state.option.TECHNICAL_RESET = Technical Reset
287287
channel-type.openwebnet.zoneAlarm.state.option.NONE = None
288+
channel-type.openwebnet.zoneAlarmTimestamp.label = Zone Alarm Timestamp
289+
channel-type.openwebnet.zoneAlarmTimestamp.description = Current alarm's timestamp for the zone (read only).
288290

289291
# thing status descriptions
290292

bundles/org.openhab.binding.openwebnet/src/main/resources/OH-INF/thing/BusAlarmZone.xml

+2
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,14 @@
1717
<!-- read only -->
1818
<channel id="state" typeId="alarmZoneState"/>
1919
<channel id="alarm" typeId="zoneAlarm"/>
20+
<channel id="timestamp" typeId="zoneAlarmTimestamp"/>
2021
</channels>
2122

2223
<properties>
2324
<property name="vendor">BTicino/Legrand</property>
2425
<property name="model">Alarm zone as configured in the Alarm System Unit</property>
2526
<property name="ownDeviceType">5200</property>
27+
<property name="thingTypeVersion">1</property>
2628
</properties>
2729

2830
<representation-property>ownId</representation-property>

bundles/org.openhab.binding.openwebnet/src/main/resources/OH-INF/thing/channels.xml

+9
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,15 @@
461461
</state>
462462
</channel-type>
463463

464+
<channel-type id="zoneAlarmTimestamp">
465+
<item-type>DateTime</item-type>
466+
<label>Zone Alarm Timestamp</label>
467+
<description>Current alarm's timestamp for the zone (read only).</description>
468+
<category>Time</category>
469+
<state readOnly="true"/>
470+
</channel-type>
471+
472+
464473
<channel-type id="alarmZoneState">
465474
<item-type>Switch</item-type>
466475
<label>Alarm Zone State</label>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<update:update-descriptions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xmlns:update="https://openhab.org/schemas/update-description/v1.0.0"
3+
xsi:schemaLocation="https://openhab.org/schemas/update-description/v1.0.0 https://openhab.org/schemas/update-description-1.0.0.xsd">
4+
5+
<thing-type uid="openwebnet:bus_alarm_zone">
6+
<instruction-set targetVersion="1">
7+
<add-channel id="timestamp">
8+
<type>openwebnet:zoneAlarmTimestamp</type>
9+
</add-channel>
10+
</instruction-set>
11+
</thing-type>
12+
13+
</update:update-descriptions>

0 commit comments

Comments
 (0)