We have moved at community.getvera.com

Author Topic: Lua conditional scene  (Read 532 times)

Offline michelhamelin

  • Full Member
  • ***
  • Posts: 162
  • Karma: +3/-1
Lua conditional scene
« on: November 29, 2017, 09:01:01 pm »
Which variable to use to check outside temp,
CurrentTemperature or Temperature?

Offline akbooer

  • Moderator
  • Master Member
  • *****
  • Posts: 6387
  • Karma: +291/-70
  • "Less is more"
Re: Lua conditional scene
« Reply #1 on: November 30, 2017, 03:09:01 am »
The UPnP defined temperature service is the CurrentTempersture variable in the ...:Temperature1 service. 
3x Vera Lite-UI5/Edge-UI7, 25x Fibaro, 23x TKB, 9x MiniMote, 2x NorthQ Power, 2x Netatmo, 1x Foscam FI9831P, 9x Philips Hue,
Razberry, MySensors Arduino, HomeWave, AltUI, AltHue, DataYours, Grafana, openLuup, ZWay, ZeroBrane Studio.

Offline michelhamelin

  • Full Member
  • ***
  • Posts: 162
  • Karma: +3/-1
Re: Lua conditional scene
« Reply #2 on: December 02, 2017, 11:56:29 pm »
At 10:00 in the morning my curtains close only if :

local dID = 72           -- Device ID of Netatmo outside temp
local allow = true       -- true runs scene if higher than, false don t runs it
local status = luup.variable_get("urn:upnp-org:serviceId:TemperatureSensor1","CurrentTemperature",dID)
return ((status >= "22") == allow)

i Have put this in : Also, execute the following Luup code

but sometimes they close even if it is lower than 22

The UPnP defined temperature service is the CurrentTempersture variable in the ...:Temperature1 service.

Offline akbooer

  • Moderator
  • Master Member
  • *****
  • Posts: 6387
  • Karma: +291/-70
  • "Less is more"
Re: Lua conditional scene
« Reply #3 on: December 03, 2017, 02:32:53 am »
Code: [Select]
status >= "22"

...is a string comparison, rather than a numeric one.

What you need is...

Code: [Select]
tonumber(status) >= 22
3x Vera Lite-UI5/Edge-UI7, 25x Fibaro, 23x TKB, 9x MiniMote, 2x NorthQ Power, 2x Netatmo, 1x Foscam FI9831P, 9x Philips Hue,
Razberry, MySensors Arduino, HomeWave, AltUI, AltHue, DataYours, Grafana, openLuup, ZWay, ZeroBrane Studio.

Offline michelhamelin

  • Full Member
  • ***
  • Posts: 162
  • Karma: +3/-1
Re: Lua conditional scene
« Reply #4 on: December 03, 2017, 01:22:07 pm »
you re right my mistake
Thank you

Code: [Select]
status >= "22"

...is a string comparison, rather than a numeric one.

What you need is...

Code: [Select]
tonumber(status) >= 22