Hi folks,
As I regularly forget to bring the garbage (plastic, paper, waste) out the day it is collected, I thought it might be good to get a reminder that day (about once a month, but irregular pick ups based on a print calendar).
I want to use the door sensor at the main door as trigger and have a list of dates which are checked. Then the variable for Sonos_Music is set and played.
But this would be triggering every time I open the front door, so I want to limit it to one time between say 7:00 and 9:00.
How can I do this?
I've converted a Blockscene into LUA and deleted the time out of the scheduler line, cause this would only work if I open the door at the exact time.
What I also don't understand is the second almost identical code generated automatically when switching to LUA, cause this never had the time in it, just the date. It confused the one that is too simple that he needs a reminder for the garbage.
Heres my code so far - Any hint/help is very much appreciated.
--[[
%% autostart
%% properties
407 value
%% weather
%% events
%% globals
--]]
local sourceTrigger = fibaro:getSourceTrigger();
function tempFunc()
local currentDate = os.date("*t");
local startSource = fibaro:getSourceTrigger();
if (
( tonumber(fibaro:getValue(407, "value")) > 0 )
and
( string.format("%04d-%02d-%02d", currentDate.year, currentDate.month, currentDate.day) == "2018-08-02" )
or
( string.format("%04d-%02d-%02d", currentDate.year, currentDate.month, currentDate.day) == "2018-09-27" )
)
then
fibaro:setGlobal("SONOS_MUSIC", "readyshare/Media/audio/Plastikmuell.m4a");
fibaro:call(377, "pressButton", "2");
end
setTimeout(tempFunc, 60*1000)
end
if (sourceTrigger["type"] == "autostart") then
tempFunc()
else
local currentDate = os.date("*t");
local startSource = fibaro:getSourceTrigger();
if (
( tonumber(fibaro:getValue(407, "value")) > 0 )
and
( string.format("%04d-%02d-%02d", currentDate.year, currentDate.month, currentDate.day) == "2018-08-02" )
or
( string.format("%04d-%02d-%02d", currentDate.year, currentDate.month, currentDate.day) == "2018-09-27" )
or
startSource["type"] == "other"
)
then
fibaro:setGlobal("SONOS_MUSIC", "readyshare/Media/audio/Plastikmuell.m4a");
fibaro:call(377, "pressButton", "2");
end
end