brommetje wrote: Tuesday 02 April 2019 12:27
Just started with dzVents and try to convert a blocky script to dzVents and have some problems.
SwitchOn is working but after 3 minutes the switch should be switchOff that doesn't happen any idea?
This is a classic phenomenon in domoticz / dzVents. Described in the
wiki as follows:
" Important note when using forXXX(): Let's say you have a light that is triggered by a motion detector. Currently the light is Off and you do this: light.switchOn().forMin(5). What happens inside Domoticz is this: at t0 Domoticz issues the switchOn() command and schedules a command to restore the current state at t5 which is Off. So at t5 it will switch the light off.
If, however, before the scheduled switchOff() happens at t5, new motion is detected and you send this command again at t2 then something unpredictable may seem to happen: the light is never turned off! This is what happens:
At t2 Domoticz receives the switchOn().forMin(5) command again. It sees a scheduled command at t5 and deletes that command (it is within the new interval). Then Domoticz performs the (unnecessary, it's already on) switchOn() command. Then it checks the current state of the light which is On!! and schedules a command to return to that state at t2+5=t7. So, at t7 the light is switched on again. And there you have it: the light is not switched off and never will be because future commands will always be checked against the current on-state.
That's just how it works and you will have to deal with it in your script"
Can you try this ?
Code: Select all
return {
on = {
devices = {
['MOTION_Sensor_GANG'] = {'between 23:00 and 30 minutes after sunrise'}
}
},
execute = function(domoticz, device)
if device.state == 'On' then
local ganglamp = domoticz.devices('IKEA Gang')
ganglamp.switchOn().checkFirst()
ganglamp.cancelQueuedCommands()
ganglamp.switchOff().afterMin(3)
domoticz.log('Effe lamp in de gang aanzetten voor (weer) 3 minuten !!!')
else
domoticz.log('Effe niets doen !!!')
end
end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>>
dzVents wiki