Python - using phidgets device state

Posted on
Sat Aug 14, 2021 4:57 pm
SMUSEBY offline
Posts: 511
Joined: Sep 16, 2009
Location: California

Python - using phidgets device state

I have a phidgets that measures ambient light. I would like to use the value in a python script.
Logging the value of the sensor, the event log produces the following:
Trigger run a script #1
Script dev: address : SBC3 1018 |a 4
batteryLevel : None
buttonGroupCount : 0
configured : True
description :
deviceTypeId : phIfKitSensor
displayStateId : state
displayStateImageSel : None
displayStateValRaw : 2030.0
displayStateValUi : 2030
enabled : True
energyAccumBaseTime : None
energyAccumTimeDelta : None
energyAccumTotal : None
energyCurLevel : None
errorState :
folderId : 1142975935
globalProps : MetaProps : (dict)
com.perceptiveautomation.indigoplugin.Phidgets : (dict)
address : SBC3 1018 |a 4 (string)
buttonFlagSensor : false (bool)
cVal1 : 2 (string)
cVal2 : 40 (string)
decimalPlaces : 0 (string)
phIfKitSensorModel : 1142 (string)
phSensorIfKitAnalogInput : 4 (string)
phSensorIfKitId : 1737950388 (string)
phSensorIfKitSerial : 339669 (string)
phTemp1 : cel (string)
id : 1666063006
lastChanged : 2021-08-14 15:01:07
lastSuccessfulComm : 2021-08-14 15:01:07
model : InterfaceKit Sensor
name : #4 ambientLight
ownerProps : com.perceptiveautomation.indigoplugin.Phidgets : (dict)
address : SBC3 1018 |a 4 (string)
buttonFlagSensor : false (bool)
cVal1 : 2 (string)
cVal2 : 40 (string)
decimalPlaces : 0 (string)
phIfKitSensorModel : 1142 (string)
phSensorIfKitAnalogInput : 4 (string)
phSensorIfKitId : 1737950388 (string)
phSensorIfKitSerial : 339669 (string)
phTemp1 : cel (string)
pluginId : com.perceptiveautomation.indigoplugin.Phidgets
pluginProps : emptyDict : (dict)
protocol : Plugin
remoteDisplay : True
sharedProps : com.indigodomo.indigoserver : (dict)
states : States : (dict)

brightness : 2030 (real)
lastUpdate : 2021-08-14 15:01:07 (string)
state : 2030 (real)

subModel :
subType :
supportsAllLightsOnOff : False
supportsAllOff : False
supportsStatusRequest : False
version : None


The value I'd like to use is either 'brightness' or 'state' - 2030. Both are logged as 'real'. But the test script below ignores the value and proceeds as if true -

Code: Select all
dev = indigo.devices[1666063006] # amb light
indigo.server.log(" dev: {}".format(dev))

if dev > 10000:
   indigo.device.turnOn(1580115691)
if dev > 10000:
   indigo.device.turnOff(1580115691)


even though both conditions are false, the device is turned on and off.

Posted on
Sun Aug 15, 2021 3:30 am
kw123 offline
User avatar
Posts: 8363
Joined: May 12, 2013
Location: Dallas, TX

Python - using phidgets device state

It is
dev.states[“brightness”]
Not just
dev
For device state brightness

The state name might be brightnessLevel


Karl


Sent from my iPhone using Tapatalk

Posted on
Sun Aug 15, 2021 1:46 pm
SMUSEBY offline
Posts: 511
Joined: Sep 16, 2009
Location: California

Re: Python - using phidgets device state

That worked.
Many thanks.
Bob

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 2 guests