Stopping Apps via ssh

Discussions about Z-Way software and Z-Wave technology in general
seattleneil
Posts: 172
Joined: 02 Mar 2020 22:41

Re: Stopping Apps via ssh

Post by seattleneil »

Happy to help.

IMHO, the EasyScripting module is a convenient and efficient way to support complicated automation rules. But it has some limitations - debugging a script is not straightforward and there isn't a safety net for "bad" or slow scripts from clobbering Z-Way. Perhaps @PoltoS might consider an enhancement where an EasyScripting script would automatically be disabled if the script took longer than 5 seconds or was triggered more frequently than 5 times in a minute. Fortunately, I suspect most Z-Way users are content with the Web UI automation features (e.g., Rules and Schedules) and won't encounter the EasyScripting script gotchas.
ridewithstyle
Posts: 155
Joined: 02 Jan 2016 01:20

Re: Stopping Apps via ssh

Post by ridewithstyle »

that was tried if I remember correctly. Long or infinite loops were detected but that was removed as it wasn't working as expected.

I simply wanted a standby killer for a power plug. As soon as the plug drops under x Watts, switch it off. Works fine, except it instantly shut off after switching it on. So I had to add a delay and additional sampling. And boom, there was the cpu killer loop that I couldn't stop anymore.
seattleneil
Posts: 172
Joined: 02 Mar 2020 22:41

Re: Stopping Apps via ssh

Post by seattleneil »

That's a funny coincidence. I had a very similar need. Have you considered looking at the switch's on/off updateTime? I use something like the following in a JavaScript virtual device (binary sensor with a 60 second poll time) to turn off a power-reporting switch when it's been on for more than 120 seconds and the power consumption is less than 100 watts:

Code: Select all

if (vdev("ZWayVDev_zway_22-0-37").value() === "on")
  var powerWatts = zway.devices[22].instances[0].Meter.data[2].val.valueOf();
  var deltaTime = new Date().getTime() / 1000 - zway.devices[22].instances[0].SwitchBinary.data.level.updateTime; 
  if (deltaTime > 120 && powerWatts < 100) {
    vdev("ZWayVDev_zway_22-0-37").off()
  }
}
The same type of logic could be used in an EasyScripting script using the setInterval function From my experience, a JavaScript virtual device is "safer" as it runs asynchronously and is easier to enable/disable.
Post Reply