I am looking to use the weather plug in status ‘‘sunny’’ to swich off the light of an aquarium.
The light is activated in the morning and when the sky is clear and sunny the light can be switched off
If the status of the weather plug in changes back the light need to be switched on
In the evening by an event (time) it will be swiched off again
I need some guidance / help for this luup option
option should be only working from 0900 hrs until sunset
update;
I am working on the following luup, on which i would like your advise
local DEVICE_ID_WEATHER_PLUGIN = 20
=====
local condition = luup.variable_get(“urn:upnp-micasaverde-com:serviceId:Weather1”, “condition”,
DEVICE_ID_WEATHER_PLUGIN )
if (condition = “sunny”)
then
luup.call_action(“urn:upnp-org:serviceId:SwitchPower1”, “SetTarget”, {newTargetValue = “0”}, 17 — aquarium off
I can’t help you on the Weather Plugin code, but this is the code I use for my Kids remote to only allow them to power on the TV outlet between certain hours, if that helps.
[code]local startTime = “08:00”
local endTime = “20:30”
local hour = tonumber( startTime:sub( startTime:find(“%d+”) ) )
local minute = tonumber(startTime:sub(-2))
if hour and minute then
startTime = hour * 100 + minute
else
luup.log(“ERROR: invalid start time”)
return false
end
[quote=“huib, post:4, topic:171768”]i have read in the weather plug in repley than the option also could be used
if (condition == “Sunny”)
or
if (condition.find(“Sunny”) ~=nil
which one is better?[/quote]
Either is reasonable. The latter would also trigger if Google decided to start returning “[tt]Not Sunny[/tt]”. It doesn’t seem likely as response but since their service is largely undocumented, anything’s possible 8)
Also note that it should be using a colon character like [tt]condition:find(“Sunny”)[/tt] or [tt]string.find(condition, “Sunny”)[/tt]. Not sure if the other one is really working as you’d expect it.
the first if querry is if the condition is to swich off the light
the second querry is to swich on the light if beteen 0900 and 1800 if the weather is not good
but i got an error message
please advise
===========================
local DEVICE_ID_WEATHER_PLUGIN = 20 – weather plug in
local t = os.date(‘*t’)
local current_time = t.hour * 3600 + t.min * 60 + t.sec – time now
local begin_day_time = 9 * 3600 – 09:00
local end_day_time = 18 * 3600 – 18:00
local condition = luup.variable_get(“urn:upnp-micasaverde-com:serviceId:Weather1”, “Condition”, DEVICE_ID_WEATHER_PLUGIN)
if ( condition == "Sunny" ) or ( condition == "Clear" ) or ( condition == "Mostly Sunny" )
then
luup.call_action("urn:upnp-org:serviceId:SwitchPower1", "SetTarget", {newTargetValue = "0"}, 17) --- aquarium off
else
return false
if ( condition == "Sunny" ) or ( condition == "Clear" ) or ( condition == "Mostly Sunny" )
then
return false
else
if ( current_time <= end_day_time ) and ( current_time >= begin_day_time )
then
luup.call_action("urn:upnp-org:serviceId:SwitchPower1", "SetTarget", {newTargetValue = "1"}, 17) --- aquarium on if after 0900 or before 1800
return false
the code as i have it now looks ok but drives me crazy (every time error message)
so your kind advise is requested
================================
local DEVICE_ID_WEATHER_PLUGIN = 20 – weather plug in
local t = os.date(‘*t’)
local current_time = t.hour * 3600 + t.min * 60 + t.sec – time now
local begin_day_time = 9 * 3600 – 09:00
local end_day_time = 18 * 3600 – 18:00
local condition = luup.variable_get(“urn:upnp-micasaverde-com:serviceId:Weather1”, “Condition”, 20)
if (current_time <= begin_day_time) -- time before 0900
then
return false – do nothing
end – stop
else
if (end_day_time <= current_time) -- time after 1800
then
return false – do nothing
end – stop
else
if ( condition == "Sunny" ) or ( condition == "Clear" ) or ( condition == "Mostly Sunny" )
From the Lua documentation (Lua 5.1 Reference Manual) if expthenblock {elseifexpthenblock} [elseblock] end
If these don’t match correctly, then you’ll get syntax errors overall. As a first stab, try indenting your code somewhat to match the structure (and using the [ code ] … [ / code ] tag wrappers in postings) as it may become more obvious to you where the problem is.
I found it and it seems to work now
and also thanks for the link the lua site
==============
local DEVICE_ID_WEATHER_PLUGIN = 20 – weather plug in
local t = os.date(‘*t’)
local current_time = t.hour * 3600 + t.min * 60 + t.sec – time now
local begin_day_time = 9 * 3600 – 09:00
local end_day_time = 18 * 3600 – 18:00
local condition = luup.variable_get(“urn:upnp-micasaverde-com:serviceId:Weather1”, “Condition”, 20)
if (current_time <= begin_day_time) -- time before 0900
then
end – stop
if (end_day_time <= current_time) -- time after 1800
then
end – stop
if ( condition == "Sunny" ) or ( condition == "Clear" ) or ( condition == "Mostly Sunny" )
then
luup.call_action("urn:upnp-org:serviceId:SwitchPower1", "SetTarget", {newTargetValue = "0"}, 17) --- aquarium off
else
luup.call_action(“urn:upnp-org:serviceId:SwitchPower1”, “SetTarget”, {newTargetValue = “1”}, 17) — aquarium on
I’d like to turn on the sprinklers not just based on the rainfall in the past 24 hours, but also take the predicted precipitation into account. Can the Google Weather plugin access the predictions? (Google’s API does offer them IIRC).
The forward looking data isn’t currently exposed. Given the recent apparent shutdown of the feed (I hope this is an accident) I may have to switch feed providers so it may get added anyhow.
Best Home Automation shopping experience. Shop at Ezlo!