Page 1 of 1
Up and Down blinds with conditions.
Posted: Tuesday 23 October 2018 14:56
by magicduck
Hello,
I am mostly stuck on the way to make a nice way to handle specific blinds on my home.
I have several bedroom and I want :
1- when sunrise > 7:00 am -> open blind at sunrise, otherwise open them at 7:00am
2- when sunset < 08:30 pm -> close bindd at sunset, otherwise closed them at 08:30pm.
Any nice way to handle that ?
Kind regards
Re: Up and Down blinds with conditions.
Posted: Tuesday 23 October 2018 15:50
by emme
try this:
first of all we will use dzVents which is much easy for me

LUA and dzVents have the time object that contain sunset and sunrise timers, we will use them
convert all timers to minutes since midnight
compare datas:
I did not test it yet... but it should works
Code: Select all
return {
on = {
devices = { 'TEST' },
timer = {
'at sunset',
'at 7:00',
'at sunrise',
'at 20:30',
}
execute = function(dz)
local minsSR = dz.time.sunriseInMinutes
local minsSS = dz.time.sunsetInMinutes
local minsMM = 420 -- 7:00 ==> ( 7*60)+00
local minsAN = 1230 -- 20:30 ==> (20*60)+30
if dz.trigger == 'at sunrise' and (minSR >= minsMM) then -- Script trigger at Sunset and Sunset after 7.00
-- Command to open blinds
elseif dz.trigger == 'at 7:00' and (minSR <= minsMM) then -- Script trigger at 7:00 and Sunset before 7.00
-- Command to open blinds
elseif dz.trigger == 'at sunset' and (minSS <= minsAN) then -- Script trigger at Sunset and Sunset after 7.00
-- Command to close blinds
elseif dz.trigger == 'at 20:30' and (minSS <= minsAN) then -- Script trigger at 7:00 and Sunset before 7.00
-- Command to close blinds
end
end
}
Re: Up and Down blinds with conditions.
Posted: Tuesday 23 October 2018 20:02
by BOverdevest
Many paths lead to Rome... I like to put important steering values only once and on top.
The logic will work (I tested it on a lightbulb). However it doesn't work on my Curtain. It just won't open or close on the command
Hopefully, it will work for you...
Basically the code is called 4 times a day (like the example above), but the logic then is simpler as only action is taken if the actual time is between the cut off times and a time the sun is definitely above or below the horizon.
Should you get the actual blinds command for open/close to work, please let me know. I'll keep trying to find the right command as well.
Code: Select all
local DeviceName = "Curtain Kitchen"
local TimeOpen = "7:00" -- Curtain Open
local TimeClose = "20:30" -- Curtain Close
return {
on = { timer = {'at ' .. TimeOpen, 'at ' .. TimeClose, "at sunrise", "at sunset" }},
execute = function(domoticz)
if (domoticz.time.matchesRule('between ' .. TimeClose ..' and 23:59')) then
domoticz.log(domoticz.devices(DeviceName).state)
domoticz.devices(DeviceName).setState('Closed')
elseif (domoticz.time.matchesRule('between ' .. TimeOpen ..' and 12:00')) then
domoticz.devices(DeviceName).setState('Open')
end
end
}
Re: Up and Down blinds with conditions.
Posted: Wednesday 24 October 2018 14:49
by Jubbes
Hello, sorry for my bad english.....
I have 2 Dummy switches for the two scenes rollos_groundfloor_down and rollos_upstairs_down. I will select that i can manual drive the rollos and automatically. Whe one of the switches is on the rollos of the scene should go down 15 minutes before sunset.... If the switches are out, i must drive the rollos manual. Is this possible to nake in the script?
Thanks
Re: Up and Down blinds with conditions.
Posted: Wednesday 24 October 2018 15:56
by Jubbes
without the times from the morning in the script, only from the evening.
thanks
Re: Up and Down blinds with conditions.
Posted: Wednesday 24 October 2018 20:58
by waaren
Jubbes wrote: ↑Wednesday 24 October 2018 14:49
I have 2 Dummy switches for the two scenes rollos_groundfloor_down and rollos_upstairs_down. When one of the switches is on the rollos of the scene should go down 15 minutes before sunset.... If the switches are out, i must drive the rollos manual.
Not sure that I completely understand what you want but the script below triggers at 15 minutes before sunset and if the dummy switch for upstairs is On, the scene for the upstairs rollos is switched On and if the dummy switch for downstairs is On, the scene for the downstairs rolllos is switched On.
Hope this helps to get you started.
Code: Select all
-- rollos
return {
on = { timer = { "15 minutes before sunset" }},
logging = { level = domoticz.LOG_DEBUG, -- INFO, DEBUG or ERROR
marker = "rollos" },
execute = function(dz, item)
downSwitch = dz.devices("name of dummy that control groundfloor scene") -- Change to real name of switch
upSwitch = dz.devices("name of dummy that control upstairs scene") -- Change to real name of switch
if downSwitch.state == "On" then
dz.scenes("rollos_groundfloor_down").switchOn()
end
if upSwitch.state == "On" then
dz.scenes("rollos_upstairs_down").switchOn()
end
end
}