Binding to openHAB2

How to integrate SPC Web Gateway with different Home Automation Systems
Post Reply
roryd
Posts: 9
Joined: Tue 21 Jun 2016, 16:05

Binding to openHAB2

Post by roryd »

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:

Code: Select all

String iBeam_Hall "Hall PIR [%s]" <motion> {mqtt="<[mqtt:/SPC/G_SPC_ZONE_INPUT_2:state:JSONPATH(status)]"}
rules file:

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
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:

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
The last two lines above are the result of toggling the following switch item on the sitemap:

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]"}
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?
gol
Webbplatsadministratör
Posts: 72
Joined: Sun 01 Jun 2014, 19:38

Re: Binding to openHAB2

Post by gol »

Hi Roryd,
You need to use the REST API directly to send commands to the SPC Panel.
Please see SPC Web Gateway Specification for details.

Best Regards,
Goran
Post Reply