Binding to openHAB2
Posted: Wed 05 Apr 2017, 13:04
I've got most of the functionality working here - if the PIR in the hall is activated, I can trigger a rule to switch on a light:
items file:
rules file:
That's all working fine, but I'm now trying to set up a switch to arm/disarm the alarm so I need to send a message back via MQTT to do that.
This is the Mosquitto sub feed:
The last two lines above are the result of toggling the following switch item on the sitemap:
What format of message via MQTT would trigger a set/unset?
Should it even be possible to control the alarm like this, or is it all read-only?
items file:
Code: Select all
String iBeam_Hall "Hall PIR [%s]" <motion> {mqtt="<[mqtt:/SPC/G_SPC_ZONE_INPUT_2:state:JSONPATH(status)]"}
Code: Select all
rule "PIR toggles light"
when
Item iBeam_Hall changed
then
if (iBeam_Hall.state == "open") {
zwave_device_15a390b5594_node2_switch_dimmer.sendCommand(ON)
}
else if (iBeam_Hall.state == "closed") {
zwave_device_15a390b5594_node2_switch_dimmer.sendCommand(OFF)
}
end
This is the Mosquitto sub feed:
Code: Select all
mosquitto_sub -v -t /#
/SPC/G_SPC_AREA_MODE_1 {"update_time":1491385018195,"status":"unset"}
/SPC/G_SPC_ZONE_INPUT_1 {"update_time":1491385018183,"status":"closed"}
/SPC/G_SPC_ZONE_STATUS_1 {"update_time":1491385018183,"status":"ok"}
/SPC/G_SPC_ZONE_INPUT_2 {"update_time":1491392732843,"status":"closed"}
/SPC/G_SPC_ZONE_STATUS_2 {"update_time":1491385018184,"status":"ok"}
/SPC/G_SPC_ZONE_INPUT_3 {"update_time":1491385018184,"status":"closed"}
/SPC/G_SPC_ZONE_STATUS_3 {"update_time":1491385018184,"status":"ok"}
/SPC/G_SPC_ZONE_INPUT_4 {"update_time":1491389782807,"status":"closed"}
/SPC/G_SPC_ZONE_STATUS_4 {"update_time":1491385018184,"status":"ok"}
/SPC/G_SPC_ZONE_INPUT_5 {"update_time":1491385018184,"status":"closed"}
/SPC/G_SPC_ZONE_STATUS_5 {"update_time":1491385018184,"status":"isolate"}
/SPC/G_SPC_ZONE_INPUT_6 {"update_time":1491385018184,"status":"closed"}
/SPC/G_SPC_ZONE_STATUS_6 {"update_time":1491385018184,"status":"ok"}
/SPC/G_SPC_ZONE_INPUT_7 {"update_time":1491385018184,"status":"closed"}
/SPC/G_SPC_ZONE_STATUS_7 {"update_time":1491385018184,"status":"ok"}
/SPC/G_SPC_AREA_MODE_1 0
/SPC/G_SPC_AREA_MODE_1 3
Code: Select all
Switch Toggle_Alarm "Toggle Alarm" {mqtt=">[mqtt:/SPC/G_SPC_AREA_MODE_1:command:ON:0],>[mqtt:/SPC/G_SPC_AREA_MODE_1:command:OFF:3]"}
Should it even be possible to control the alarm like this, or is it all read-only?