After a few hours of reading in this forum I have made two scenes running the scripts below…
- Scene is triggered to run every 30minutes and the script checks weather/wind to see if the awning should be rolled out.
[code]local function checkTime()
local pStart = “08:00” – Start of time period
local pEnd = “20:00” – End of time period
local allow = true – Runs if time schedule is true, else blocks it
local hS, mS = string.match(pStart,“(%d+)%:(%d+)”)
local mStart = (hS * 60) + mS
local hE, mE = string.match(pEnd,“(%d+)%:(%d+)”)
local mEnd = (hE * 60) + mE
local tNow = os.date(“*t”)
local mNow = (tNow.hour * 60) + tNow.min
if mEnd >= mStart then
return (((mNow >= mStart) and (mNow <= mEnd)) == allow)
else
return (((mNow >= mStart) or (mNow <= mEnd)) == allow)
end
end
local function checkDay()
local dID = 31 – Device ID of your DayTime plugin
local allow = true – true runs scene during day
local status = luup.variable_get(“urn:rts-services-com:serviceId:DayTime”,“Status”,dID)
return ((status == “1”) == allow)
end
local function checkWheater()
local rID = 23 – Device ID of your Roller Shutter device
local dID = 24 – Device ID of your Weather app
local wHigh = 20 – Highest wind level, value/3.6 to get m/s Vindklass 2 made for 10.5
local gHigh = 20 – Highest gust level
local allow = true – true runs scene when in range, false blocks it
local level = luup.variable_get(“urn:upnp-org:serviceId:Dimming1”,“LoadLevelTarget”,rID)
local gust = tonumber((luup.variable_get(“urn:upnp-micasaverde-com:serviceId:Weather1”,“WindGust”,dID)))
local wind = tonumber((luup.variable_get(“urn:upnp-micasaverde-com:serviceId:Weather1”,“WindSpeed”,dID)))
if (level == “100”) – Checks if the marquis is already rolled out
and ((wind <= wHigh) and (gust <= gHigh)) – High wind or gusts blocks scene from running
then
local cond = tostring((luup.variable_get(“urn:upnp-micasaverde-com:serviceId:Weather1”,“ConditionGroup”,dID)))
return (((cond == “sunny”) or (cond == “partlysunny”) or (cond == “partlycloudy”) or (cond == “mostlysunny”) or (cond == “clear”)) == allow)
else
return false
end
end
return (checkTime() and checkDay() and checkWheater()) – runs scene when in time interval, daytime and the weather is right[/code]
- Scene is triggered to run every 5minutes and the script checks weather/wind to see if the awning should be rolled in.
[code]local function checkWind()
local dID = 24 – Device ID of your Weather app
local wHigh = 25 – Highest wind level, value/3.6 to get m/s Vindklass 2 made for 10.5
local gHigh = 30 – Highest gust level
local allow = true – true runs scene when in range, false blocks it
local gust = tonumber((luup.variable_get(“urn:upnp-micasaverde-com:serviceId:Weather1”,“WindGust”,dID)))
local wind = tonumber((luup.variable_get(“urn:upnp-micasaverde-com:serviceId:Weather1”,“WindSpeed”,dID)))
return (((wind >= wHigh) or (gust >= gHigh)) == allow)
end
local function checkWheater()
local dID = 24 – Device ID of your Weather app
local allow = true – true runs scene when in range, false blocks it
local cond = tostring((luup.variable_get(“urn:upnp-micasaverde-com:serviceId:Weather1”,“ConditionGroup”,dID)))
return (((cond == “rain”) or (cond == “snow”) or (cond == “tstorms”) or (cond == “unknown”) or (cond == “cloudy”) or (cond == “flurries”) or (cond == “fog”) or (cond == “mostlycloudy”) or (cond == “sleet”)) == allow)
end
local function checkTime()
local dID = 31 – Device ID of your DayTime plugin
local allow = true – true runs scene during night
local status = luup.variable_get(“urn:rts-services-com:serviceId:DayTime”,“Status”,dID)
return ((status == “0”) == allow)
end
local rID = 23 – Device ID of your Roller Shutter device
local level = luup.variable_get(“urn:upnp-org:serviceId:Dimming1”,“LoadLevelTarget”,rID)
if (level == “100”) – Checks if the marquis is already rolled in
then
return false
else
return (checkWind() or checkWheater() or checkTime()) – runs scene if high wind/gusts, the weather is bad or if it’s night.
end[/code]