How do I pull the states accessible through an Indigo device

Posted on
Fri Oct 27, 2023 5:16 pm
EagleDTW offline
Posts: 69
Joined: Apr 30, 2020

How do I pull the states accessible through an Indigo device

Hi All,

I'm trying to pull "actual_state" from an HA sensor text device...how do I script 1st a python script method to know which states are accessible and then how would I reference this state in my device reference in the script. issues I'm running into is that this is displayed as a date text field in indigo device with some help from a beta release from FlyingDiver, but the state that is actually used by the device is the defualt value of just 0, and referencing the device states comes up with errors, and if I don't include a .state reference I get:
Script Error action group "Update days till Havdalah" script error in file days till havdalah.py:
Script Error strptime() argument 1 must be str, not SensorDevice
Script Error Exception Traceback (most recent call shown last):

days till havdalah.py, line 16, at top level
TypeError: strptime() argument 1 must be str, not SensorDevice

2nd is there a method to list all states available when I try this code I get no response in event log, even with logging enabled through script from this forum section:
dev = indigo.devices[1169704765]
# print(dev.states[actual_state])
print(dev.states)

Thank you,
Daniel

Posted on
Fri Oct 27, 2023 6:03 pm
EagleDTW offline
Posts: 69
Joined: Apr 30, 2020

Re: How do I pull the states accessible through an Indigo de

EagleDTW wrote:
Hi All,

I'm trying to pull "actual_state" from an HA sensor text device...how do I script 1st a python script method to know which states are accessible and then how would I reference this state in my device reference in the script. issues I'm running into is that this is displayed as a date text field in indigo device with some help from a beta release from FlyingDiver, but the state that is actually used by the device is the defualt value of just 0, and referencing the device states comes up with errors, and if I don't include a .state reference I get:
Script Error action group "Update days till Havdalah" script error in file days till havdalah.py:
Script Error strptime() argument 1 must be str, not SensorDevice
Script Error Exception Traceback (most recent call shown last):

days till havdalah.py, line 16, at top level
TypeError: strptime() argument 1 must be str, not SensorDevice

2nd is there a method to list all states available when I try this code I get no response in event log, even with logging enabled through script from this forum section:
dev = indigo.devices[1169704765]
# print(dev.states[actual_state])
print(dev.states)

Thank you,
Daniel


Any idea @Jay

Posted on
Fri Oct 27, 2023 6:31 pm
FlyingDiver offline
User avatar
Posts: 7222
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: How do I pull the states accessible through an Indigo de

Use the right click (context) menu on a device, select "Print Device Details to Log". You'll get an output like the following. Look at the "states" near the bottom.

Code: Select all
address : sensor.4_in_1_sensor_node_status
allowOnStateChange : False
allowSensorValueChange : False
batteryLevel : None
buttonGroupCount : 0
configured : True
description :
deviceTypeId : HAsensor
displayStateId : sensorValue
displayStateImageSel : NoImage
displayStateValRaw : 0.0
displayStateValUi : asleep
enabled : True
energyAccumBaseTime : None
energyAccumTimeDelta : None
energyAccumTotal : None
energyCurLevel : None
errorState :
folderId : 1484589292
globalProps : MetaProps : (dict)
     no.homeassistant.plugin : (dict)
          SupportsOnState : false (bool)
          SupportsSensorValue : true (bool)
          SupportsStatusRequest : false (bool)
          address : sensor.4_in_1_sensor_node_status (string)
          states_list : (list)
               Item : icon (string)
               Item : friendly_name (string)
id : 1304685517
lastChanged : 2023-10-27 17:47:58
lastSuccessfulComm : 2023-10-27 17:47:58
model : Home Assistant Value Sensor
name : Node Status
onState : None
ownerProps : no.homeassistant.plugin : (dict)
     SupportsOnState : false (bool)
     SupportsSensorValue : true (bool)
     SupportsStatusRequest : false (bool)
     address : sensor.4_in_1_sensor_node_status (string)
     states_list : (list)
          Item : icon (string)
          Item : friendly_name (string)
pluginId : no.homeassistant.plugin
pluginProps : emptyDict : (dict)
protocol : Plugin
remoteDisplay : True
sensorValue : 0.0
sharedProps : com.indigodomo.indigoserver : (dict)
states : States : (dict)
     actual_state : asleep (string)
     friendly_name : 4-in-1 Sensor Node status (string)
     icon : mdi:sleep (string)
     lastUpdated : 2023-10-26T14:49:46.469824+00:00 (string)
     sensorValue : 0.000000 (real)
     sensorValue.ui : asleep (string)
subModel :
subType :
supportsAllLightsOnOff : False
supportsAllOff : False
supportsOnState : False
supportsSensorValue : True
supportsStatusRequest : False
version : None

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Fri Oct 27, 2023 6:42 pm
EagleDTW offline
Posts: 69
Joined: Apr 30, 2020

Re: How do I pull the states accessible through an Indigo de

Thanks, Joe!!

Much appreciated,
-Daniel

Posted on
Fri Oct 27, 2023 6:45 pm
FlyingDiver offline
User avatar
Posts: 7222
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: How do I pull the states accessible through an Indigo de

You can also see the custom states in the Indigo UI. This doesn't have the sensorValue or sensorValue.ui values, since those are not "custom states". Those always exist for a sensor device.
Attachments
Screenshot 2023-10-27 at 8.43.55 PM.png
Screenshot 2023-10-27 at 8.43.55 PM.png (112.75 KiB) Viewed 835 times

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Fri Oct 27, 2023 6:56 pm
EagleDTW offline
Posts: 69
Joined: Apr 30, 2020

Re: How do I pull the states accessible through an Indigo de

I found this to work to pull the right date:

dateString = indigo.devices[1169704765].displayStateValUi

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 14 guests