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
Question
rjansen 0
Hi,
I have a goog working Lua script for Dag (Day) and nacht (night) variable.
The settings are for the variable Day and night are exactly start at sunrise or sunset.
But now i want to program 30 minuts. So the variable Dag (Day) for sunrise must start 30 minutes later and for Sunset 30 minuts earlyer.
Dous anyone now where and how i must programm a 30 minutes code?
This is my Lua code:
--[[
%% autostart
%% properties
%% globals
--]]
--Deze senne maakt van variable Nacht.
--Wat heeft de scene gestart?
local sourceTrigger = fibaro:getSourceTrigger();
--------------------------------------------------
if (sourceTrigger["type"] == "autostart") then
--Controleer elke minuut het tijdstip
while true do
--Defineer de tijden
local currentDate = os.date("*t");
local TimeNow = (string.format("%02d", currentDate.hour) .. ":" .. string.format("%02d", currentDate.min))
local sunrise=fibaro:getValue(1, "sunriseHour")
local sunset=fibaro:getValue(1, "sunsetHour")
local startSource = fibaro:getSourceTrigger();
fibaro:debug("Het is nu: "..TimeNow)
fibaro:debug("Zonsopkomst: "..sunrise)
fibaro:debug("Zonsondergang: "..sunset)
--Bij zonsopkomst
if (TimeNow == sunrise) then
fibaro:setGlobal("Dag_Nacht","Dag")
end
--bij zonsondergang
if (TimeNow == sunset) then
fibaro:setGlobal("Dag_Nacht","Nacht")
end
--wacht 1 minuten
fibaro:sleep(60*1000);
end
else
--dit gebeurt als je handmatig scene start
---------------------------------------------------
local Dag_Nacht=fibaro:getGlobalValue("Dag_Nacht")
if Dag_Nacht == "Nacht" then
fibaro:setGlobal("Dag_Nacht","Dag")
else
fibaro:setGlobal("Dag_Nacht","Nacht")
end
end
Link to comment
Share on other sites
9 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.