Page 1 of 1
Problème state switch
Posted: Sunday 30 June 2019 17:47
by Hydci
Hello,
My script works by cons when I add a condition this one does not work anymore and and I can not understand the mistake I made
elseif dz.time.matchesRule('25 minutes after sunset') and dz.devices('Jardin').state == 'Off' then
MY SCRIPT WORK
elseif dz.time.matchesRule('25 minutes after sunset') and dz.devices('Jardin').state == 'Off' and dz.devices('Volet cuisine').state == 'On' then
MY SCRIPT NO WORK
Code: Select all
return {
on =
{
timer = { '25 minutes after sunset','at 7:30 on mon,tue,thu,fri','at 8:30 on wed,sat,sun'},
devices = {'Jardin'},
},
logging =
{
level = domoticz.LOG_DEBUG,
marker = 'Volets'
},
execute = function( dz, item, devices )
Cuisine = dz.devices('Volet cuisine') -- racourci des devices
Salon = dz.devices('Volet salon')
if item.isDevice and item.state == 'Off' and dz.time.matchesRule('at nighttime') then -- ferme les volets si le jardin pass en off
Cuisine.switchOff().silent()
Salon.switchOff().silent()
elseif dz.time.matchesRule('25 minutes after sunset') and dz.devices('Jardin').state == 'Off' then --coucher du soleil protection lumière on attend le off pour fermer les volets
Cuisine.switchOff().silent()
Salon.switchOff().silent()
elseif dz.time.matchesRule('at 7:30 on mon,tue,thu,fri') then -- lever du soleil
Cuisine.switchOn().silent()
Salon.switchOn().silent()
elseif dz.time.matchesRule('at at 8:30 on wed,sat,sun') then -- lever du soleil
Cuisine.switchOn().silent()
Salon.switchOn().silent()
end
end
}
Re: Problème state switch
Posted: Sunday 30 June 2019 18:01
by waaren
Hydci wrote: Sunday 30 June 2019 17:47
Code: Select all
elseif dz.time.matchesRule('25 minutes after sunset') and dz.devices('Jardin').state == 'Off' and dz.devices('Volet cuisine').state == 'Off' then
I don't see this line in the script but should work
Code: Select all
elseif dz.time.matchesRule('at at 8:30 on wed,sat,sun') then -- lever du soleil
You entered the keyword at twice.
Re: Problème state switch
Posted: Sunday 30 June 2019 18:06
by Hydci
I paste my script that works because when I add that and dz.devices ('Kitchen pane'). state == 'On' the script works more
That's how I write it when I make the condition
Code: Select all
return {
on =
{
timer = { '25 minutes after sunset','at 7:30 on mon,tue,thu,fri','at 8:30 on wed,sat,sun'},
devices = {'Jardin'},
},
logging =
{
level = domoticz.LOG_DEBUG,
marker = 'Volets'
},
execute = function( dz, item, devices )
Cuisine = dz.devices('Volet cuisine') -- racourci des devices
Salon = dz.devices('Volet salon')
if item.isDevice and item.state == 'Off' and dz.time.matchesRule('at nighttime') then -- ferme les volets si le jardin pass en off
Cuisine.switchOff().silent()
Salon.switchOff().silent()
elseif dz.time.matchesRule('25 minutes after sunset') and dz.devices('Jardin').state == 'Off' and dz.devices('Volet cuisine').state == 'On' then --coucher du soleil protection lumière on attend le off pour fermer les volets
Cuisine.switchOff().silent()
Salon.switchOff().silent()
elseif dz.time.matchesRule('at 7:30 on mon,tue,thu,fri') then -- lever du soleil
Cuisine.switchOn().silent()
Salon.switchOn().silent()
elseif dz.time.matchesRule('at 8:30 on wed,sat,sun') then -- lever du soleil
Cuisine.switchOn().silent()
Salon.switchOn().silent()
end
end
}
Re: Problème state switch
Posted: Sunday 30 June 2019 18:30
by waaren
Hydci wrote: Sunday 30 June 2019 18:06
I paste my script that works because when I add that and dz.devices ('Kitchen pane'). state == 'On' the script works more
That's how I write it when I make the condition
what do you see in the log when you run this ?
Code: Select all
return {
on =
{
timer = { '25 minutes after sunset','at 7:30 on mon,tue,thu,fri','at 8:30 on wed,sat,sun'},
devices = {'Jardin'},
},
logging =
{
level = domoticz.LOG_DEBUG,
marker = 'Volets'
},
execute = function( dz, item)
Cuisine = dz.devices('Volet cuisine') -- racourci des devices
Salon = dz.devices('Volet salon')
dz.log("Cuisine.state: " .. Cuisine.state,dz.LOG_DEBUG)
dz.log("Salon.state: " .. Salon.state,dz.LOG_DEBUG)
if item.isDevice and item.state == 'Off' and dz.time.matchesRule('at nighttime') then -- ferme les volets si le jardin pass en off
Cuisine.switchOff().silent()
Salon.switchOff().silent()
elseif dz.time.matchesRule('25 minutes after sunset') and dz.devices('Jardin').state == 'Off' and Cuisine.state == 'On' then --coucher du soleil protection lumière on attend le off pour fermer les volets
Cuisine.switchOff().silent()
Salon.switchOff().silent()
elseif dz.time.matchesRule('at 7:30 on mon,tue,thu,fri') then -- lever du soleil
Cuisine.switchOn().silent()
Salon.switchOn().silent()
elseif dz.time.matchesRule('at 8:30 on wed,sat,sun') then -- lever du soleil
Cuisine.switchOn().silent()
Salon.switchOn().silent()
end
end
}
Re: Problème state switch
Posted: Sunday 30 June 2019 18:37
by Hydci
Just
Code: Select all
2019-06-30 18:18:00.492 Status: dzVents: Info: Volets: ------ Start internal script: Volet:, trigger: at 18:18
2019-06-30 18:18:00.509 Status: dzVents: Debug: Volets: Processing device-adapter for Jardin: Switch device adapter
2019-06-30 18:18:00.510 Status: dzVents: Debug: Volets: Processing device-adapter for Volet cuisine: Switch device adapter
2019-06-30 18:18:00.510 Status: dzVents: Info: Volets: ------ Finished Volet
And no condition and dz.devices('Volet cuisine').state == 'On'
Code: Select all
2019-06-30 18:37:00.200 Status: dzVents: Info: Volets: ------ Start internal script: Volet:, trigger: at 18:37
2019-06-30 18:37:00.218 Status: dzVents: Debug: Volets: Processing device-adapter for Volet cuisine: Switch device adapter
2019-06-30 18:37:00.219 Status: dzVents: Debug: Volets: Processing device-adapter for Volet salon: Switch device adapter
2019-06-30 18:37:00.220 Status: dzVents: Debug: Volets: Processing device-adapter for Jardin: Switch device adapter
2019-06-30 18:37:00.220 Status: dzVents: Debug: Volets: Constructed timed-command: Off
2019-06-30 18:37:00.220 Status: dzVents: Debug: Volets: Constructed timed-command: Off NOTRIGGER
2019-06-30 18:37:00.220 Status: dzVents: Debug: Volets: Constructed timed-command: Off
2019-06-30 18:37:00.220 Status: dzVents: Debug: Volets: Constructed timed-command: Off NOTRIGGER
2019-06-30 18:37:00.220 Status: dzVents: Info: Volets: ------ Finished Volet
with your script
Code: Select all
2019-06-30 18:46:00.265 Status: dzVents: Info: Volets: ------ Start internal script: Volet:, trigger: at 18:46
2019-06-30 18:46:00.282 Status: dzVents: Debug: Volets: Processing device-adapter for Volet cuisine: Switch device adapter
2019-06-30 18:46:00.283 Status: dzVents: Debug: Volets: Processing device-adapter for Volet salon: Switch device adapter
2019-06-30 18:46:00.283 Status: dzVents: Debug: Volets: Cuisine.state: Open
2019-06-30 18:46:00.283 Status: dzVents: Debug: Volets: Salon.state: Open
2019-06-30 18:46:00.284 Status: dzVents: Debug: Volets: Processing device-adapter for Jardin: Switch device adapter
2019-06-30 18:46:00.284 Status: dzVents: Info: Volets: ------ Finished Volet
Re: Problème state switch [Solved]
Posted: Sunday 30 June 2019 18:51
by waaren
Hydci wrote: Sunday 30 June 2019 18:37
with your script
2019-06-30 18:46:00.283 Status: dzVents: Debug: Volets: Cuisine.state: Open
2019-06-30 18:46:00.283 Status: dzVents: Debug: Volets: Salon.state: Open
Is this not why it's not working ?
You check for 'On' and 'Off' but states are 'Open' and 'Closed'
Re: Problème state switch
Posted: Sunday 30 June 2019 18:52
by Hydci
thanks to the log I understood when domoticz checked the state of the shutter it takes not on but open while in the logs it is on or off
I rely on the logs that I saw on the device

Re: Problème state switch
Posted: Sunday 30 June 2019 18:55
by Hydci
Thank's for help