[ANSWERED]: Script zone status DSCalarm

Posted on
Sat Jun 14, 2014 11:17 pm
jsrivet offline
User avatar
Posts: 13
Joined: May 23, 2010
Location: Joliette, Québec, Canada

[ANSWERED]: Script zone status DSCalarm

I want to know how to know the status of the alarm zone plugin DSCalarm. I want to write a script ex: When this Zone opens, my lights on with python.
I tried with this script but it does not work. surely this is a cause of custom states and it is a value open closet.

lamp = indigo.devices[1133344481]
if hasattr(lamp, 'onState'):
isOn = lamp.onState
if not lamp.onState:
indigo.device.turnOn(34387386)

Posted on
Sun Jun 15, 2014 12:45 am
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: Script zone status DSCalarm

try this:

Code: Select all
lamp = indigo.devices[1133344481]
if hasattr(lamp, 'onState'):
    if  not lamp.onState: indigo.device.turnOn(34387386)

or

lamp = indigo.devices[1133344481]
if hasattr(lamp, 'onState'):
   isOn = lamp.onState
   if not isOn:  indigo.device.turnOn(34387386)

Posted on
Sun Jun 15, 2014 8:10 am
matt (support) offline
Site Admin
User avatar
Posts: 21411
Joined: Jan 27, 2003
Location: Texas

Re: Script zone status DSCalarm

Since the DSC plugin uses a custom state, you need to access its values via the states[] dict of the device. In the older version of the plugin I happened to have here the state key name used is "state", but that might have changed in more recent versions of the plugin. You can see the state name by expanding the device details area in the main window.

Here is code that should work assuming the state name is still "state":

Code: Select all
zonedev = indigo.devices[1133344481]
lampdev = indigo.devices[34387386]
if zonedev.states["state"] in ["open", "tripped"]:     # other possible state is "closed" I think
   indigo.device.turnOn(lampdev)

Image

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 2 guests