Page 1 of 1
lamp not reacting to script
Posted: Monday 09 September 2019 19:46
by snellejellep
Hi all,
i have this really simple script you can see below which should turn on a lamp for 5 minutes when a door is opened or immediately turn the lamp off when the door is closed. i can see in my log that the script reacts to my door sensor but it does not turn on my lamp, am i missing something? the names are matching, even tried filling in the idx but that also results in nothing...
Code: Select all
return {
on = {
devices = {
'Deur Kast tuinkamer'
},
},
execute = function(dz, device)
local deur = dz.devices("Deur Kast tuinkamer")
local lamp = dz.devices("Lamp kast tuinkamer")
if deur.state == "Open" then
lamp.switchOn().forMin(5)
elseif deur.state == "Closed" and lamp.state == "On" then
lamp.switchOff()
end
end
}
Re: lamp not reacting to script
Posted: Monday 09 September 2019 20:22
by waaren
snellejellep wrote: Monday 09 September 2019 19:46
i have this really simple script you can see below which should turn on a lamp for 5 minutes when a door is opened or immediately turn the lamp off when the door is closed. i can see in my log that the script reacts to my door sensor but it does not turn on my lamp.
To understand what is happening it can be helpful to add some log statements in the script. I have seen many forum-members struggling with the behavior of the dzVents forXXX and repeatXXX methods and therefore I try to prevent the use of them. Luckily it is quite simple to replace these methods with a combination of the afterXXX and cancelQueuedCommands() method.
like below
Code: Select all
return
{
on =
{
devices =
{
'Deur Kast tuinkamer'
},
},
logging =
{
level = domoticz.LOG_DEBUG,
marker = 'tuinkamer control',
},
execute = function(dz, item)
local lamp = dz.devices("Lamp kast tuinkamer")
lamp.cancelQueuedCommands()
if item.state == "Open" then
lamp.switchOn().checkFirst()
lamp.swotchOff().afterMin(5)
else
lamp.switchOff().checkFirst()
end
end
}
Re: lamp not reacting to script
Posted: Monday 09 September 2019 21:20
by snellejellep
thank you, tried your code but i unfortunately get the same result.
also, my log is not giving any more information:
Code: Select all
2019-09-09 21:17:08.209 Status: dzVents: Info: Handling events for: "Deur kast tuinkamer", value: "Open"
2019-09-09 21:17:08.209 Status: dzVents: Info: ------ Start internal script: Alarm away dzvents: Device: "Deur kast tuinkamer (zigbee2mqtt)", Index: 682
2019-09-09 21:17:08.215 Status: dzVents: Info: ------ Finished Alarm away dzvents
2019-09-09 21:17:11.088 (domo slave) General/Percentage (CPU_slave)
2019-09-09 21:17:12.971 (hpauto) General/Percentage (hpauto cpu)
2019-09-09 21:17:13.113 Status: dzVents: Info: Handling events for: "Deur kast tuinkamer", value: "Closed"
2019-09-09 21:17:13.114 Status: dzVents: Info: ------ Start internal script: Alarm away dzvents: Device: "Deur kast tuinkamer (zigbee2mqtt)", Index: 682
2019-09-09 21:17:13.118 Status: dzVents: Info: ------ Finished Alarm away dzvents
2019-09-09 21:17:15.251 MQTT: Topic: domoticz/in, Message: {"idx":429,"nvalue":0,"svalue":"","Battery":18,"RSSI":7}
2019-09-09 21:17:16.631 Status: dzVents: Info: Handling events for: "Deur kast tuinkamer", value: "Open"
2019-09-09 21:17:16.631 Status: dzVents: Info: ------ Start internal script: Alarm away dzvents: Device: "Deur kast tuinkamer (zigbee2mqtt)", Index: 682
2019-09-09 21:17:16.636 Status: dzVents: Info: ------ Finished Alarm away dzvents
2019-09-09 21:17:18.364 Status: dzVents: Info: Handling events for: "Deur kast tuinkamer", value: "Closed"
2019-09-09 21:17:18.364 Status: dzVents: Info: ------ Start internal script: Alarm away dzvents: Device: "Deur kast tuinkamer (zigbee2mqtt)", Index: 682
2019-09-09 21:17:18.369 Status: dzVents: Info: ------ Finished Alarm away dzvents
which i find really weird, i tried the log part before but it did not help me and now it also does not...
but thanks anyway.
waaren wrote: Monday 09 September 2019 20:22
To understand what is happening it can be helpful to add some log statements in the script. I have seen many forum-members struggling with the behavior of the dzVents forXXX and repeatXXX methods and therefore I try to prevent the use of them. Luckily it is quite simple to replace these methods with a combination of the afterXXX and cancelQueuedCommands() method.
like below
Code: Select all
return
{
on =
{
devices =
{
'Deur Kast tuinkamer'
},
},
logging =
{
level = domoticz.LOG_DEBUG,
marker = 'tuinkamer control',
},
execute = function(dz, item)
local lamp = dz.devices("Lamp kast tuinkamer")
lamp.cancelQueuedCommands()
if item.state == "Open" then
lamp.switchOn().checkFirst()
lamp.swotchOff().afterMin(5)
else
lamp.switchOff().checkFirst()
end
end
}
Re: lamp not reacting to script
Posted: Monday 09 September 2019 21:25
by snellejellep
something i just tried, a simple blockly like this works... strange...
https://imgur.com/a/OFSwxwO
Re: lamp not reacting to script
Posted: Monday 09 September 2019 21:37
by waaren
snellejellep wrote: Monday 09 September 2019 21:20
thank you, tried your code but i unfortunately get the same result.
also, my log is not giving any more information:
It does to me
there is difference between "kast" and "Kast" and I don't see any debug log lines so it shows the log of a different script.
Re: lamp not reacting to script
Posted: Tuesday 10 September 2019 19:18
by snellejellep
waaren wrote: Monday 09 September 2019 21:37
It does to me
there is difference between "kast" and "Kast" and I don't see any debug log lines so it shows the log of a different script.
well, thats stupid, i forgot to check that... without capital k it works... thanks!