PatchworkBoy / homebridge-edomoticz

Domoticz Homebridge-Plugin
Other
118 stars 43 forks source link

Trigger security system alarm #122

Closed madcat-nl closed 6 years ago

madcat-nl commented 6 years ago

Hi,

Great work on this project, i really love to use homekit for all the hardware attached to domoticz.

I have a question: i use the security system from domoticz and it would be nice to use the build in trigger from homekit. Is there any way to set "SecuritySystemCurrentState.ALARM_TRIGGERED" from domoticz to homebridge? So when there is a panic it's reflected in homekit?

for example is it possible to send a Mqtt message and then the SecuritySystemCurrentState would switch to ALARM_TRIGGERED/Panic?

PatchworkBoy commented 6 years ago

We have no control over the MQTT messages sent by Domoticz. You’d need to use an MQTT Desktop client to monitor the current MQTT output and capture what (if anything) is sent by Domoticz when the alarm is triggered, along with the JSON API output for the same device at the same time, and provide those here.

PatchworkBoy commented 6 years ago

Try this... although no clue what it’ll do, if anything.

First, edit lib/domoticz_accesory.js and remove line 981 - case 6: //Panic

Then, copy and paste the following to line 975 (the empty line before default:):

    case 2:
    case 6:
        systemState = Characteristic.SecuritySystemCurrentState.ALARM_TRIGGERED;
    break;

Restart homebridge.

That’s as much as can be done within the confines of the HomeKit Spec. Let me know if it works or not - theoretically it should but I have no way to test it. If it does then I can add it into the next release.

PatchworkBoy commented 6 years ago

Sneaked it in alongside https://github.com/PatchworkBoy/homebridge-edomoticz/commit/7fd4dbf0206a0c2324a9d5264fef541862776643

madcat-nl commented 6 years ago

Sorry for the late reply, i have upgraded to the latest version and it works like a charm! when i send the message: { "Battery" : 255, "RSSI" : 12, "description" : "", "dtype" : "Security", "id" : "MyId", "idx" : Myidx, "name" : "Domoticz Security Panel", "nvalue" : 6, "stype" : "Security Panel", "switchType" : "On/Off", "unit" : 0 } The trigger is send to the IOS device!

All i need to do now it make a rule to send this message automatically within domoticz, but the plugin works great, Thanks a lot for fixing it.

madcat-nl commented 6 years ago

For the ones who also would like to use it, here is a script that you should add into the domoticz/scripts folder:

!/bin/sh

TOPIC="domoticz/in"; MESSAGE="{\"Battery\" : 255, \"RSSI\" : 12, \"description\" : \"\", \"dtype\" : \"Security\", \"id\" : \"YourId\", \"idx\" : YourIDX, \"name\" : \"Domoticz Security Panel\", \"nvalue\" : 6, \"stype\" : \"Security Panel\", \"switchType\" : \"On/Off\", \"unit\" : 0 }"

mosquitto_pub -h localhost -t "$TOPIC" -m "$MESSAGE"

make sure to change the YourId and YourIDX with the corresponding id's Then in blocky add the "Run Script" block and type the name of the file including a space at the end (there is a bug in the current build) it should send the panic if a certain event is triggered

@PatchworkBoy Thanks a lot for making this work

jannnfe commented 6 years ago

@PatchworkBoy Okay I've worked a bit more and could now with:

http://url:port/json.htm?type=command&param=udevice&idx=120&nvalue=6&svalue= ""

to trigger an alarm. The question I ask is why the status 6 (panic) is used instead of the status 2 (alarm).

Likewise, I wonder why the alarm on my iPhone in the home app can not be turned "off" and the security device freezes and does not respond to any changes. It would be great if you can then turn off the alarm on his mobile phone.

madcat-nl commented 4 years ago

HI,

I updated to the latest version and it looks like this change broke the MQTT part of this solution, it will set the state in domoticz correct, but it will not update the trigger state in IOS.

But the url part does work for me and correctly updates IOS to trigger an alarm i also added this on my machine: case 2: //Alarm systemState = Characteristic.SecuritySystemCurrentState.ALARM_TRIGGERED; break; around line 1300 in domoticz_accessory.js

I will use the URL solution, but it took me a while why this was not working anymore.