Skip to content

Commit

Permalink
[openwebnet] Final review (openhab#14819)
Browse files Browse the repository at this point in the history
This reverts commit 3807c80.

Signed-off-by: Giovanni Fabiani <[email protected]>
  • Loading branch information
fabgio authored May 5, 2023
1 parent 58470ca commit 7bcf2e7
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 1 deletion.
1 change: 1 addition & 0 deletions bundles/org.openhab.binding.openwebnet/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {
Expand Down Expand Up @@ -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());
}
}

Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@
<!-- 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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,15 @@
</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>
Expand Down
Original file line number Diff line number Diff line change
@@ -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>

0 comments on commit 7bcf2e7

Please sign in to comment.