Getting the property of device

This is a legacy forum which is locked for new topics. New topics should be started in one of the other forums under Extending Indigo
Forum rules
This is a legacy forum which is locked for new topics. New topics should be started in one of the other forums under Extending Indigo
User avatar
DomoPat
Posts: 213
Joined: Sat Jul 17, 2010 10:35 am
Location: Toulouse, France

Getting the property of device

Post by DomoPat »

In an action group I am trying to access the property of a device created with a plugin, in this case the RFXtrx plugin. The device shows three properties named 'last updated', 'type' and 'status'.

I expected the following would work:

ledevice=indigo.devices["cabanon"]
machin = ledevice.status
indigo.server.log(str(machin))

but it returns an error because the device does not have a 'status' attribute.

Where am I wrong ?
User avatar
matt (support)
Site Admin
Posts: 21542
Joined: Mon Jan 27, 2003 1:17 pm
Location: Texas
Contact:

Re: Getting the property of device

Post by matt (support) »

Try this:

Code: Select all

ledevice=indigo.devices["cabanon"]
indigo.server.log(str(ledevice))
And copy/paste the Event Log results.
Image
User avatar
DomoPat
Posts: 213
Joined: Sat Jul 17, 2010 10:35 am
Location: Toulouse, France

Re: Getting the property of device

Post by DomoPat »

Thank you, nice to see the structure of the device. I can see these properties are in a dictionary:

------
Script address : 4739
buttonGroupCount : 0
description :
deviceTypeId : SecuritySensor
enabled : True
errorState :
folderId : 0
globalProps : MetaProps : (dict)
nl.rjdekok.indigoplugin.RFXRDK : (dict)
address : 4739 (string)
sensorNumber : 4739 (string)
space0 : (string)
id : 11176171
lastChanged : 2012-04-10 00:23:49
model : Security Sensor
name : cabanon
pluginId : nl.rjdekok.indigoplugin.RFXRDK
pluginProps : emptyDict : (dict)
protocol : Plugin
remoteDisplay : True
states : States : (dict)
lastUpdated : Tue Apr 10 00:23:49 2012 (string)
status : 0 (integer)
type : 0 (integer)
supportsAllLightsOnOff : False
supportsAllOff : False
supportsStatusRequest : False
version : 0
------

I will have to practice reading dictionaries... :D
User avatar
matt (support)
Site Admin
Posts: 21542
Joined: Mon Jan 27, 2003 1:17 pm
Location: Texas
Contact:

Re: Getting the property of device

Post by matt (support) »

I think you'll want something like:

Code: Select all

ledevice=indigo.devices["cabanon"]

lastUpdatedStr = ledevice.states["lastUpdated"]
statusInt = ledevice.states["status"]
typeInt = ledevice.states["type"]
Image
Locked

Return to “Extending Indigo with Plugins and Python”