Luup call to Wunderground Plugin Humidity Sensor

I cannot believe I’m struggling with basic syntax, but it is happening
The following code works but I want to test for humidity level below 70, thusly I am using the “less than” operator. Replacing the “==” to “<” makes the below script error.

Any suggestions?

Script:

– get the current exterior humidity level
local humidityvalue = luup.variable_get(“urn:upnp-org:serviceId:HumiditySensor1” , “CurrentLevel” , 93)
if (tonumber(humidityvalue) == 70 ) then
return false
end

– this one works
– if I change the “==” to “<” is will not work.

You need to use the html code for the less than character.

  • Garrett

Or use the following

if (70 > tonumber(humidityvalue)) then 

The problem with < is that this is trapped by the XML wrapper for this code.

I really appreciate the responses, however I tried this with no results:

– get the current exterior humidity level
local humidityvalue = luup.variable_get(“urn:upnp-org:serviceId:HumiditySensor1” , “CurrentLevel” , 93)
if (70 > tonumber(humidityvalue)) then
return false
end

I’m not clear on how to add the HTML code to the script to get it to work. As my “newbie” status suggests… I’m not there yet on putting HTML in these scripts.

I’d bang a “return true” at the very end for the sake of completeness.

But I reckon you might have an argument wrong in your call to luup.variable_get() that is returning nil instead of your expected humidity. Comparing nil with == will be false, but comparing with an ordered comparison may be triggering a Lua error.

Edit: also you haven’t said where you are putting this code in the Vera web UI.

You need to use the right ServiceId !!!

local humidityvalue = luup.variable_get(“urn:micasaverde-com:serviceId:HumiditySensor1” , “CurrentLevel” , 93)

@Futzle
I totally agree … but I always found it a very strange the MCV considers falling off the end of LUA without a return as meaning TRUE … I guess they figure that’s the 90% case.

Richard, you solved my problem… forrest for the trees kind of thing

Thanks so much kind sir