I am new to VeraLite and I would love to be able to have an Attic Fan switch that would check the current temperature using the World Weather Application and if the temperature is over 80 degrees turn the fan on and below 80 turn it off. Any help would be appreciated. I would really like to know how it can be done with LUA programming and an explanation of where the code is placed within VeraLite. Does anyone know where I can find COMPLETE examples of how to place LUA code within Vera? Most people just leave tidbits expecting everyone is an advanced user.
You’ve presumably already found this wiki page. Those code fragments are complete, though none of them do exactly what you want. If you’re able to learn from examples different to your immediate problem, you can adapt them to your needs. The code goes into the text box in the LUUP tab while you are editing a scene.
You could achieve what you want without any Lua programming, by the way. The temperature device from the Weather plugin has an event “Temperature goes over X”, which you can tie to a scene that starts your fan. Likewise, another scene would turn it off.
So can anyone tell me why this is not working. I created a Scene that turns the “fan” “ON” and is scheduled it to run every minute. The current temperature outside is 32.2 degrees and I have added the following in the LUUP code:
local outside = luup.variable_get(“urn:upnp-org:serviceId:TemperatureSensor:1”, “CurrentTemperature”, 23)
if (tonumber(outside) <= “20”) then
return true
end
return false
I saved it… when it triggers a minute later the “fan” turns on even thought 32.2 degrees is not <= 20 degrees… What am I missing?
hb - I feel your pain. The wiki has information but it is not ideally written for those trying to self-teach. I found useful information in the luup lua extensions page but there are limited examples and I’m learning to crawl. So what I do is after I find an extension that I think will work, I need to hunt through various plugins to find an example to see the syntax and how to properly use it in a function. Granted my ignorance is the problem but with some more information I could save a significant amount of time which would accelerate lua/luup learning and plugin development.
Does anyone know if there are any luup/lua programs that error check what you write? I have also made the mistake of a misplaced " and it takes hours to solve it.
Create a PLEG Device (Temp Controlled Fan)
Inputs
Triggers WarmOutSide = When Google Plugin Temperatue Goes Above 80
Condition FanOn = WarnOutSide FanOff = Not WarmOutSide
Actions: FanOn
Turn Fan Device On FanOff
Turn Fan Device Off
You still can program the Logic but you do not need to learn/use LUA and learn all about how to get/set device properties using LUA.
Thanks to everyone that took the time to reply. All of your information was very useful and had helped to move me forward… Futzle your ideas worked perfectly, I think I tried both of your suggestions before, sadly not at the same time :
I have created a scene that only uses schedules and LUUP code with no device selection. Can someone help me understand why this does not work? Thanks in advance to all of you that are willing to help New Kids learn.
local Outside = luup.variable_get("urn:upnp-org:serviceId:TemperatureSensor1","CurrentTemperature", 23)
if (tonumber(Outside)>= 10) then
luup.call_action("urn:upnp-org:serviceId:SwitchPower1","SetTarget",{ newTargetValue="1" },71)
else
luup.call_action("urn:upnp-org:serviceId:SwitchPower1","SetTarget",{ newTargetValue="0" },71)
end