I'm currently having some trouble with the dzvenst script i've written for my lights.
I'm using one selector switch to say if I want it all automated (Auto) or manually On or Off (5 levels in total).
Then I have two dummy light switch for the schedule (outdoor lights and indoor lights) to indicate if the lights should be switched On or Off depending on the day of the week and so on.
All modes are working except for the Auto : the lights are not switched On or Off according to the schedule (the dummy switch used for the schedule are going On and Off as planned).
Here is the code :
Code: Select all
return {
active = true,
on = {
devices = { 'Selecteur_Ambiance',
'Planning_Eclairage_Indoor',
'Planning_Eclairage_Outdoor'
}
},
-- custom logging level for this script
logging = {
level = domoticz.LOG_DEBUG,
marker = "Script Ambiance_lumineuse_v2"
},
execute = function(domoticz, Selecteur_Ambiance, Planning_Eclairage_Indoor, Planning_Eclairage_Outdoor)
if (Selecteur_Ambiance.levelName == 'Off_All') then -- Full Off
domoticz.devices('Lampe_Salle_a_Manger').switchOff()
domoticz.devices('Lampe_Entrée').switchOff()
domoticz.devices('Eclairage_Exterieur').switchOff()
domoticz.devices('Level_Lampe_Buffet').switchOff()
domoticz.log('The lights are switched Off forever')
end
if (Selecteur_Ambiance.levelName == 'On_All') then -- Full On
domoticz.devices('Lampe_Salle_a_Manger').switchOn()
domoticz.devices('Lampe_Entrée').switchOn()
domoticz.devices('Eclairage_Exterieur').switchOn()
domoticz.devices('Level_Lampe_Buffet').switchOn()
domoticz.log('The lights are switched On forever')
end
if (Selecteur_Ambiance.levelName == 'On_Once') then -- Set everything On once and then back to Auto at 23:59
domoticz.devices('Lampe_Salle_a_Manger').switchOn()
domoticz.devices('Lampe_Entrée').switchOn()
domoticz.devices('Eclairage_Exterieur').switchOn()
Selecteur_Ambiance.switchSelector('Auto').at('23:59')
domoticz.log('The lights are switched On and selector set on Auto')
end
if (Selecteur_Ambiance.levelName == 'Off_Once') then -- Set everything Off once and then back to Auto at 23:59
domoticz.devices('Lampe_Salle_a_Manger').switchOff()
domoticz.devices('Lampe_Entrée').switchOff()
domoticz.devices('Eclairage_Exterieur').switchOff()
Selecteur_Ambiance.switchSelector('Auto').at('23:59')
domoticz.log('The lights are switched Off and selector set on Auto')
end
if (Selecteur_Ambiance.levelName == 'Auto' and Planning_Eclairage_Indoor.state == 'On') then -- Auto as per Planning_Eclairage_Indoor On
domoticz.devices('Lampe_Salle_a_Manger').switchOn()
domoticz.devices('Lampe_Entrée').switchOn()
domoticz.log('The lights are switched On (Auto Inside)')
end
if (Selecteur_Ambiance.levelName == 'Auto' and Planning_Eclairage_Indoor.state == 'Off') then -- Auto as per Planning_Eclairage_Indoor Off
domoticz.devices('Lampe_Salle_a_Manger').switchOff()
domoticz.devices('Lampe_Entrée').switchOff()
domoticz.log('The lights are switched Off (Auto Inside)')
end
if (Selecteur_Ambiance.levelName == 'Auto' and Planning_Eclairage_Outdoor.state == 'On') then -- Auto as per Planning_Eclairage_Outdoor On
domoticz.devices('Eclairage_Exterieur').switchOn()
domoticz.log('The lights are switched On (Auto Outside)')
end
if (Selecteur_Ambiance.levelName == 'Auto' and Planning_Eclairage_Outdoor.state == 'Off') then -- Auto as per Planning_Eclairage_Outdoor Off
domoticz.devices('Eclairage_Exterieur').switchOff()
domoticz.log('The lights are switched Off (Auto Outside)')
end
end
}
Code: Select all
2021-12-09 21:00:00.585 Status: Starting automatic database backup procedure...
2021-12-09 21:00:01.585 Status: Schedule item started! Name: Planning_Eclairage_Outdoor, Type: On Time, DevID: 268, Time: 2021-12-09 21:00:01
2021-12-09 21:00:02.874 Planning_Eclairage_Outdoor: Light/Switch (Planning_Eclairage_Outdoor)
2021-12-09 21:00:02.862 Status: Ending automatic database backup procedure...
2021-12-09 21:00:03.053 Status: dzVents: Info: Handling events for: "Planning_Eclairage_Outdoor", value: "Off"
2021-12-09 21:00:03.053 Status: dzVents: Info: Script Ambiance_lumineuse_v2: ------ Start internal script: Ambiance_lumineuse_v2: Device: "Planning_Eclairage_Outdoor (Planning_Eclairage_Outdoor)", Index: 268
2021-12-09 21:00:03.054 Status: dzVents: Info: Script Ambiance_lumineuse_v2: ------ Finished Ambiance_lumineuse_v2
I've tried as well a version with if/elseif but with the same results.
If anyone has an idea...
Thanks in advance for wour help
Thomas