From 53fb74bda6c098680e300f4b33e407dff7e2e4c2 Mon Sep 17 00:00:00 2001 From: tylerbinski <4217402+tylerbinski@users.noreply.github.com> Date: Sat, 8 Feb 2025 22:05:34 -0500 Subject: [PATCH 1/3] Examples - esp8266 - OpenHAB-MQTT --> Add Arm Mode Night (Stay with No Entry Delay) Issue # 361 --- examples/esp8266/OpenHAB-MQTT/OpenHAB-MQTT.ino | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/examples/esp8266/OpenHAB-MQTT/OpenHAB-MQTT.ino b/examples/esp8266/OpenHAB-MQTT/OpenHAB-MQTT.ino index 60a64f0..4df2158 100644 --- a/examples/esp8266/OpenHAB-MQTT/OpenHAB-MQTT.ino +++ b/examples/esp8266/OpenHAB-MQTT/OpenHAB-MQTT.ino @@ -33,6 +33,7 @@ Thing mqtt:topic:mymqtt:dsc "DSC Security System" (mqtt:broker:mymqtt) @ "Home" Type string : partition1_message "Partition 1" [stateTopic="dsc/Get/Partition1/Message"] Type switch : partition1_armed_away "Partition 1 Armed Away" [stateTopic="dsc/Get/Partition1", commandTopic="dsc/Set", on="1A", off="1D"] Type switch : partition1_armed_stay "Partition 1 Armed Stay" [stateTopic="dsc/Get/Partition1", commandTopic="dsc/Set", on="1S", off="1D"] + Type switch : partition1_armed_night "Partition 1 Armed Night" [stateTopic="dsc/Get/Partition1", commandTopic="dsc/Set", on="1N", off="1D"] Type switch : partition1_alarm "Partition 1 Alarm" [stateTopic="dsc/Get/Partition1", on="1T", off="1D"] Type switch : partition1_fire "Partition 1 Fire" [stateTopic="dsc/Get/Fire1", on="1", off="0"] Type switch : panel_online "Panel Online" [stateTopic="dsc/Status", on="online", off="offline"] @@ -50,6 +51,7 @@ Thing mqtt:topic:mymqtt:dsc "DSC Security System" (mqtt:broker:mymqtt) @ "Home" String partition1_message "Partition 1 [%s]" {channel="mqtt:topic:mymqtt:dsc:partition1_message"} Switch partition1_armed_away "Partition 1 Armed Away" {channel="mqtt:topic:mymqtt:dsc:partition1_armed_away"} Switch partition1_armed_stay "Partition 1 Armed Stay" {channel="mqtt:topic:mymqtt:dsc:partition1_armed_stay"} +Switch partition1_armed_night "Partition 1 Armed Night" {channel="mqtt:topic:mymqtt:dsc:partition1_armed_night"} Switch partition1_triggered "Partition 1 Alarm" {channel="mqtt:topic:mymqtt:dsc:partition1_alarm"} Switch partition1_fire "Partition 1 Fire" {channel="mqtt:topic:mymqtt:dsc:partition1_fire"} Switch panel_online "Panel Online" {channel="mqtt:topic:mymqtt:dsc:panel_online"} @@ -64,6 +66,7 @@ Contact zone3 "Zone 3" {channel="mqtt:topic:mymqtt:dsc:zone3"} * The commands to set the alarm state are setup in OpenHAB with the partition number (1-8) as a prefix to the command: * Partition 1 stay arm: "1S" * Partition 1 away arm: "1A" + * Partition 1 night (no entry delay) arm: "1N" * Partition 2 disarm: "2D" * * The interface listens for commands in the configured mqttSubscribeTopic, and publishes partition status in a @@ -261,6 +264,11 @@ void loop() { else if (dsc.armedStay[partition]) { publishState(mqttPartitionTopic, partition, "S"); } + + // Armed - Instant Alarm - Night Mode (No Exit Delay) + else if (dsc.noEntryDelay[partition]) { + publishState(mqttPartitionTopic, partition, "N"); + } } // Disarmed @@ -398,6 +406,13 @@ void mqttCallback(char* topic, byte* payload, unsigned int length) { return; } + // Arm - No Entry Delay - Night Mode + if (payload[payloadIndex] == 'N' && !dsc.armed[partition] && !dsc.exitDelay[partition]) { + dsc.writePartition = partition + 1; // Sets writes to the partition number + dsc.write('n'); // Keypad - Arm with no entry delay (night arm) + return; + } + // Disarm if (payload[payloadIndex] == 'D' && (dsc.armed[partition] || dsc.exitDelay[partition] || dsc.alarm[partition])) { dsc.writePartition = partition + 1; // Sets writes to the partition number From 9cbd57dcb9a9e1771b0e04987425a69577d39c35 Mon Sep 17 00:00:00 2001 From: tylerbinski <4217402+tylerbinski@users.noreply.github.com> Date: Mon, 24 Mar 2025 23:55:49 -0400 Subject: [PATCH 2/3] Fix Status reporting as STAY when in NIGHT mode. Fixed the logic so that Night mode is not reported as Stay with. the logic now considers no entry delay in order to report as N mode. --- examples/esp8266/OpenHAB-MQTT/OpenHAB-MQTT.ino | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/examples/esp8266/OpenHAB-MQTT/OpenHAB-MQTT.ino b/examples/esp8266/OpenHAB-MQTT/OpenHAB-MQTT.ino index 4df2158..41a8eb0 100644 --- a/examples/esp8266/OpenHAB-MQTT/OpenHAB-MQTT.ino +++ b/examples/esp8266/OpenHAB-MQTT/OpenHAB-MQTT.ino @@ -31,6 +31,7 @@ Bridge mqtt:broker:mymqtt "My MQTT" [host="MQTT broker IP address or hostname"] Thing mqtt:topic:mymqtt:dsc "DSC Security System" (mqtt:broker:mymqtt) @ "Home" { Channels: Type string : partition1_message "Partition 1" [stateTopic="dsc/Get/Partition1/Message"] + Type string : partition1_armed_mode "Alarm Armed Mode" [stateTopic="dsc/Get/Partition1", commandTopic="dsc/Set"] Type switch : partition1_armed_away "Partition 1 Armed Away" [stateTopic="dsc/Get/Partition1", commandTopic="dsc/Set", on="1A", off="1D"] Type switch : partition1_armed_stay "Partition 1 Armed Stay" [stateTopic="dsc/Get/Partition1", commandTopic="dsc/Set", on="1S", off="1D"] Type switch : partition1_armed_night "Partition 1 Armed Night" [stateTopic="dsc/Get/Partition1", commandTopic="dsc/Set", on="1N", off="1D"] @@ -38,8 +39,8 @@ Thing mqtt:topic:mymqtt:dsc "DSC Security System" (mqtt:broker:mymqtt) @ "Home" Type switch : partition1_fire "Partition 1 Fire" [stateTopic="dsc/Get/Fire1", on="1", off="0"] Type switch : panel_online "Panel Online" [stateTopic="dsc/Status", on="online", off="offline"] Type switch : panel_trouble "Panel Trouble" [stateTopic="dsc/Get/Trouble", on="1", off="0"] - Type switch : pgm1 "PGM 1" [stateTopic="dsc/Get/PGM 1", on="1", off="0"] - Type switch : pgm8 "PGM 8" [stateTopic="dsc/Get/PGM 8", on="1", off="0"] + Type switch : pgm1 "PGM 1" [stateTopic="dsc/Get/PGM1", on="1", off="0"] + Type switch : pgm8 "PGM 8" [stateTopic="dsc/Get/PGM8", on="1", off="0"] Type contact : zone1 "Zone 1" [stateTopic="dsc/Get/Zone1", on="1", off="0"] Type contact : zone2 "Zone 2" [stateTopic="dsc/Get/Zone2", on="1", off="0"] Type contact : zone3 "Zone 3" [stateTopic="dsc/Get/Zone3", on="1", off="0"] @@ -49,6 +50,7 @@ Thing mqtt:topic:mymqtt:dsc "DSC Security System" (mqtt:broker:mymqtt) @ "Home" * - https://www.openhab.org/docs/configuration/items.html String partition1_message "Partition 1 [%s]" {channel="mqtt:topic:mymqtt:dsc:partition1_message"} +String partition1_armed_mode "Armed Mode" {channel="mqtt:topic:mosquitto:dsc:partition1_armed_mode"} Switch partition1_armed_away "Partition 1 Armed Away" {channel="mqtt:topic:mymqtt:dsc:partition1_armed_away"} Switch partition1_armed_stay "Partition 1 Armed Stay" {channel="mqtt:topic:mymqtt:dsc:partition1_armed_stay"} Switch partition1_armed_night "Partition 1 Armed Night" {channel="mqtt:topic:mymqtt:dsc:partition1_armed_night"} @@ -260,17 +262,19 @@ void loop() { publishState(mqttPartitionTopic, partition, "A"); } + // Armed - Night Mode / Instant Alarm (Stay and no Entry Delay) + else if (dsc.armedStay[partition] && dsc.noEntryDelay[partition]) { + publishState(mqttPartitionTopic, partition, "N"); + } + // Armed stay else if (dsc.armedStay[partition]) { publishState(mqttPartitionTopic, partition, "S"); } - // Armed - Instant Alarm - Night Mode (No Exit Delay) - else if (dsc.noEntryDelay[partition]) { - publishState(mqttPartitionTopic, partition, "N"); - } } + // Disarmed else publishState(mqttPartitionTopic, partition, "D"); } From 73ff9095ddefb44b9197a594baf7c081fe5ccd6f Mon Sep 17 00:00:00 2001 From: tylerbinski <4217402+tylerbinski@users.noreply.github.com> Date: Mon, 24 Mar 2025 23:56:50 -0400 Subject: [PATCH 3/3] update mqtt server name - fix typo --- examples/esp8266/OpenHAB-MQTT/OpenHAB-MQTT.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/esp8266/OpenHAB-MQTT/OpenHAB-MQTT.ino b/examples/esp8266/OpenHAB-MQTT/OpenHAB-MQTT.ino index 41a8eb0..e6c11ad 100644 --- a/examples/esp8266/OpenHAB-MQTT/OpenHAB-MQTT.ino +++ b/examples/esp8266/OpenHAB-MQTT/OpenHAB-MQTT.ino @@ -50,7 +50,7 @@ Thing mqtt:topic:mymqtt:dsc "DSC Security System" (mqtt:broker:mymqtt) @ "Home" * - https://www.openhab.org/docs/configuration/items.html String partition1_message "Partition 1 [%s]" {channel="mqtt:topic:mymqtt:dsc:partition1_message"} -String partition1_armed_mode "Armed Mode" {channel="mqtt:topic:mosquitto:dsc:partition1_armed_mode"} +String partition1_armed_mode "Armed Mode" {channel="mqtt:topic:mymqtt:dsc:partition1_armed_mode"} Switch partition1_armed_away "Partition 1 Armed Away" {channel="mqtt:topic:mymqtt:dsc:partition1_armed_away"} Switch partition1_armed_stay "Partition 1 Armed Stay" {channel="mqtt:topic:mymqtt:dsc:partition1_armed_stay"} Switch partition1_armed_night "Partition 1 Armed Night" {channel="mqtt:topic:mymqtt:dsc:partition1_armed_night"}