Love some help with a Challenge...

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.

Thanks in advance for any help…

Yup, it’s confusing to begin with…

…a really good tutorial source is the MiCasaVerde Wiki site.

Try, for example,
[url=http://wiki.micasaverde.com/index.php/Scripts_for_scenes]http://wiki.micasaverde.com/index.php/Scripts_for_scenes[/url]

which should be close to what you need.
Some of the “How To” pages are quite helpful too.

Others will probably have better suggestions, but I hope this gets you going.

Best of luck, and let us all know how you get on.

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?

Thanks again for your help.

[quote=“hbcameron, post:4, topic:174101”]local outside = luup.variable_get(“urn:upnp-org:serviceId:TemperatureSensor:1”, “CurrentTemperature”, 23)

if (tonumber(outside) <= “20”) then[/quote]

I see two niggling little errors which will be enough to make it fail:

Your service Id has one extra stray colon. You want:

local outside = luup.variable_get("urn:upnp-org:serviceId:TemperatureSensor1", "CurrentTemperature", 23)

“20” is a string. You want 20, which is a number:

if (tonumber(outside) <= 20) then

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.

I know you wanted to do this with LUA. But besides Scenes and Triggers, you can also do this with the PLEG Beta: See: [url=http://forum.micasaverde.com/index.php/topic,13421.0.html]http://forum.micasaverde.com/index.php/topic,13421.0.html[/url]

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 ::slight_smile:

Thanks again

Hi,

I see your using the Google Plugin for Temperature but can you use an “Aeon Labs Z-Wave Multisensor” or “Z-Wave 4 in 1 Multi-Sensor” instead?

(are they compatible wit vera?)

Cheers.

I am now trying to go a step further and combining two scenes into one. Building on what I have above, I am trying to make the following code work:

[code]local CTemp = luup.variable_get(“urn:upnp-org:serviceId:TemperatureSensor1”,“CurrentTemperature”, 23)

if (tonumber(CTemp)> 10) then
luup.call_action(“urn:upnp-org:serviceId:PowerSwitch1”,“SetTarget”,{ newTargetValue=“1” },71)

else
luup.call_action(“urn:upnp-org:serviceId:PowerSwitch1”,“SetTarget”,{ newTargetValue=“0” },71)

end [/code]

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.

Since you like to do it the hard way … I will only give you a hint.

urn:upnp-org:serviceId:PowerSwitch1 is wrong!

Thanks… I do Appreciate your help!

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

A second “hint”. There are a number of ways to find the same details, here is just one.

http://Vera_IP:3480/data_request?id=lu_invoke
This will provide a html drill down of services and actions available for devices.