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