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]