DaveL17 wrote:
I've got a question related to the above code.
I'm attempting to test the state of a Phidgets device (from berkinet's plugin). In particular, I'm able to successfully do the following to turn on a digital output (or off using turnOff):
indigo.device.turnOn("do_device_name") # where device is a Phidgets digital output
What I'm not able to do is test the state of a digital input by using code similar to this (I get an error saying the attribute onState is not defined):
- Code: Select all
dev = indigo.devices["di_device_name"] # where device is a Phidgets digital input
if dev.onState == on: # not sure about the boolean value I'm testing against, but it never got there before throwing an error on the undefined attribute
do something
OK, so the device doesn't support onState. Reading through this thread, I figured I'd just see what the device's properties are and I then subsequently put them in the log file using the quoted code and got this:
2017-04-19 19:33:29.578 Script address : P-SBC3 - Veg Garden |di 1
batteryLevel : None
buttonGroupCount : 0
configured : True
description :
deviceTypeId : phDiIfKit
displayStateId : onOffState
displayStateImageSel : PowerOff
displayStateValRaw : False
displayStateValUi : off
enabled : True
energyAccumBaseTime : None
energyAccumTimeDelta : None
energyAccumTotal : None
energyCurLevel : None
errorState :
folderId : 0
globalProps : MetaProps : (dict)
com.perceptiveautomation.indigoplugin.Phidgets : (dict)
address : P-SBC3 - Veg Garden |di 1 (string)
buttonFlagDi : false (bool)
phDiIfKitId : 580018001 (string)
phDiIfKitInput : 1 (string)
phDiIfKitModel : phDiIfKit (string)
phDiIfKitSerial : 491507 (string)
id : 1567846833
lastChanged : 2017-04-19 14:22:51
lastSuccessfulComm : 2017-04-19 14:22:51
model : InterfaceKit Digital Input
name : 3-Way Valve Position - Veg Garden to Street Drain
ownerProps : com.perceptiveautomation.indigoplugin.Phidgets : (dict)
address : P-SBC3 - Veg Garden |di 1 (string)
buttonFlagDi : false (bool)
phDiIfKitId : 580018001 (string)
phDiIfKitInput : 1 (string)
phDiIfKitModel : phDiIfKit (string)
phDiIfKitSerial : 491507 (string)
pluginId : com.perceptiveautomation.indigoplugin.Phidgets
pluginProps : emptyDict : (dict)
protocol : Plugin
remoteDisplay : True
states : States : (dict)
lastUpdate : 2017-04-19 14:22:51 (string)
onOffState : off (on/off bool)
subModel :
supportsAllLightsOnOff : False
supportsAllOff : False
supportsStatusRequest : False
version : None
Now, based on my limited knowledge, I'd expect that I could use onOffState (instead of onState), but it also ends up being undefined. Am I doing something wrong or is this a limitation of the plugin? If the latter, how else can I test the state of the device within a Python script? Clearly Indigo can see the state of the on/off attribute since I can use the attribute to fire a trigger, so I would think I can test against it too. Any tips are greatly appreciated.
Thanks,
Blaine