Where am I going wrong???

Hi

I am trying to code a scene based on the examples given and it’s not working.

The intent is to run the scene every few minutes using an interval timer, set to 1 minute for testing and then probably 5 minutes when in service

This timer will compare the current temperature on a sensor with the upper trip level and, if it’s over it, turn an appliance switch off.

There will be a corresponding “opposite scene” to turn the heat back on when the temperature drops below the dead band.

The code is based on the example given here

http://wiki.micasaverde.com/index.php/Luup_Scenes_Events#Walk-through_.231_--_At_12_noon.2C_turn_off_the_interior_lights_if_the_temperature_is_over_80_degrees

virtually what I want, I need a timer that fires more often, no problem, I need to set it to my temperature sensor, again no problem.

The problem is that it does not work, the event fires whether or not the temperature is above or below the threshold set.

The code follows, about as simple as it can get, is there a problem with this specimen code or am I missing something??

local lul_temp = luup.variable_get(“urn:schemas-micasaverde-com:device:TemperatureSensor:1”, “CurrentTemperature”, 45)
if (tonumber(lul_temp) >7) then return false
end

I tried it with 2 different temperature sensors, the other version is

local lul_temp = luup.variable_get(“urn:schemas-micasaverde-com:device:TemperatureSensor:1”, “CurrentTemperature”, 52)
if (tonumber(lul_temp) <22.5) then return false
end

Can someone enlighten me where I am going wrong please??

Many thanks

Nick

The service ID ([tt]“urn:schemas-micasaverde-com:device:TemperatureSensor:1”[/tt]) is wrong.

Please consult
[tt]http://wiki.micasaverde.com/index.php/Luup_Scenes_Events#Walk-through_.231_--_At_12_noon.2C_turn_off_the_interior_lights_if_the_temperature_is_over_80_degrees[/tt] and
[tt]http://wiki.micasaverde.com/index.php/Luup_UPNP_Files#TemperatureSensor1[/tt].

I copied and pasted the content of the “device_type” field on the Advanced tabs for the temperature sensors that I had in the system here. Is that not correct?? Should it be the text from the example rather than the actual content of my own system???

Nick

Looks like that’s the case, use the “device type” from the advanced tab for my own device and it does not work, use the example given and it works.

Thanks for the guide, just wish I understood the syntax etc better.

Nick

Hi,

may i ask anybody to explain the logic of the “service ID” identification? i am following nickrwym line of thought and of course it doesn’t work with the device type under the advanced tab.

So: how to know the right “service IP” to be applied to a given device?

Thanks anyway.

Some devices have multiple functions (for example, those 3-in-1 things from Aeon that are temperature and motion and light sensors). Other devices can do the same thing multiple times (for example, a lot of HVAC devices have two setpoints, one for heating, one for cooling). The architects of UPnP realized this and so they designed UPnP so that every device has to give each of its functions (“services”) a unique name (“id”) to distinguish it.

There are two ways you can find the service id: one is to go to the device’s Advanced tab and hover the mouse pointer over a variable name. You get hover text that is the service id. The other is to find the device’s XML filename (also from the Advanced tab) and go view that file in the Luup Files page. That lists all the device’s service ids.