Author Topic: Conditional scenes with Elk and Lua  (Read 722 times)

Offline Quixote

  • Sr. Member
  • ****
  • Posts: 323
  • Karma: +11/-34
Conditional scenes with Elk and Lua
« on: November 01, 2016, 10:39:39 pm »
Hi,
I'm trying to figure out how to use Lua to trigger/prevent scenes. I'd appreciate if someone can give me a hand with this.

I set up this script attached to a scene, but it seems to trigger no matter what. Any ideas?

local allow = true
local status = luup.variable_get("urn:schemas-micasaverde-com:device:ElkAlarmPartition:1", "DetailedArmMode", 6)
return ((status == "Armed") == allow)

What I'm trying to do is prevent the scene from happening if I am at home, even if the system is armed StayInstant, but work if I'm out and the system is armed away. Thanks!
My "Karma" has been modified by 2 or 3 douchebags that didn't like that I criticized the plugin that they worship. I'm not actually a bad person.

Offline zoot1612

  • Moderator
  • Hero Member
  • *****
  • Posts: 600
  • Karma: +20/-2
Re: Conditional scenes with Elk and Lua
« Reply #1 on: November 03, 2016, 08:32:37 pm »
Try

local status = luup.variable_get("urn:micasaverde-com:serviceId:AlarmPartition2","ArmMode",6)

Offline Quixote

  • Sr. Member
  • ****
  • Posts: 323
  • Karma: +11/-34
Re: Conditional scenes with Elk and Lua
« Reply #2 on: November 03, 2016, 11:42:45 pm »
Success! It seems that it works. (knock on wood...   I only tested once)

local allow = true
local status = luup.variable_get("urn:micasaverde-com:serviceId:AlarmPartition2","ArmMode",6)
return ((status == "Armed") == allow)

did not work for my application because apparently StayInstant is considered Armed, just as when it's armed in away mode. However, using this worked:

local allow = true
local status = luup.variable_get("urn:micasaverde-com:serviceId:AlarmPartition2","DetailedArmMode",6)
return ((status == "Armed") == allow)


Thanks so much for your help!
My "Karma" has been modified by 2 or 3 douchebags that didn't like that I criticized the plugin that they worship. I'm not actually a bad person.