5.0.3 Thermostat device type

Forum rules

This is a legacy forum which is locked for new topics. New topics should be started in one of the other forums under Extending Indigo

Posted on
Tue Jan 31, 2012 11:01 pm
berkinet offline
User avatar
Posts: 3298
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

5.0.3 Thermostat device type

I am converting the Proliphix plugin to use a device type of thermostat instead of custom and have run into a problem. I am unable too get the DEVICES window to display any data for the thermostat. I know I am reading data and writing the inherited states. But, no display data.

Here is my thermostat object and the Indigo UI display:
Code: Select all
>>> print indigo.devices[262748967]
address :
buttonGroupCount : 0
coolIsOn : False
coolSetpoint : 0.0
description :
deviceTypeId : proliphixTstat
enabled : True
errorState :
fanIsOn : False
fanMode : Auto
folderId : 1062697007
globalProps : MetaProps : (dict)
     com.berkinet.ProliphixControl : (dict)
          NumHumidityInputs : 0 (string)
          NumTemperatureInputs : 1 (string)
          ShowCoolHeatEquipmentStateUI : false (bool)
          tstatAddress : 192.168.4.163 (string)
          tstatModel : NT20e (string)
          tstatPass : admin (string)
          tstatPort : 80 (string)
          tstatUser : admin (string)
heatIsOn : False
heatSetpoint : 0.0
humidities : []
humiditySensorCount : 0
hvacMode : Off
id : 262748967
lastChanged : 2012-01-31 20:48:06
model : Proliphix Thermostat
name : Thermostat: Berkeley Downstairs
pluginId : com.berkinet.ProliphixControl
pluginProps : emptyDict : (dict)
protocol : Plugin
remoteDisplay : True
states : States : (dict)
     humidityInput1 : 0 (string)
     hvacFanMode : 0 (integer)
     hvacFanModeIsAlwaysOn : false (bool)
     hvacFanModeIsAuto : false (bool)
     hvacOperationMode : 0 (integer)
     hvacOperationModeIsAuto : false (bool)
     hvacOperationModeIsCool : false (bool)
     hvacOperationModeIsHeat : false (bool)
     hvacOperationModeIsOff : false (bool)
     hvacOperationModeIsProgramAuto : false (bool)
     hvacOperationModeIsProgramCool : false (bool)
     hvacOperationModeIsProgramHeat : false (bool)
     lastRead : 2012-01-31 20:48:06 (string)
     setpointCool : 95.0 (string)
     setpointHeat : 67.0 (string)
     temperatureInput1 : 66.0 (string)
     temperatureInputsAll :  (string)
     thermCurrentClass : Occupied/In (string)
     thermCurrentPeriod : Evening (string)
     thermFanState : Off (string)
     thermHvacState : Heat (string)
     thermSetbackStatus : Override (string)
supportsAllLightsOnOff : False
supportsAllOff : False
supportsStatusRequest : True
temperatureSensorCount : 1
temperatures : [0.0]
version :

tstat.png
tstat.png (18.21 KiB) Viewed 2991 times

Posted on
Wed Feb 01, 2012 8:19 am
matt (support) offline
Site Admin
User avatar
Posts: 21429
Joined: Jan 27, 2003
Location: Texas

Re: 5.0.3 Thermostat device type

berkinet wrote:
I am converting the Proliphix plugin to use a device type of thermostat


Awesome -- I was hoping you would do this! :-)

berkinet wrote:
I am unable too get the DEVICES window to display any data for the thermostat. I know I am reading data and writing the inherited states. But, no display data.


Hmm... the dump of the thermostat instance looks good. Some questions:

1) Does the Example Thermostat plugin work?

2) Copy/paste the exact .py lines you are using to change the main temperature input.

3) Are there any errors logged when you update states?

Image

Posted on
Wed Feb 01, 2012 11:04 am
berkinet offline
User avatar
Posts: 3298
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: 5.0.3 Thermostat device type

Ok... The example plugin works (and displays seemingly random temp values).

The plugin was throwing an minor error:
    Error device state key temperatureInput2 not defined (ignoring update request)
    Error device state key temperatureInput3 not defined (ignoring update request)
Which I had just ignored for the time, but just now fixed. The reason for not dealing with it immediately is that I read from the physical device and write to the Indigo device in a two nested loops (outer iterates over the devices, and the inner iterates a list of OIDs). And, since you asked, here is where the loop writes to Indigo...
    prDevice.updateStateOnServer(key=theOBJ, value=theOUT)

I am sure I am just missing setting something. But, for the moment I can't seem to find it. To that end, I diffed the example device "<" and my device ">" and get this:
Code: Select all
ip-94:~ rdp$ diff obj-1 obj-2
1c1
< address : 123456
---
> address : 12345
4c4
< coolSetpoint : 77.5
---
> coolSetpoint : 0.0
6c6
< deviceTypeId : myThermoType
---
> deviceTypeId : proliphixTstat
13,14c13,15
<      com.perceptiveautomation.indigoplugin.example-device-thermo1 : (dict)
<           NumHumidityInputs : 1 (string)
---
>      com.berkinet.ProliphixControl : (dict)
>           Address : 12345 (string)
>           NumHumidityInputs : 0 (string)
17c18,23
<           address : 123456 (string)
---
>           address : 12345 (string)
>           tstatAddress : 192.168.4.163 (string)
>           tstatModel : NT20e (string)
>           tstatPass : admin (string)
>           tstatPort : 80 (string)
>           tstatUser : admin (string)
19,27c25,33
< heatSetpoint : 66.5
< humidities : [79.0]
< humiditySensorCount : 1
< hvacMode : HeatCool
< id : 177492077
< lastChanged : 2012-02-01 08:39:52
< model : Example Thermostat Module
< name : new device 1
< pluginId : com.perceptiveautomation.indigoplugin.example-device-thermo1
---
> heatSetpoint : 0.0
> humidities : []
> humiditySensorCount : 0
> hvacMode : Off
> id : 262748967
> lastChanged : 2012-02-01 08:46:58
> model : Proliphix Thermostat
> name : Thermostat: Berkeley Downstairs
> pluginId : com.berkinet.ProliphixControl
32,34d37
<      backlightBrightness : 85 (integer)
<      humidityInput1 : 79 (real)
<      humidityInputsAll : 79 (string)
36d38
<      hvacFanMode.ui : auto on (string)
38,41c40,42
<      hvacFanModeIsAuto : true (bool)
<      hvacOperationMode : 3 (integer)
<      hvacOperationMode.ui : auto on (string)
<      hvacOperationModeIsAuto : true (bool)
---
>      hvacFanModeIsAuto : false (bool)
>      hvacOperationMode : 0 (integer)
>      hvacOperationModeIsAuto : false (bool)
48,51c49,58
<      setpointCool : 77.5 (real)
<      setpointHeat : 66.5 (real)
<      temperatureInput1 : 76 (real)
<      temperatureInputsAll : 76 (string)
---
>      lastRead : 2012-02-01 08:46:58 (string)
>      setpointCool : 95.0 (string)
>      setpointHeat : 66.0 (string)
>      temperatureInput1 : 67.0 (string)
>      temperatureInputsAll :  (string)
>      thermCurrentClass : Occupied/In (string)
>      thermCurrentPeriod : Morning (string)
>      thermFanState : Off (string)
>      thermHvacState : Off (string)
>      thermSetbackStatus : Normal (string)
56c63
< temperatures : [76.0]
---
> temperatures : [0.0]


Maybe your bright eyes wu=ill see what I missed :?

Posted on
Wed Feb 01, 2012 11:23 am
matt (support) offline
Site Admin
User avatar
Posts: 21429
Joined: Jan 27, 2003
Location: Texas

Re: 5.0.3 Thermostat device type

I think the problem is you are passing strings and not floats (or integers) to the updateStateOnServer() method. The example plugin temperatureInput1 is type "real" but your temperatureInput1 is type "string."

So for your theOUT object, when it is a temperature/humidity/setpoint value, try casting it via float() before you call updateStateOnServer().

Image

Posted on
Wed Feb 01, 2012 11:32 am
berkinet offline
User avatar
Posts: 3298
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: 5.0.3 Thermostat device type

That was it. Now to the next step. The Proliphix data dictionary does not map directly to the pre-set elements you have defined for the UI. So, I need to do a bit of juggling. Also, this was the first plugin I wrote, and as I look at it now, it could use a "bit" of a re-write.

But, I am over the big hump and its downhill from here.

Thanks.

Posted on
Wed Feb 01, 2012 11:42 am
matt (support) offline
Site Admin
User avatar
Posts: 21429
Joined: Jan 27, 2003
Location: Texas

Re: 5.0.3 Thermostat device type

support wrote:
I think the problem is you are passing strings and not floats (or integers) to the updateStateOnServer() method.


FYI, I'll look into relaxing how Indigo deals with those state value types so that even if the float() cast is not there it will still work.

Image

