Up and Down blinds with conditions.

Easy to use, 100% Lua-based event scripting framework.
Post Reply
magicduck
Posts: 12
Joined: Sunday 11 February 2018 14:25
Target OS: -
Domoticz version:
Location: Longwy, France
Contact:

Up and Down blinds with conditions.

Post by magicduck » Tuesday 23 October 2018 14:56

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

User avatar
emme
Posts: 963
Joined: Monday 27 June 2016 11:02
Target OS: Raspberry Pi
Domoticz version: latest
Location: Milano, Italy
Contact:

Re: Up and Down blinds with conditions.

Post by emme » Tuesday 23 October 2018 15:50

try this:

first of all we will use dzVents which is much easy for me :P
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
}
The most dangerous phrase in any language is:
"We always done this way"

BOverdevest
Posts: 5
Joined: Wednesday 28 March 2018 20:56
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Up and Down blinds with conditions.

Post by BOverdevest » Tuesday 23 October 2018 20:02

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
}

Jubbes
Posts: 8
Joined: Wednesday 24 October 2018 14:35
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Up and Down blinds with conditions.

Post by Jubbes » Wednesday 24 October 2018 14:49

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

Jubbes
Posts: 8
Joined: Wednesday 24 October 2018 14:35
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Up and Down blinds with conditions.

Post by Jubbes » Wednesday 24 October 2018 15:56

without the times from the morning in the script, only from the evening.
thanks

User avatar
waaren
Posts: 1377
Joined: Tuesday 03 January 2017 15:18
Target OS: Raspberry Pi
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Up and Down blinds with conditions.

Post by waaren » Wednesday 24 October 2018 20:58

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
}
Raspberry (debian stretch via berryboot on Synology DS916+) , Domoticz (almost) latest Beta, , dzVents 2.6, RFLink, RFXtrx433e, P1, Youless, Harmony, Hue, Yeelight, Xiaomi, HomeWizard, Zwave, Amazon echo

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests