Action script only executing a few times
Posted: Saturday 25 July 2020 9:08
I've got a number of devices which I usually control through either webinterface of app. Now I've got myself a few switches and want to use these switch lights on and of.
I've got a small php script:
Which runs file. Calling 'switch.php 30' for instance toggles my bathroom light.Then I put
In the 'on' action of one of the buttons. Tested it and it worked. I got to switch the bathroom light on and off. So far, so good. But after 5 or 6 times, it appears not to invoke the script anymore.
Each press of a button is neatly recorded in the switch's log:
But only the first few of these triggered the php script. Then removed these action scripts and created a script in Domoticz:
This is script is for both buttons. 46 to trigger the bathroom light, 47 to trigger the bathroom ventilator. If I look at the log, it should be working:
But as you can tell, @9:02:52 it thinks it switched the bathroom on, but it didn't, since @9:03:11 it tries to switch it on again.
Does anyone have a clue where to look?
BTW:
I've got a small php script:
Code: Select all
#!/usr/bin/php
<?php
$id=$argv[1];
print "Id: $id";
$js=file_get_contents("http://192.168.11.119:8080/json.htm?type=devices&rid=$id");
$p=json_decode($js);
if ($p->result[0]->Data=='On') {
print "Uitschakelen";
$r=file_get_contents("http://192.168.11.119:8080/json.htm?type=command¶m=switchlight&switchcmd=Off&idx=$id");
} else {
print "Aanzetten";
$r=file_get_contents("http://192.168.11.119:8080/json.htm?type=command¶m=switchlight&switchcmd=On&idx=$id");
}
?>
Code: Select all
script://switch.php 30
Each press of a button is neatly recorded in the switch's log:
Code: Select all
2020-07-25 08:52:30 On Admin
2020-07-25 08:50:04 On Admin
2020-07-25 08:17:01 On Admin
2020-07-25 08:16:49 On Admin
2020-07-25 08:16:01 On Admin
2020-07-25 08:15:46 On Admin
Code: Select all
return {
on = {
devices = {
46,47
}
},
execute = function(domoticz, device)
domoticz.log('Device ' .. device.name .. ' was clicked', domoticz.LOG_INFO)
if (device.id == 46) then
if (domoticz.devices(30).state == 'On') then
domoticz.devices(30).switchOff()
domoticz.log('Device 30 was switched off', domoticz.LOG_INFO)
else
domoticz.devices(30).switchOn()
domoticz.log('Device 30 was switched on', domoticz.LOG_INFO)
end
end
if (device.id == 47) then
if (domoticz.devices(31).state == 'On') then
domoticz.devices(31).switchOff()
domoticz.log('Device 31 was switched off', domoticz.LOG_INFO)
else
domoticz.devices(31).switchOn()
domoticz.log('Device 31 was switched on', domoticz.LOG_INFO)
end
end
end
}
Code: Select all
2020-07-25 09:02:52.386 Status: dzVents: Info: Handling events for: "SW Badkamer", value: "On"
2020-07-25 09:02:52.386 Status: dzVents: Info: ------ Start internal script: Script #1: Device: "SW Badkamer (Z-Stick gen5)", Index: 46
2020-07-25 09:02:52.387 Status: dzVents: Info: Device SW Badkamer was clicked
2020-07-25 09:02:52.403 Status: dzVents: Info: Device 30 was switched on
2020-07-25 09:02:52.403 Status: dzVents: Info: ------ Finished Script #1
2020-07-25 09:02:52.407 Status: EventSystem: Script event triggered: /home/pi/domoticz/dzVents/runtime/dzVents.lua
2020-07-25 09:03:11.377 Status: dzVents: Info: Handling events for: "SW Badkamer", value: "On"
2020-07-25 09:03:11.377 Status: dzVents: Info: ------ Start internal script: Script #1: Device: "SW Badkamer (Z-Stick gen5)", Index: 46
2020-07-25 09:03:11.378 Status: dzVents: Info: Device SW Badkamer was clicked
2020-07-25 09:03:11.394 Status: dzVents: Info: Device 30 was switched on
2020-07-25 09:03:11.394 Status: dzVents: Info: ------ Finished Script #1
Does anyone have a clue where to look?
BTW:
Code: Select all
Version: 2020.2
Build Hash: b63341bc0
Compile Date: 2020-04-26 13:47:55
dzVents Version: 3.0.2
Python Version: 3.7.3 (default, Dec 20 2019, 18:57:59) [GCC 8.3.0]