Getting the property of device

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

Posted on
Mon Apr 09, 2012 3:37 pm
DomoPat offline
User avatar
Posts: 210
Joined: Jul 17, 2010
Location: Toulouse, France

Getting the property of device

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 ?

Posted on
Mon Apr 09, 2012 4:05 pm
matt (support) offline
Site Admin
User avatar
Posts: 21429
Joined: Jan 27, 2003
Location: Texas

Re: Getting the property of device

Try this:

Code: Select all
ledevice=indigo.devices["cabanon"]
indigo.server.log(str(ledevice))


And copy/paste the Event Log results.

Image

Posted on
Tue Apr 10, 2012 12:32 am
DomoPat offline
User avatar
Posts: 210
Joined: Jul 17, 2010
Location: Toulouse, France

Re: Getting the property of device

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

Posted on
Tue Apr 10, 2012 11:12 am
matt (support) offline
Site Admin
User avatar
Posts: 21429
Joined: Jan 27, 2003
Location: Texas

Re: Getting the property of device

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

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 3 guests

cron