Posted on
Wed Feb 01, 2012 12:12 pm
berkinet offline
User avatar
Posts: 3298
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: 5.0.3 Thermostat device type

Actually, the data type was not really an issue. My code checks for the OID's data type and then casts it as necessary. I was using strings so I could manage the decimal places. But, that is no longer required (thanks). What would help, and I know it is in the code, would be some additional documentation on the data type for each inherited state. (string, int, enumeration (with the enumerated values) & the relationship between writable states, readonly states and the actual UI display. For example, for temp there are: temperatureInput[1,2,3] (writable), temperatureInputsAll (read only) and temperatures. I assume that the 3 sensors are averaged for ALL, but even that is not completely clear. And, what is temperatures - is that the display element and where does it come from.

Anyway, none of this is urgent, and if, when I finish my changes, I still remember what I did, I'll try a quick write-up.

Posted on
Wed Feb 01, 2012 12:49 pm
jay (support) offline
Site Admin
User avatar
Posts: 18265
Joined: Mar 19, 2008
Location: Austin, Texas

Re: 5.0.3 Thermostat device type

Yep, docs are coming as soon as I finish up a thermostat plugin myself.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Wed Feb 01, 2012 4:30 pm
berkinet offline
User avatar
Posts: 3298
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: 5.0.3 Thermostat device type

support wrote:
berkinet wrote:
I am converting the Proliphix plugin to use a device type of thermostat
Awesome -- I was hoping you would do this! :-)

So, to help those other intrepid souls who may try this. Once I got past the basics (data types, etc.) I ran into a significant issue that may affect other networked thermostats.

(At least) for the Proliphix network thermostats, there is a limit to the frequency you can send updates/queries.
In the Proliphix API the developers wrote:
Limitations on the Frequency of Operations
While the device can handle numerous back to back requests, it is advisable to not sustain an operation frequency higher than 1 request per 60 second period for a substantial amount of time. In other words, sustained polling of the device should not exceed a few requests per minute. A prolonged burst of requests higher than 1 request per 60 second period may degrade the main function of the thermostat. Also, if one is making a PIB set and wishes to observe a reaction from the device, it is advisable to wait for at least 1 second between the set request and subsequent get request.

The plugin thermostat device type is, apparently, based on the Venstar thermostat which (as far as I can tell) does not have such limitations.

Since the Indigo thermostat UI has those nice widgets for adjusting the setpoints, it was clear that any change of more than a degree or two could overload the thermostat. At the same time there is a need to provide quick visual feedback that the keypress/touch has been registered. But, clearly a read for each write for act degree of change could be too much.

I solved the problem by creating a resettable 2 second timer and passing the change request to the timer. If there are additional key presses (up or down) before the 2 seconds are up, the timer is reset, the setpoint value adjusted accordingly - and the device's setpoint state is immediately updated. When the timer times out, the new setpoint value is actually written out, and the device is polled to make sure the displayed setpoint is correct.

I would be glad to share the resettable timer code if anyone is interested.

Posted on
Wed Feb 01, 2012 5:14 pm
berkinet offline
User avatar
Posts: 3298
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Bug or?

I am now seeing what looks like an anomaly in one of my thermostat devices. The issue is the decimal precision in the displayed temperature value. Note that the readOnly temperatureInputsAll accurately reflects temperatureInput1 yet, the state temperatures has a value of 68.200000000000003

Code: Select all
address :
buttonGroupCount : 0
coolIsOn : False
coolSetpoint : 110.3
description :
deviceTypeId : proliphixTstat
enabled : True
errorState :
fanIsOn : False
fanMode : Auto
folderId : 1062697007
globalProps : MetaProps : (dict)
     com.berkinet.ProliphixControl : (dict)
          NumHumidityInputs : 1 (string)
          NumTemperatureInputs : 1 (string)
          ShowCoolHeatEquipmentStateUI : false (bool)
          address :  (string)
          tstatAddress : france.perlman.com (string)
          tstatModel : IMT550c/w (string)
          tstatPass : M1r4cl3 (string)
          tstatPort : 10080 (string)
          tstatUser : admin (string)
