Ok so a touch of a newbie to micasa system so I am a bit frustrated on a script. I want to pull from weather underground app the ambient outside temp, and if its below a certain threshold allow the scene to run. Basic if its below X run all this automation to run to change the thermostat… here is what I have so far
local LOW_LEVEL < 59.9 – the temp level threshold for night
local DEVICE_NO = 29 – the temp sensor device number
local LS_SID = “urn:schemas-micasaverde-com:device:TemperatureSensor:1” – 29
local currentLevel = luup.variable_get (SES_SID, " CurrentTemperature", 29) or 0
currentLevel = tonumber(currentLevel)
if currentLevel <= LOW_LEVEL then
return true
else
return false
end
Ready to scream – don’t understand why this is not working… any help would be appreciated!
I would be interested to see what the code fix is to this, but I am going to ask you something that many others have asked about scenes like this - have you considered using the PLEG plugin to automate this scene?
This looks like something you could rather easily accomplish with that plug in. There is a lot of help around it too, so if you get stuck, the community is pretty willing to help out.
Problem #1 is the “<” there. It should be “=”. I know you are thinking that you want to do a “less-than” comparison, but this is not the place to do that. The “=” operator isn’t about comparison; it’s about assignment to a variable. Which you use correctly later on, I might add.
local LS_SID = "urn:schemas-micasaverde-com:device:TemperatureSensor:1" -- 29
local currentLevel = luup.variable_get (SES_SID, " CurrentTemperature", 29) or 0
Search recent posts on the forum for “perennial newbie trap” for just the most recent case, and what to do to get it right.
Plus then, you use a different variable name in the following luup.variable_get(). Probably a copy-and-paste error.
Edit: finally, do I see a space between your opening quote and CurrentTemperature? If that’s in your code, get rid of it.
I will add a little more of a hint … but you still need to find it and fix it…
It has to do with mixing device and service IDs.
Also you have a variable DEVICE_NO that is never used.
In general it hurts my eyes to see so many errors in a few lines of code.
Computers always do what they are told … but as you have just learned … they rarely do what you want them to do.
Richard thanks for the heads up – the funny part is this code is a copy out of wiki with a few tweeks, and this code works for a lumination event, that was the most difficult issue I was having is that its working for one scene and not another, and this code is almost a dead on copy of a wiki verde help code that was touted. I am going to tinker around with the PLEG… Futzle thanks for the hint… I am more inclinde to find the problem and learn from the mistake vs someone just giving the answer. I appreciate all the hints and points in the general direction!
Best Home Automation shopping experience. Shop at Ezlo!