Author Topic: Compare two temperature value  (Read 151 times)

Offline michelhamelin

  • Full Member
  • ***
  • Posts: 113
  • Karma: +2/-0
Compare two temperature value
« on: August 06, 2017, 10:39:59 pm »
I have a scene with the following conditions: if my Heatpump ModeStatus is "HeatOn" and "CurrentTemperature" is greater then 2 degrees celcius or more than  the "CurrentSetpoint"  allow the scene, but even smaller than 2 degrees the scene run...

What is wrong with that code ?

Code: [Select]
local dID = 178           -- Device ID of your zxt-120 plugin
local status = luup.variable_get("urn:upnp-org:serviceId:HVAC_UserOperatingMode1","ModeStatus",dID)
local BdID = 156           -- Device ID of your temperature sensor Salon
local sCurrent1 = tonumber((luup.variable_get("urn:upnp-org:serviceId:TemperatureSetpoint1","CurrentSetpoint",BdID)))
local tLow =  sCurrent1        -- Lowest temperature of range
local tCurrent = tonumber((luup.variable_get("urn:upnp-org:serviceId:TemperatureSensor1","CurrentTemperature",BdID)))
local allow = true     
return ((status == "HeatOn") and (tCurrent >= (tLow +(2))) == allow)

Offline RichardTSchaefer

  • Master Member
  • *******
  • Posts: 9572
  • Karma: +729/-136
    • RTS Services Plugins
Re: Compare two temperature value
« Reply #1 on: August 07, 2017, 10:00:38 am »
Try putting some luup.log statements in your code to see if your are getting what you expect.

Offline michelhamelin

  • Full Member
  • ***
  • Posts: 113
  • Karma: +2/-0
Re: Compare two temperature value
« Reply #2 on: August 07, 2017, 10:02:25 pm »
Now it works, my mistake just switch dID and BdID   :)

Quote
local dID = 178           -- Device ID of your zxt-120 plugin
local allow = true       -- true runs scene if heaton, false don t runs it
local status = luup.variable_get("urn:upnp-org:serviceId:HVAC_UserOperatingMode1","ModeStatus",dID)
local BdID = 156           -- Device ID of your temperature sensor Salon
local sCurrent1 = tonumber((luup.variable_get("urn:upnp-org:serviceId:TemperatureSetpoint1","CurrentSetpoint",dID)))
local tLow =  sCurrent1       -- Lowest temperature of range
local tCurrent = tonumber((luup.variable_get("urn:upnp-org:serviceId:TemperatureSensor1","CurrentTemperature",BdID)))
local Ballow = true       -- true runs scene when in range, false blocks it
return ((status == "HeatOn") and (tCurrent >= tLow + 2) == Ballow)