heatIsOn : False
heatSetpoint : 67.1
humidities : [38.0]
humiditySensorCount : 1
hvacMode : Off
id : 1844854028
lastChanged : 2012-02-01 14:58:50
model : Proliphix Thermostat
name : Thermostat: Mougins
pluginId : com.berkinet.ProliphixControl
pluginProps : emptyDict : (dict)
protocol : Plugin
remoteDisplay : True
states : States : (dict)
     humidityInput1 : 38 (real)
     humidityInputsAll : 38 (string)
     hvacFanMode : Off (string)
     hvacFanModeIsAlwaysOn : false (bool)
     hvacFanModeIsAuto : false (bool)
     hvacOperationMode : Off (string)
     hvacOperationModeIsAuto : false (bool)
     hvacOperationModeIsCool : false (bool)
     hvacOperationModeIsHeat : false (bool)
     hvacOperationModeIsOff : false (bool)
     hvacOperationModeIsProgramAuto : false (bool)
     hvacOperationModeIsProgramCool : false (bool)
     hvacOperationModeIsProgramHeat : false (bool)
     lastRead : 2012-02-01 14:58:50 (string)
     setpointCool : 110.3 (real)
     setpointHeat : 67.0 (real)
     temperatureInput1 : 68.2 (real)
     temperatureInputsAll : 68.2 (string)
     thermCurrentClass : Unoccupied/Out (string)
     thermCurrentPeriod : Night (string)
     thermFanState :  (string)
     thermHvacState :  (string)
     thermSetbackStatus : Normal (string)
supportsAllLightsOnOff : False
supportsAllOff : False
supportsStatusRequest : True
temperatureSensorCount : 1
temperatures : [68.200000000000003]
version : 0

Posted on
Wed Feb 01, 2012 6:25 pm
matt (support) offline
Site Admin
User avatar
Posts: 21429
Joined: Jan 27, 2003
Location: Texas

Re: Bug or?

berkinet wrote:
I am now seeing what looks like an anomaly in one of my thermostat devices. The issue is the decimal precision in the displayed temperature value. Note that the readOnly temperatureInputsAll accurately reflects temperatureInput1 yet, the state temperatures has a value of 68.200000000000003.

That is just the nature of how floating points are stored internally on computers. You can specify the precision you want when it is logged or converted to a string by using %.2f formatter, like:

Code: Select all
tempStr = "%.2f" % (dev.temperatures[0],)

(or %.1f for tenths, or %.0f for integer precision)

Image

Posted on
Wed Feb 01, 2012 6:32 pm
berkinet offline
User avatar
Posts: 3298
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: Bug or?

support wrote:
...That is just the nature of how floating points are stored internally on computers. You can specify the precision you want when it is logged or converted to a string by using %.2f formatter


Well, maybe I am missing something here... But, I thought Indigo calculated the temperatures state object. All I am writing to is temperatureInput1, and I have set the updateStateOnServer to use decimalPlaces=1. Are you saying that decimalPlaces only affects the display and not the actual value stored in Indigo. Ok. I'll try that.

But, OTOH, from time to time I still see full precision numbers in the state column. Mostly when I restart the plugin, then they clear later on updates.

Posted on
Wed Feb 01, 2012 6:54 pm
berkinet offline
User avatar
Posts: 3298
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: 5.0.3 Thermostat device type

Well, if this is something I can control, I am missing it.

I now have this code in the plugin:
    theOUT = round(float(theOUT), 1)
    prDevice.updateStateOnServer(key=theOBJ, value=theOUT, decimalPlaces=1)

Which sets these two states:
    temperatureInput1 : 67.40000000000001 (real)
    temperatureInput2 : 70.5 (real)

From which Indigo derives:
    temperatureInputsAll : 67.40000000000001, 70.5 (string)
    temperatures : [67.400000000000006, 70.5]

But, after letting a few minutes pass, I see these values:
    temperatureInput1 : 66.8 (real)
    temperatureInput2 : 70.2 (real)
    temperatureInputsAll : 66.8, 70.2 (string)
    temperatures : [66.799999999999997, 70.200000000000003]

Seems flakey to me, but maybe its me that's flakey :?

Posted on
Wed Feb 01, 2012 7:21 pm
matt (support) offline
Site Admin
User avatar
Posts: 21429
Joined: Jan 27, 2003
Location: Texas

Re: 5.0.3 Thermostat device type

We need to document it, but the decimalPlaces arg is only supported for custom states not states inherited from Indigo. We might improve that at some point, but right now it is ignored for relay/dimmer/thermostat inherited states.

Image

Posted on
Wed Feb 01, 2012 8:04 pm
berkinet offline
User avatar
Posts: 3298
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: 5.0.3 Thermostat device type

Gotcha.

On the same subject (more-or-less), I assume the syntax you used in the example:
    dev.updateStateOnServer("setpointHeat", 66.5)

Is just a synonym for:
    dev.updateStateOnServer(key="setpointHeat", value=66.5)

Or is something else implied?

Who is online

Users browsing this forum: No registered users and 2 guests