Page 1 of 1

[SOLVED] run script on status change

Posted: 18 Jan 2019 19:26
by doubledrat
Hi there

I'm having real trouble finding enough information to do this. Can someone help please?

This is my device description

Code: Select all

      {
        "creationTime": 1473888157,
        "creatorId": 1,
        "deviceType": "doorlock",
        "h": 1078450102,
        "hasHistory": true,
        "id": "ZWayVDev_zway_2-0-98",
        "location": 1,
        "metrics": {
          "level": "close",
          "icon": "door",
          "title": "Yale Door Lock (2.0)"
        },
        "permanently_hidden": false,
        "probeType": "",
        "tags": [],
        "visibility": true,
        "updateTime": 1547802239
      },
I have put the following code in /opt/z-way-server/automation/main.js

Code: Select all

zway.devices[2].instances[0].metrics.level.bind(function () {
        debugPrint("Doorlock level is '" + this.value + "'");
        try {
                system("python /home/pi/Desktop/network_send.py");
                return;
        } catch (err) {
                debugPrint("Failed to execute script system call: " + err);
        }
});
but nothing is happening.

firstly how do I see the results of debugPrint?
secondly have I done the bind correctly?

thanks for any help!

Re: run script on status change

Posted: 18 Jan 2019 22:42
by doubledrat
OK, I worked out how to do this. the bind should have been

Code: Select all

zway.devices[2].instances[0].DoorLock.data.mode.bind(function () {
however, it only seems to trigger when I use the UI update the status of the doorlock?

I Need it to trigger on state change. How do I do that?

Re: run script on status change

Posted: 19 Jan 2019 12:55
by PoltoS
make sure your lock is sending updates to Z-Way. For this it should have Z-Way in LifeLine group (Association group #1)

Re: run script on status change

Posted: 19 Jan 2019 13:39
by doubledrat
thanks for the suggestion, but I think it's already in there -
assoc.PNG
assoc.PNG (8.38 KiB) Viewed 3896 times

Re: run script on status change

Posted: 19 Jan 2019 14:30
by doubledrat
I've found out what the issue was. the device wasn't updating the UI. I added it to "Niffler" and all started working :D

https://github.com/jensmoes/Niffler