Alarm Panel Custom State

Posted on
Tue Dec 22, 2015 6:29 pm
jltnol offline
Posts: 994
Joined: Oct 15, 2013

Alarm Panel Custom State

So with generous help from others, this script evaluated a custom state of the main alarm panel , and did what I needed it to do:
Code: Select all
alarmPanel = 1145882715
alarmPanelState = indigo.devices[alarmPanel].states['panelReady']
day = indigo.variables[1864332157]

if alarmPanelState == "0":
   indigo.dimmer.setLedState(418713206, index = 2, value = False)
elif alarmPanelState == "1" and day.value == "true":
   indigo.actionGroup.execute(327874994), indigo.actionGroup.execute(1040855971)
elif alarmPanelState == "1" and day.value == "false":
   indigo.actionGroup.execute(327874994), indigo.actionGroup.execute(53352835)


Now, I'm trying to work on a script that evaluates the custom state Zone 1 of the alarm system, which is the front door, and is defined as a "device" in Indigo and have started with the script below. The "onOffState" part comes from the same place as "panelReady" does in the script above, and appears in the Custom States for the device in question. It compiles correctly, but when I execute it, nothing happens, and nothing shows up in the log to give me a hint.
In place of the "0", I've tried "1", "True", "true", "False", "false", "off", "Off", "Clear", "clear"(from the device menu), but nothing works.

Code: Select all
door = 1273767074
doorstate = indigo.devices[door].states['onOffState']

if doorstate == "0":
   indigo.actionGroup.execute(237143343)


I'll have the script do much more, but this is my stumbling block.... can't get this custom zone to evaluate correctly...

As usual, any assistance would be greatly appreciated.

Posted on
Wed Dec 23, 2015 1:59 am
howartp offline
Posts: 4559
Joined: Jan 09, 2014
Location: West Yorkshire, UK

Re: Alarm Panel Custom State

Have you mis-copied this, or does the last line start "digo" instead of "indigo"?

Other than that it looks correct to me from memory.


Sent from my iPhone using Tapatalk

Posted on
Wed Dec 23, 2015 10:10 am
jay (support) offline
Site Admin
User avatar
Posts: 18221
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Alarm Panel Custom State

Assuming the device is one of the subclasses of built-in devices that automatically supports onOffState, then try this instead:

Code: Select all
door = 1273767074
doorstate = indigo.devices[door].states['onOffState']

# doorstate should contain a boolean, so just test if it's false
if not doorstate:
   indigo.actionGroup.execute(237143343)


You can see what types states are by opening a scripting shell and using print to see the type of the state:

Code: Select all
Python 2.6.9 (unknown, Oct 23 2015, 18:05:10)
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)]
Connected to Indigo Server v6.1.4, api v1.19 (localuds:1176)
>>> sensor = indigo.devices[681280488] # "024 - Motion Sensor"
>>> print sensor
address : 24
allowOnStateChange : False
allowSensorValueChange : False
batteryLevel : 100

[SNIP]

onState : False
pluginId : com.perceptiveautomation.indigoplugin.zwave
pluginProps : emptyDict : (dict)
protocol : ZWave
remoteDisplay : False
sensorValue : None
states : States : (dict)
     batteryLevel : 100 (integer)
     batteryLevel.ui : 100% (string)
     onOffState : off (on/off bool)  <----------------- it's a bool(ean)
subModel : Motion Sensor
supportsAllLightsOnOff : False
supportsAllOff : False
supportsStatusRequest : True
version : 0
>>>

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Wed Dec 23, 2015 2:58 pm
jltnol offline
Posts: 994
Joined: Oct 15, 2013

Re: Alarm Panel Custom State

As usual, thanks so much for your help. Didn't quit grasp the "if not doorstate", but found "if doorstate" did the opposite, and for this project, I need both. The rest I can easily assemble from other scrips I've hammered out.

Will dive into the shell script for sure and take a look to see what I can find.

Thanks again, and Happy Holidays.

Posted on
Wed Dec 23, 2015 3:22 pm
howartp offline
Posts: 4559
Joined: Jan 09, 2014
Location: West Yorkshire, UK

Re: Alarm Panel Custom State

jltnol wrote:
Didn't quit grasp the "if not doorstate", but found "if doorstate" did the opposite

Code: Select all
doorstate = indigo.devices[door].states['onOffState']

The onOffState is a Boolean true/false value. In Indigo (and other places) true/on/1 are the same thing, and false/off/0 are the same thing. (Note there's no quote marks around them)
So your doors' on/off state (doorstate) is either true or false.

The "if" command requires something which equates to either true or false - if it's true then it carries out the commands below, if it isn't then it doesn't (unless there's an "else" below it).

"if doorstate" is therefore a short form of "if doorstate = true"

The "not" keyword inverts the logic.

"if not doorstate" is therefore a short form of "if doorstate does not = true" or in other words "if doorstate = false"

Hope that helps.

Peter

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 10 guests