Jump to content

Welcome to Smart Home Forum by FIBARO

Dear Guest,

 

as you can notice parts of Smart Home Forum by FIBARO is not available for you. You have to register in order to view all content and post in our community. Don't worry! Registration is a simple free process that requires minimal information for you to sign up. Become a part of of Smart Home Forum by FIBARO by creating an account.

 

As a member you can:

  •     Start new topics and reply to others
  •     Follow topics and users to get email updates
  •     Get your own profile page and make new friends
  •     Send personal messages
  •     ... and learn a lot about our system!

 

Regards,

Smart Home Forum by FIBARO Team


  • 0

How to create a scene that a roller shutter opens at sunrise, but not before 6:00 o´clock in the morning


Question

Posted

Hi,

 

I am absolutely new to Fibaro Home Center etc.

 

Currently I just own HC 3 and 1 Roller shutter module to get used to the fibaro world.

 

Now I am trying to create a scene, that opens the roller shutter at sunrise (which ist quite easy using the block scenes). But I want to edit this scene, that even if the sunrise time is earlier than 6 o´clock in the morning the roller shutter opens at 6 o´clock in the morning.

 

Is there any easy way to create such a scene for me as an absolutely newbie?

 

Thanks in advance for your help!

1 answer to this question

Recommended Posts

  • 0
Posted

Hi I have the following scene in lua which does something very similar, I use a function called suncalc to get sunrise times etc...

What I am doing is setting a start time to open the curtains and then to check if it is light enough using an aeotec sensor to give me a light reading.

 

 

local fmt = string.format

function str2sec(str) local h,m,s=str:match("^(%d%d):(%d%d):?(%d*)") return 3600*h+60*m+(s~="" and s or 0) end

function sec2str(sec) return fmt("%02d:%02d%s",math.floor(sec/3600),math.floor((sec % 3600)/60),sec % 60 > 0 and fmt(":%02d",sec%60) or "") end

--Set locals

local currentDate = os.date("*t")

local currentTime = os.date("%H:%M")

local shabbos = fibaro.getGlobalVariable("shabbos")

local sunRise = fibaro.getGlobalVariable("Sunrise")

local sunSet = fibaro.getGlobalVariable("Sunset")

local curtainDuskVariable = fibaro.getGlobalVariable("curtaindusk")

local sunRisePlusOneHour = sec2str(str2sec(sunRise)+60*60)

local sunSetMinusOneHour = sec2str(str2sec(sunSet)-60*60)

--List Curtains Devices

local LivingLeft = 178

local LivingCentre = 183

local LivingRight = 197

local Dining = 259

local Study = 269

local MasterBedroom = 264

--Set earliest OPEN time for groups

local GroupDownstairsFrontEarlyOpenTime = "07:00"

local GroupDownstairsBackEarlyOpenTime = "07:00"

local GroupBedroomEarlyOpenTime = "07:30"

local GroupBedroomEarlyOpenTimeShabbos = "08:00"

if shabbos == "true" then

    GroupBedroomEarlyOpenTime = GroupBedroomEarlyOpenTimeShabbos

end

--Get Current Light Level For Outside

local LumLevelDeviceId = 280

local LuxLevel = tonumber(fibaro.getValue(LumLevelDeviceId, "value"))

local LuxLevelVariable = tonumber(fibaro.getGlobalVariable("lightLevel"))

local LuxLevelCurtainOpen = 100

local LuxLevelCurtainClose = 20

local checkLuxLevel = "false"

--Open and Close State for curtains

local curtainOpenState = 99

local curtainCloseState = 0

--Set devices in to groups

local GroupDownstairsFront = {Dining,Study}

local GroupDownstairsBack = {LivingLeft,LivingCentre,LivingRight}

local GroupBedroom = {MasterBedroom}

local curtainStateVariable

local GroupDownstairsFrontDirection = "close"

local GroupDownstairsBackDirection = "close"

local GroupBedroomDirection = "close"

--Curtain Control Starts Here

--Group DownstairsFront Curtain Control

if currentTime >= GroupDownstairsFrontEarlyOpenTime and currentTime < sunRisePlusOneHour then

    if LuxLevelVariable >= LuxLevelCurtainOpen then

        GroupDownstairsFrontDirection = "open"

    end

elseif currentTime >= GroupDownstairsFrontEarlyOpenTime and currentTime >= sunRisePlusOneHour and currentTime < sunSetMinusOneHour then

    GroupDownstairsFrontDirection = "open"

elseif currentTime >= sunSetMinusOneHour and currentTime < curtainDuskVariable then

    if LuxLevelVariable <= LuxLevelCurtainClose then

        GroupDownstairsFrontDirection = "close"

    else

        GroupDownstairsFrontDirection = "open"

    end

elseif currentTime >= curtainDuskVariable then

    GroupDownstairsFrontDirection = "close"

end

if GroupDownstairsFrontDirection == "open" then

    curtainStateVariable = curtainCloseState

else

    curtainStateVariable = curtainOpenState

end

for k,i in ipairs(GroupDownstairsFront)  do

    if fibaro.getValue(i, "value") == curtainStateVariable then

        fibaro.call(i,GroupDownstairsFrontDirection)

    end

end

--Group DownstairsBack Curtain Control

if currentTime >= GroupDownstairsBackEarlyOpenTime and currentTime < sunRisePlusOneHour then

    if LuxLevelVariable >= LuxLevelCurtainOpen then

        GroupDownstairsBackDirection = "open"

    end

elseif currentTime >= GroupDownstairsBackEarlyOpenTime and currentTime >= sunRisePlusOneHour and currentTime < sunSetMinusOneHour then

    GroupDownstairsBackDirection = "open"

elseif currentTime >= sunSetMinusOneHour and currentTime < curtainDuskVariable then

    if LuxLevelVariable <= LuxLevelCurtainClose then

        GroupDownstairsBackDirection = "close"

    else

        GroupDownstairsBackDirection = "open"

    end

elseif currentTime >= curtainDuskVariable then

    GroupDownstairsBackDirection = "close"

end

if GroupDownstairsBackDirection == "open" then

    curtainStateVariable = curtainCloseState

else

    curtainStateVariable = curtainOpenState

end

for k,i in ipairs(GroupDownstairsBack)  do

    if fibaro.getValue(i, "value") == curtainStateVariable then

        fibaro.call(i,GroupDownstairsBackDirection)

    end

end

--Group Bedroom Curtain Control

if currentTime >= GroupBedroomEarlyOpenTime and currentTime < sunRisePlusOneHour then

    if LuxLevelVariable >= LuxLevelCurtainOpen then

        GroupBedroomDirection = "open"

    end

elseif currentTime >= GroupBedroomEarlyOpenTime and currentTime >= sunRisePlusOneHour and currentTime < sunSetMinusOneHour then

    GroupBedroomDirection = "open"

elseif currentTime >= sunSetMinusOneHour and currentTime < curtainDuskVariable then

    if LuxLevelVariable <= LuxLevelCurtainClose then

        GroupBedroomDirection = "close"

    else

        GroupBedroomDirection = "open"

    end

elseif currentTime >= curtainDuskVariable then

    GroupBedroomDirection = "close"

end

if GroupBedroomDirection == "open" then

    curtainStateVariable = curtainCloseState

else

    curtainStateVariable = curtainOpenState

end

for k,i in ipairs(GroupBedroom)  do

    if fibaro.getValue(i, "value") == curtainStateVariable then

        fibaro.call(i,GroupBedroomDirection)

    end

end

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...