-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[openwebnet] Add a time stamp when an alarm zone event occurs #14743
Changes from all commits
fe8b9dc
b718ed1
7c69b68
aab4e6f
77f55e6
f252326
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -221,13 +221,13 @@ OPEN command to execute: *5*8#134## | |
|
||
### Alarm channels | ||
|
||
| Channel Type ID (channel ID) | Applies to Thing Type IDs | Item Type | Description | Read/Write | | ||
|------------------------------|----------------------------------------|-------------|-----------------------------------------------------------------------|:-----------:| | ||
| `state` | `bus_alarm_system`, `bus_alarm_zone` | Switch | Alarm system or zone is active (`ON`) or inactive (`OFF`) | R | | ||
| `network` | `bus_alarm_system` | Switch | Alarm system network state (`ON` = network ok, `OFF` = no network) | R | | ||
| `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 | | ||
| Channel Type ID (channel ID) | Applies to Thing Type IDs | Item Type | Description | Read/Write | | ||
|------------------------------|----------------------------------------|-------------|----------------------------------------------------------------------------------------------------------------------------------------------|:-----------:| | ||
| `state` | `bus_alarm_system`, `bus_alarm_zone` | Switch | Alarm system or zone is active (`ON`) or inactive (`OFF`) | R | | ||
| `network` | `bus_alarm_system` | Switch | Alarm system network state (`ON` = network ok, `OFF` = no network) | R | | ||
| `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`) as well as the date and time of the event (YY/MM/DD hh:mm:ss) | R | | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this channel should remain as it was before: it's not a good idea to put together two differnet information: the type of alarm that was triggered an its timestamp. This is not a good desing at all, as it makes difficult for example for scripts to detect which type of alarm has been triggered (you would need to parse the string). |
||
|
||
### Thermo channels | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,9 @@ | |
|
||
import static org.openhab.binding.openwebnet.internal.OpenWebNetBindingConstants.*; | ||
|
||
import java.time.LocalDateTime; | ||
import java.time.ZoneId; | ||
import java.time.format.DateTimeFormatter; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
|
@@ -43,6 +46,7 @@ | |
* {@link OpenWebNetThingHandler}. | ||
* | ||
* @author Massimo Valla - Initial contribution | ||
* @author Giovanni Fabiani - Added timestamp | ||
*/ | ||
@NonNullByDefault | ||
public class OpenWebNetAlarmHandler extends OpenWebNetThingHandler { | ||
|
@@ -229,27 +233,29 @@ private void updateZoneState(WhatAlarm w) { | |
} | ||
|
||
private void updateZoneAlarm(WhatAlarm w) { | ||
LocalDateTime now = LocalDateTime.now(ZoneId.systemDefault()); | ||
DateTimeFormatter format = DateTimeFormatter.ofPattern("MM-dd-yyyy HH:mm:ss"); | ||
switch (w) { | ||
case ZONE_ALARM_INTRUSION: | ||
updateState(CHANNEL_ALARM_ZONE_ALARM, new StringType(ALARM_INTRUSION)); | ||
updateState(CHANNEL_ALARM_ZONE_ALARM, new StringType(ALARM_INTRUSION + " " + now.format(format))); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. timestamp should not be concatenated to the |
||
break; | ||
case ZONE_ALARM_TAMPERING: | ||
updateState(CHANNEL_ALARM_ZONE_ALARM, new StringType(ALARM_TAMPERING)); | ||
updateState(CHANNEL_ALARM_ZONE_ALARM, new StringType(ALARM_TAMPERING + " " + now.format(format))); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. see previous comment |
||
break; | ||
case ZONE_ALARM_ANTI_PANIC: | ||
updateState(CHANNEL_ALARM_ZONE_ALARM, new StringType(ALARM_ANTI_PANIC)); | ||
updateState(CHANNEL_ALARM_ZONE_ALARM, new StringType(ALARM_ANTI_PANIC + " " + now.format(format))); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. see previous comment |
||
break; | ||
case ZONE_ALARM_SILENT: | ||
updateState(CHANNEL_ALARM_ZONE_ALARM, new StringType(ALARM_SILENT)); | ||
updateState(CHANNEL_ALARM_ZONE_ALARM, new StringType(ALARM_SILENT + " " + now.format(format))); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. see previous comment |
||
break; | ||
case ZONE_ALARM_TECHNICAL: | ||
updateState(CHANNEL_ALARM_ZONE_ALARM, new StringType(ALARM_TECHNICAL)); | ||
updateState(CHANNEL_ALARM_ZONE_ALARM, new StringType(ALARM_TECHNICAL + " " + now.format(format))); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. see previous comment |
||
break; | ||
case ZONE_ALARM_TECHNICAL_RESET: | ||
updateState(CHANNEL_ALARM_ZONE_ALARM, new StringType(ALARM_TECHNICAL_RESET)); | ||
updateState(CHANNEL_ALARM_ZONE_ALARM, new StringType(ALARM_TECHNICAL_RESET + " " + now.format(format))); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. see previous comment |
||
break; | ||
default: | ||
updateState(CHANNEL_ALARM_ZONE_ALARM, new StringType(ALARM_NONE)); | ||
updateState(CHANNEL_ALARM_ZONE_ALARM, new StringType(ALARM_NONE + " " + now.format(format))); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. see previous comment There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see, ok I will keep working on the basis of what you suggested. Do not consider this PR! |
||
logger.warn("Alarm.updateZoneAlarm() Ignoring unsupported WHAT {} for zone {}", w, this.deviceWhere); | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do not modify other lines if they are not related to the PR