Specifying zone specific data for use in Python script

bjmouton
Posts: 65
Joined: Sun Jul 23, 2017 4:01 pm

Specifying zone specific data for use in Python script

Post by bjmouton »

I have an Ecobee 3 thermostat with 5 remote sensors and I want to calculate the average temperature and write the result to an Indigo variable. The problem I am running in to is that the plugin reports two (2) values for the thermostat sensor (Zone 1 & Zone 2). The device data being pulled in to the script for the thermostat sensor looks like "70.5, 70.7", this is causing the script to error because it is not a valid number. Below is the Python script, note that Temp1 is the thermostat sensor and that I have excluded it from the list for "Temps" definition. The script works properly when excluding "Temp1", but fails when it is included.

Code: Select all

# Get devices
t1 = indigo.devices[1829625480] # "Hallway Temperature"
t2 = indigo.devices[1446069066] # "Master Bedroom Temperature"
t3 = indigo.devices[423635363] # "Kitchen Temperature"
t4 = indigo.devices[138420090] # "Living Room Temperature"
t5 = indigo.devices[1148505944] # "Office Temperature"
t6 = indigo.devices[1991769175] # "Guest Bedroom Temperature"

# Extract information on Temperatures
Temp1 = t1.displayStateValRaw
Temp2 = t2.displayStateValRaw
Temp3 = t3.displayStateValRaw
Temp4 = t4.displayStateValRaw
Temp5 = t5.displayStateValRaw
Temp6 = t6.displayStateValRaw


# Calculate average
Temps = [Temp2,Temp3,Temp4,Temp5,Temp6]
Average = sum(Temps) / len(Temps)

ConversionValue = Average
ConversionValue_String = format(ConversionValue, '.2f')
indigo.variable.updateValue(1657812550, value=ConversionValue_String) # Write the updated value back to Indigo
Attachments
Screen Shot 2020-12-05 at 00.56.36.png
Screen Shot 2020-12-05 at 00.56.36.png (148.81 KiB) Viewed 2663 times
User avatar
FlyingDiver
Posts: 7830
Joined: Sat Jun 07, 2014 10:36 am
Location: Southwest Florida, USA

Re: Specifying zone specific data for use in Python script

Post by FlyingDiver »

Don't use ".displayStateValRaw". Use ".temperatureInput1" or ".temperatureInput2" (or both).

https://wiki.indigodomo.com/doku.php?id ... ce_states5

Code: Select all

# Get devices
Temp1 = indigo.devices[1829625480].temperatureInput1     # "Hallway Temperature"
Temp2 = indigo.devices[1446069066].temperatureInput1 # "Master Bedroom Temperature"
Temp3 = indigo.devices[423635363].temperatureInput1 # "Kitchen Temperature"
Temp4 = indigo.devices[138420090].temperatureInput1 # "Living Room Temperature"
Temp5 = indigo.devices[1148505944].temperatureInput1 # "Office Temperature"
Temp6 = indigo.devices[1991769175].temperatureInput1 # "Guest Bedroom Temperature"

# Calculate average
Temps = [Temp2,Temp3,Temp4,Temp5,Temp6]
Average = sum(Temps) / len(Temps)

indigo.variable.updateValue(1657812550, value=format(Average, '.2f')).  # Write the updated value back to Indigo
joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177
bjmouton
Posts: 65
Joined: Sun Jul 23, 2017 4:01 pm

Re: Specifying zone specific data for use in Python script

Post by bjmouton »

Please see error message from captured from logger:

Script Error embedded script: 'ThermostatDevice' object has no attribute 'temperatureInput1'
Script Error Exception Traceback (most recent call shown last):

embedded script, line 19, at top level
AttributeError: 'ThermostatDevice' object has no attribute 'temperatureInput1'
User avatar
FlyingDiver
Posts: 7830
Joined: Sat Jun 07, 2014 10:36 am
Location: Southwest Florida, USA

Re: Specifying zone specific data for use in Python script

Post by FlyingDiver »

My bad, those are states not attributes. Try this.

Code: Select all

# Get devices
Temp1 = indigo.devices[1829625480].states['temperatureInput1']    # "Hallway Temperature"
Temp2 = indigo.devices[1446069066].states['temperatureInput1']    # "Master Bedroom Temperature"
Temp3 = indigo.devices[423635363].states['temperatureInput1']     # "Kitchen Temperature"
Temp4 = indigo.devices[138420090].states['temperatureInput1']     # "Living Room Temperature"
Temp5 = indigo.devices[1148505944].states['temperatureInput1']    # "Office Temperature"
Temp6 = indigo.devices[1991769175].states['temperatureInput1'].   # "Guest Bedroom Temperature"

# Calculate average
Temps = [Temp2,Temp3,Temp4,Temp5,Temp6]
Average = sum(Temps) / len(Temps)

indigo.variable.updateValue(1657812550, value=format(Average, '.2f')).  # Write the updated value back to Indigo
joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177
bjmouton
Posts: 65
Joined: Sun Jul 23, 2017 4:01 pm

Re: Specifying zone specific data for use in Python script

Post by bjmouton »

OK,
That fixed Temp1 (the one I was having the problem with and is the thermostat), but it broke Temp2....Temp6 which are all remote sensors. I just applied the change only to Temp1 and reverted back to my originals for Temp2....Temp6.

I am also having an issue with my remote sensors not updating, but I will open a new topic for that one.

Thanks for the help!
User avatar
FlyingDiver
Posts: 7830
Joined: Sat Jun 07, 2014 10:36 am
Location: Southwest Florida, USA

Re: Specifying zone specific data for use in Python script

Post by FlyingDiver »

Oh, right. Remote Sensors are just sensors, not thermostats. If you want consistent code, use states['sensorValue'] instead.
joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177
Post Reply

Return to “Ecobee”