Page 1 of 1
Timed device trigger not working...
Posted: Friday 04 October 2019 22:36
by FearNaBoinne
I am trying to use a timed device trigger, but it's not working...
Can anyone tell me what I am doing wrong?
Code: Select all
return {
on = {
devices = { ['Voordeur Entry Sensor'] = { 'at nighttime' } }
},
execute = function(domoticz, device)
domoticz.log('Hal licht aan/uit.', domoticz.LOG_INFO)
if ( device.status == "open" ) then
-- turn light on
domoticz.devices('Ganglicht BG').setState("On")
elseif ( device.status == 'closed' ) then
-- turn light off after one minute
domoticz.devices('Ganglicht BG').setState("Off").afterMin(1)
end
end
}
It is not triggering at all, even though the device name is correct and the time is between sunset and sunrise...
Re: Timed device trigger not working...
Posted: Friday 04 October 2019 23:21
by waaren
FearNaBoinne wrote: ↑Friday 04 October 2019 22:36
I am trying to use a timed device trigger, but it's not working...
It is not triggering at all, even though the device name is correct and the time is between sunset and sunrise...
I can't see anything wrong with your script. Just tested below (domoticz V4.11350 / dzVents 2.4.29
Code: Select all
return {
on = {
devices = { ['my Trigger'] = { 'at nighttime' } }
},
execute = function(dz, item)
dz.log(item.name .. ' triggered this script.', dz.LOG_FORCE)
end
}
Log
- Spoiler: show
Code: Select all
]2019-10-04 23:18:41.149 Status: dzVents: Info: Handling events for: "my Trigger", value: "On"
2019-10-04 23:18:41.150 Status: dzVents: Info: ------ Start external script: dumper499 (combined trigger).lua: Device: "my Trigger (Virtual)", Index: 2355
2019-10-04 23:18:41.152 Status: dzVents: !Info: my Trigger triggered this script.
2019-10-04 23:18:41.156 Status: dzVents: Info: ------ Finished dumper499 (combined trigger).lua
Re: Timed device trigger not working... [Solved]
Posted: Friday 04 October 2019 23:28
by BOverdevest
Hi
Is the use of "status" correct? I think it should be ".state"
Below my script for a similar situation. The OD's are the Open/Close devices.
Code: Select all
--Voordeur of zijdeur open
return {
on = { devices = {['OD Voordeur'] = {'at nighttime'},['OD Zijdeur'] = {'at nighttime'}}},
execute = function(domoticz, device)
domoticz.devices('Voordeur Lamp').switchOn().checkFirst().forMin(10)
end
}
Re: Timed device trigger not working...
Posted: Friday 04 October 2019 23:48
by FearNaBoinne
BOverdevest wrote: ↑Friday 04 October 2019 23:28
Is the use of "status" correct? I think it should be ".state"
Weird, I missed that, and as soon as I changed it, the script started triggering... Very strange that it didn't even trigger when it said .status instead of .state, but did not show any errors in the editor NOR in the logs!...
Re: Timed device trigger not working...
Posted: Friday 04 October 2019 23:58
by waaren
FearNaBoinne wrote: ↑Friday 04 October 2019 23:48
Weird, I missed that, and as soon as I changed it, the script started triggering... Very strange that it didn't even trigger when it said .status instead of .state, but did not show any errors in the editor NOR in the logs!...
The triggering of the script should not be influenced by this. And
Code: Select all
if ( device.status == "open" ) then
is formally not an error. It will just always evaluates to false because device.status is not equal to "open" (it is nil)
Can you check your dzVents loglevel ? Do you see other scripts being triggered if they do not have an explicit logging = section ?
Re: Timed device trigger not working...
Posted: Saturday 05 October 2019 9:22
by FearNaBoinne
waaren wrote: ↑Friday 04 October 2019 23:58
The triggering of the script should not be influenced by this.
I know, and I was about to respond with that, but then I thought I'd try fixing that error anyway, and after that it worked... And the *only* thing I did was replace 'us' with 'e' (twice)...
waaren wrote: ↑Friday 04 October 2019 23:58
Can you check your dzVents loglevel ? Do you see other scripts being triggered if they do not have an explicit logging = section ?
Yup, and once I changed the .status-es for .state-s, so did this one (even without the domoticz.log line), but not before that! I don't understand either...