Author Topic: reading Current Temperature from Virtual Outdoor Temp device  (Read 178 times)

Offline jchin

  • Sr. Newbie
  • *
  • Posts: 38
  • Karma: +0/-0
reading Current Temperature from Virtual Outdoor Temp device
« on: April 14, 2018, 04:37:10 pm »
How can I read the current outdoor temperature from the Virtual Outdoor Temperature (VOTD) device?

Using the luup code:
local OutdoorTemp = luup.variable_get("urn:upnp-org:serviceId:TemperatureSensor1", "CurrentTemperature", 23) -- where 23 is the device ID
does not seem to work.

Offline jchin

  • Sr. Newbie
  • *
  • Posts: 38
  • Karma: +0/-0
Re: reading Current Temperature from Virtual Outdoor Temp device
« Reply #1 on: April 14, 2018, 06:26:11 pm »
Finally I got a WORKING SOLUTION !!!

I use this LUUP code in a scene that is triggered by a motion detector.
Used to control the heat in my basement.
Basically, if it is warm outside, do not turn up the heat in the basement and someone goes in.


Code: [Select]
local THERMOSTAT = 16 -- deviceID for Thermostat
local TEMP = 72 -- temperature to set
local HEATOFF = 65 -- temperature to set when outside is warm
local VOTD = 23 -- deviceID of Virtual Outdoor Temp
local TEMPwarm = 55 -- temperature outside considered warm

local OutdoorTemp = tonumber((luup.variable_get("urn:upnp-org:serviceId:TemperatureSensor1", "CurrentTemperature", VOTD)))
-- note the number of parentheses

if (OutdoorTemp < TEMPwarm) then
luup.call_action("urn:upnp-org:serviceId:TemperatureSetpoint1_Heat", "SetCurrentSetpoint", {NewCurrentSetpoint = TEMP}, THERMOSTAT)
else
luup.call_action("urn:upnp-org:serviceId:TemperatureSetpoint1_Heat", "SetCurrentSetpoint", {NewCurrentSetpoint = HEATOFF}, THERMOSTAT)
end

Offline jswim788

  • Hero Member
  • *****
  • Posts: 678
  • Karma: +43/-2
Re: reading Current Temperature from Virtual Outdoor Temp device
« Reply #2 on: April 14, 2018, 11:14:50 pm »
local OutdoorTemp = luup.variable_get("urn:upnp-org:serviceId:TemperatureSensor1", "CurrentTemperature", 23) -- where 23 is the device ID
does not seem to work.

I'll guess that you tried to use OutdoorTemp as a number?  Remember that luup.variable_get always returns a string (actually 2 return values, but typically you only want the first), and you need to convert the string to a number as in your second post if you want to compare it to other numbers.