Item.state problem
Posted: Sunday 27 October 2019 18:57
Hello, I come to you for help I have a script that works perfectly but I have a problem with item.state I have two devices that can turn on to turn off
The devices are 'Jardin' and 'vacances scolaires'
I tried to do this but it does not work item.state('jardin') == 'Off'
Here is my code if you want to take a look
The devices are 'Jardin' and 'vacances scolaires'
I tried to do this but it does not work item.state('jardin') == 'Off'
Here is my code if you want to take a look
Code: Select all
return {
on =
{
timer = { '25 minutes after sunset','15 minutes after sunset','at 7:45 on mon,tue,thu,fri','at 9:30 on wed,sat,sun','at 9:30 on mon,tue,thu,fri'},
devices = {'Jardin','Bouton volet','vacances scolaires'},
},
execute = function( dz, item)
Cuisine = dz.devices('Volet cuisine') -- racourci des devices
Salon = dz.devices('Volet salon')
if dz.time.matchesRule('15 minutes after sunset') then
os.execute("sudo /home/pi/./alexa.sh -d Cuisine -e speak:'Fermeture des volets dans dix minutes'")
end
if item.state == "1 Click" and dz.devices('Volet cuisine').state == 'Closed' and dz.devices('Volet salon').state == 'Closed' then
Cuisine.switchOn().silent()
Salon.switchOn().silent()
elseif item.state == "1 Click" and dz.devices('Volet cuisine').state == 'Open' and dz.devices('Volet salon').state == 'Open' then
Cuisine.switchOff().silent()
Salon.switchOff().silent()
end
if item.state == "2 Clicks" and dz.devices('Volet cuisine').state == 'Closed' then
Cuisine.switchOn().silent()
elseif item.state == "2 Clicks" and dz.devices('Volet cuisine').state == 'Open' then
Cuisine.switchOff().silent()
end
if item.state == "3 Clicks" and dz.devices('Volet salon').state == 'Closed' then
Salon.switchOn().silent()
elseif item.state == "3 Clicks" and dz.devices('Volet salon').state == 'Open' then
Salon.switchOff().silent()
end
if item.isDevice and item.state == 'Off' and dz.time.matchesRule('at nighttime') then -- ferme les volets si le jardin pass en off
if dz.devices('Volet cuisine').state == 'Open' then
Cuisine.switchOff().silent()
end
if dz.devices('Volet salon').state == 'Open' then
Salon.switchOff().silent()
end
end
if 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
if dz.devices('Volet cuisine').state == 'Open' then
Cuisine.switchOff().silent()
end
if dz.devices('Volet salon').state == 'Open' then
Salon.switchOff().silent()
end
end
if dz.time.matchesRule('at 7:45 on mon,tue,thu,fri') and dz.devices('vacances scolaires').state == 'Off' then -- lever du soleil
if dz.devices('Volet cuisine').state == 'Closed' then
Cuisine.switchOn().silent()
end
if dz.devices('Volet salon').state == 'Closed' then
Salon.switchOn().silent()
end
end
if dz.time.matchesRule('at 9:30 on mon,tue,thu,fri') and dz.devices('vacances scolaires').state == 'On' then -- lever du soleil
if dz.devices('Volet cuisine').state == 'Closed' then
Cuisine.switchOn().silent()
end
if dz.devices('Volet salon').state == 'Closed' then
Salon.switchOn().silent()
end
end
if dz.time.matchesRule('at 9:30 on wed,sat,sun') then -- lever du soleil
if dz.devices('Volet cuisine').state == 'Closed' then
Cuisine.switchOn().silent()
end
if dz.devices('Volet salon').state == 'Closed' then
Salon.switchOn().silent()
end
end
end
}