enumerate indigo device properties in Python script...

Posted on
Sun Mar 31, 2019 12:48 am
russg offline
Posts: 46
Joined: Oct 02, 2014

enumerate indigo device properties in Python script...

Hi All,
I have installed the myQ plug-in for my garage doors, and I'm trying to log information when it changes state. That made me realize I didn't know (and couldn't figure out) how to enumerate a devices properties.

what I'm trying to get to is essentially this:

pvMode = indigo.devices[586475679] # myQ Door Opener device
indigo.server.log("Garage Door One changed state to: " + pvMode.<???????>)

where the <??????> is the state of the device (door).

Any suggestions would be greatly appreciated!
-russg

Posted on
Sun Mar 31, 2019 6:28 am
DaveL17 offline
User avatar
Posts: 6751
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: enumerate indigo device properties in Python script...

Here you go.
Code: Select all
dev = indigo.devices[1188813242]

status_str = dev.states['doorStatus']
status_bool = dev.states['doorStatus.Open']

indigo.server.log(status_str)
indigo.server.log(str(status_bool))


Code: Select all
Mar 31, 2019 at 7:27:20 AM
   Script                          Closed
   Script                          False

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Sun Mar 31, 2019 7:09 pm
russg offline
Posts: 46
Joined: Oct 02, 2014

Re: enumerate indigo device properties in Python script...

Thank you (again)!

That works, So, do you know the properties because of the device type, or is there a way to iterate and expose the properties in python?
thanks,
-russg

Posted on
Sun Mar 31, 2019 7:41 pm
DaveL17 offline
User avatar
Posts: 6751
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: enumerate indigo device properties in Python script...

Sure! When you use this code:

Code: Select all
dev = indigo.devices[1188813242]


You're actually getting a copy of the entire Indigo device object. You can get a lot of information about the object simply by sending it to print.

Code: Select all
indigo.server.log(str(dev))


gives you all this:

Code: Select all
   Script                          address : 14167012
batteryLevel : None
buttonConfiguredCount : 0
buttonGroupCount : 0
configured : True
description : Opener Device auto-created by MyQ plugin from gateway information
deviceTypeId : myqOpener
displayStateId : onOffState
displayStateImageSel : Locked
displayStateValRaw : True
displayStateValUi : locked
enabled : True
energyAccumBaseTime : None
energyAccumTimeDelta : None
energyAccumTotal : None
energyCurLevel : None
errorState :
folderId : 1921185512
globalProps : MetaProps : (dict)
     com.flyingdiver.indigoplugin.myq : (dict)
          IsLockSubType : true (bool)
          address : 14167012 (integer)
          devVersCount : 1 (integer)
id : 1188813242
lastChanged : 2019-03-31 20:28:18
lastSuccessfulComm : 2019-03-31 20:28:18
ledStates : []
model : MyQ Door Opener
name : Garage Door Opener (SNIP)
onState : True
ownerProps : com.flyingdiver.indigoplugin.myq : (dict)
     IsLockSubType : true (bool)
     address : 14167012 (integer)
     devVersCount : 1 (integer)
pluginId : com.flyingdiver.indigoplugin.myq
pluginProps : emptyDict : (dict)
protocol : Plugin
remoteDisplay : True
states : States : (dict)
     doorStatus : Closed (string)
     doorStatus.Closed : true (bool)
     doorStatus.Closing : false (bool)
     doorStatus.Disconnected : false (bool)
     doorStatus.Open : false (bool)
     doorStatus.Opening : false (bool)
     doorStatus.Stopped : false (bool)
     doorStatus.Unknown : false (bool)
     onOffState : on (on/off bool)
     onOffState.ui : locked (string)
subModel :
supportsAllLightsOnOff : False
supportsAllOff : False
supportsStatusRequest : True
version : None

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Mon Apr 01, 2019 10:12 pm
russg offline
Posts: 46
Joined: Oct 02, 2014

Re: enumerate indigo device properties in Python script...

Ah! That's exactly it. Once again, my humble thanks!
-russg

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 3 guests