[SOLVED] run script on status change

Discussions about RaZberry - Z-Wave board for Raspberry computer
Post Reply
doubledrat
Posts: 13
Joined: 25 Nov 2018 13:57

[SOLVED] run script on status change

Post 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!
Last edited by doubledrat on 19 Jan 2019 14:31, edited 1 time in total.
doubledrat
Posts: 13
Joined: 25 Nov 2018 13:57

Re: run script on status change

Post 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?
User avatar
PoltoS
Posts: 7565
Joined: 26 Jan 2011 19:36

Re: run script on status change

Post 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)
doubledrat
Posts: 13
Joined: 25 Nov 2018 13:57

Re: run script on status change

Post by doubledrat »

thanks for the suggestion, but I think it's already in there -
assoc.PNG
assoc.PNG (8.38 KiB) Viewed 3888 times
doubledrat
Posts: 13
Joined: 25 Nov 2018 13:57

Re: run script on status change

Post 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
Post Reply