Thermostat problem

Posted on
Sun Sep 08, 2013 9:51 am
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Thermostat problem

I am trying to track down a problem with the thermostat type device. In I6.0.1 When I save the new device I get the following errors:
    Error device "new device 1" state key humidityInput1 not defined (ignoring update request)
    Error device "new device 1" state key humidityInputsAll not defined (ignoring update request)
    Error device "new device 1" state key humidityInput1 not defined (ignoring update request)

But if I restart the plugin, and open the device's config again, and save. Eventually the states appear. Any idea what is going on?

Posted on
Sun Sep 08, 2013 10:48 am
matt (support) offline
Site Admin
User avatar
Posts: 21411
Joined: Jan 27, 2003
Location: Texas

Re: Thermostat problem

At what point are you setting the device's NumHumidityInputs property? Is the problem just that it isn't getting set before validateDeviceConfigUi() returns? One trick is to add NumHumidityInputs to the device's configUI XML even if you don't want it in the UI (so set the hidden attribute):

Code: Select all
   <Field type="textfield" id="NumHumidityInputs" hidden="true" defaultValue="0" />


Then inside validateDeviceConfigUi() you can just set valuesDict["NumHumidityInputs'] to whatever you need, which should cause the states to be updated before deviceStartComm() gets called on the device.

Image

Posted on
Sun Sep 08, 2013 11:02 am
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: Thermostat problem

Well, that might be an issue but I already have...
Code: Select all
         <Field type="menu" id="NumHumidityInputs" defaultValue="1">
            <Label>Number of humidity sensors:</Label>
            <List>
               <Option value="0">None</Option>
               <Option value="1">1</Option>
               <Option value="2">2</Option>
               <Option value="3">3</Option>
            </List>
         </Field>


It looks like the plugin is trying to update the states but they have not been defined. SInce these states are supposed to be inherited that should have been done automatically. But, for some reason they are delayed or missed. validateDeviceConfigUi() doesn't explicitly deal with the property should be as set configUI. Also, I have not created a local getDeviceStateList(). So, the creation of the states should be out of my hands.

Posted on
Sun Sep 08, 2013 11:27 am
matt (support) offline
Site Admin
User avatar
Posts: 21411
Joined: Jan 27, 2003
Location: Texas

Re: Thermostat problem

But in this case is NumHumidityInputs 0? That would explain the errors. The states are dynamically added and removed based on NumHumidityInputs. If it is 0, then humidityInput1 and humidityInputsAll will not exist.

Image

Posted on
Sun Sep 08, 2013 11:36 am
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: Thermostat problem

Got it... So, rename my field to endNumHumidityInputs, set the hidden field to NumHumidityInputs to 1, and then set NumHumidityInputs to endNumHumidityInputs in the return from validateDeviceConfigUi() .

Thanks.

Posted on
Sun Sep 08, 2013 11:40 am
matt (support) offline
Site Admin
User avatar
Posts: 21411
Joined: Jan 27, 2003
Location: Texas

Re: Thermostat problem

Hmmm... I'm not sure why that would be necessary. Just your original NumHumidityInputs definition as a List should be fine. The only problem would be if you have code that tries to access the humidityInput1 or humidityInputsAll states in the case when the user has selected None (0), since they won't exist in that case. Note you can always test to see if a state exists before you access it:

Code: Select all
if 'humidityInput1' in somedevice.states:
   # do something with somedevice.states['humidityInput1']

Image

Posted on
Sun Sep 08, 2013 12:20 pm
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: Thermostat problem

Ok. What you say makes sense, for the case of zero humidity inputs. But, I think the problem has only appeared when NumHumidityInputs was > 0. My code immdiately tries to query the thermostat as soon as it is "created." Maybe that needs a short delay--- though I am not sure why the states would not be created immediately.

Posted on
Sun Sep 08, 2013 1:11 pm
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: Thermostat problem

Ok, something definitely weird going on here.

But, I did find one issue. This plugin still used deviceCreted() and was not testing for dev.created. So, when the config dialog first opened it threw an error. I added deviceStartComm() and deleted deviceCreated().

But, when the device is first created, it still throws the errors:
    Error device "new device 1" state key humidityInput1 not defined (ignoring update request)
    Error device "new device 1" state key humidityInputsAll not defined (ignoring update request)
    Error device "new device 1" state key humidityInput1 not defined (ignoring update request)

Those go away after a plugin restart.

In the meantime, to fix an error reported by a user, I commented out the hvacHeaterIsOn and hvacCoolerIsOn states from Devices.xml - that fixed the errors he was seeing:
    Error (client) illegal state key hvacHeaterIsOn defined by plugin -- native state keys cannot be overriden (ignoring)
    Error (client) illegal state key hvacCoolerIsOn defined by plugin -- native state keys cannot be overriden (ignoring)
That fixed his issue.

But, now when I try to create a new thermostat device I get
    Error device "new device 1" state key hvacHeaterIsOn not defined (ignoring update request)
    Error device "new device 1" state key hvacCoolerIsOn not defined (ignoring update request)
and had to add the states back to Devices.xml.

Very, very odd.

Posted on
Sun Sep 08, 2013 4:21 pm
matt (support) offline
Site Admin
User avatar
Posts: 21411
Joined: Jan 27, 2003
Location: Texas

Re: Thermostat problem

berkinet wrote:
But, when the device is first created, it still throws the errors:
    Error device "new device 1" state key humidityInput1 not defined (ignoring update request)
    Error device "new device 1" state key humidityInputsAll not defined (ignoring update request)
    Error device "new device 1" state key humidityInput1 not defined (ignoring update request)

I'm afraid I need to see the code that is referencing those states and also the your deviceStartComm() method to troubleshoot this. It sounds like your plugin is trying to reference those devices before NumHumidityInputs is > 0, but without more details I don't know why.

berkinet wrote:
In the meantime, to fix an error reported by a user, I commented out the hvacHeaterIsOn and hvacCoolerIsOn states from Devices.xml - that fixed the errors he was seeing:
    Error (client) illegal state key hvacHeaterIsOn defined by plugin -- native state keys cannot be overriden (ignoring)
    Error (client) illegal state key hvacCoolerIsOn defined by plugin -- native state keys cannot be overriden (ignoring)
That fixed his issue.

Correct. Indigo doesn't like it when a plugin tries to re-define a native state type for a type of device. That is Indigo's responsibility.

berkinet wrote:
But, now when I try to create a new thermostat device I get
    Error device "new device 1" state key hvacHeaterIsOn not defined (ignoring update request)
    Error device "new device 1" state key hvacCoolerIsOn not defined (ignoring update request)
and had to add the states back to Devices.xml.

Don't add those back. This is the same issue as with NumHumidityInputs, but in this case it is the property ShowCoolHeatEquipmentStateUI which isn't set to true before your plugin references the states hvacHeaterIsOn or hvacCoolerIsOn.

Image

Posted on
Mon Sep 09, 2013 11:22 am
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: Thermostat problem

Ok...This was my first plugin and I have learned a lot since I wrote this so I took the time to do a little code cleanup, and hopefully find the source of this problem in the process, which didn't happen. Anyway, here is deviceStartComm():
Code: Select all
 def deviceStartComm(self, dev):
        if self.logLevel > 1: indigo.server.log("deviceStartComm: entered for device: %s" % (dev.name), type=self.pluginDisplayName)
        if self.logLevel > 0: indigo.server.log("deviceStartComm: Starting device %s" % (dev.name), type=self.pluginDisplayName)

        if dev.enabled:
            if self.logLevel > 1: indigo.server.log("deviceStartComm: Added device device %s to device dct" % (dev.id), type=self.pluginDisplayName)
            self.thermCap[dev.id] = \
                {'NumHumidityInputs': dev.pluginProps["NumHumidityInputs"], \
                'NumTemperatureInputs': dev.pluginProps["NumTemperatureInputs"], \
                'ShowCoolHeatEquipmentStateUI': dev.pluginProps["ShowCoolHeatEquipmentStateUI"]}

        if self.logLevel > 1: indigo.server.log("deviceStartComm: completed", type=self.pluginDisplayName)


And this is the log output I get (every method has an enter and complete debug statement so I can trace the flow...
    Proliphix Thermostat Control validateDeviceConfigUi: entered
    Proliphix Thermostat Control validateDeviceConfigUi: completed
    Proliphix Thermostat Control deviceStartComm: entered for device: new device 1
    Proliphix Thermostat Control deviceStartComm: Starting device new device 1
    Proliphix Thermostat Control deviceStartComm: Added device device 78150067 to device dct
    Proliphix Thermostat Control deviceStartComm: completed

And here, without the desired inherited states, is the device:
Code: Select all
address :
batteryLevel : None
buttonGroupCount : 0
configured : True
coolIsOn : False
coolSetpoint : 37.5
dehumidifierIsOn : False
description :
deviceTypeId : proliphixTstat
enabled : True
energyAccumBaseTime : None
energyAccumTimeDelta : None
energyAccumTotal : None
energyCurLevel : None
errorState :
fanIsOn : False
fanMode : Auto
folderId : 89138017
globalProps : MetaProps : (dict)
     com.berkinet.ProliphixControl : (dict)
          NumHumidityInputs : 1 (string)
          NumTemperatureInputs : 1 (string)
          ShowCoolHeatEquipmentStateUI : false (bool)
          tstatAddress : 192.168.5.30 (string)
          tstatModel : IMT550c/w (string)
          tstatPass : foo (string)
          tstatPort : 10030 (string)
          tstatUser : admin (string)
heatIsOn : False
heatSetpoint : 22.0
humidifierIsOn : False
humidities : [47.0]
humiditySensorCount : 1
hvacMode : Off
id : 78150067
lastChanged : 2013-09-09 19:07:28
model : Proliphix Thermostat
name : new device 1
pluginId : com.berkinet.ProliphixControl
pluginProps : emptyDict : (dict)
protocol : Plugin
remoteDisplay : True
states : States : (dict)
     hvacFanMode : 0 (integer)
     hvacFanModeIsAlwaysOn : false (bool)
     hvacFanModeIsAuto : true (bool)
     hvacOperationMode : 0 (integer)
     hvacOperationModeIsAuto : false (bool)
     hvacOperationModeIsCool : false (bool)
     hvacOperationModeIsHeat : false (bool)
     hvacOperationModeIsOff : true (bool)
     hvacOperationModeIsProgramAuto : false (bool)
     hvacOperationModeIsProgramCool : false (bool)
     hvacOperationModeIsProgramHeat : false (bool)
     lastRead : 2013-09-09 19:07:28 (string)
     setpointCool : 37.5 (real)
     setpointHeat : 22 (real)
     temperatureInput1 : 25.1 (real)
     temperatureInputsAll : 25.1 (string)
     thermCurrentClass : Unoccupied/Out (string)
     thermCurrentPeriod : Evening (string)
     thermFanState :  (string)
     thermHvacState : Unoccupied/Out (string)
     thermSetbackStatus : Normal (string)
subModel :
supportsAllLightsOnOff : False
supportsAllOff : False
supportsStatusRequest : True
temperatureSensorCount : 1
temperatures : [25.100000000000001]
version : 0


I did find one odd thing. I had implemented deviceUpdated() and found that when I created a new device, deviceStartComm() is NOT called as long as deviceUpdated() exists. Perhaps I should be returning something from deviceUpdated(), right now it returns nothing? Anyway, for the tests done above, deviceUpdated() was commented out. I should also replace deviceUpdated() with didDeviceCommPropertyChange() -- but I though I should mention this behavior anyway.
Last edited by berkinet on Mon Sep 09, 2013 2:40 pm, edited 1 time in total.

Posted on
Mon Sep 09, 2013 1:41 pm
matt (support) offline
Site Admin
User avatar
Posts: 21411
Joined: Jan 27, 2003
Location: Texas

Re: Thermostat problem

When you commented out deviceUpdated() did you comment out the entire thing (including the function declaration)?

Plugins normally don't need to override deviceUpdated() and if they do they must make sure they call the base class implementation since it has logic which ends up calling deviceStartComm(), deviceStopComm(), etc.

Thoughts for troubleshooting: you should log the entire device inside the deviceStartComm() method so we can see how it exists there.

And a question: for above where you logged the device, where in the code is that and how does it get the device exactly (is it a cached copy the plugin has, or is it directly calling indigo.devices[id] to get it there)?

Image

Posted on
Mon Sep 09, 2013 2:19 pm
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: Thermostat problem

matt (support) wrote:
When you commented out deviceUpdated() did you comment out the entire thing (including the function declaration)?

Well, I didn't exactly comment it out, I just changed the name to xdeviceUpdated.

matt (support) wrote:
Plugins normally don't need to override deviceUpdated() and if they do they must make sure they call the base class implementation since it has logic which ends up calling deviceStartComm(), deviceStopComm(), etc.

Yea, I know. I wrote this almost 2 years ago. I am switching to didDeviceCommPropertyChange()

matt (support) wrote:
Thoughts for troubleshooting: you should log the entire device inside the deviceStartComm() method so we can see how it exists there.

I will dump the device at the start and end of startDeviceComm(). But, since the states aren't there at the end, I am not sure what I will see.

matt (support) wrote:
And a question: for above where you logged the device, where in the code is that and how does it get the device exactly (is it a cached copy the plugin has, or is it directly calling indigo.devices[id] to get it there)?

I "printed" the device in the scripting shell after seeing startDeviceComm() finish in the log.

Posted on
Mon Sep 09, 2013 2:40 pm
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: Thermostat problem

matt (support) wrote:
...Thoughts for troubleshooting: you should log the entire device inside the deviceStartComm() method so we can see how it exists there...


the dev is the same at the end of startDeviceComm() as at the start (I saved both printouts to files and diffed them).

Here is the device (BTW, I am creating new devices each time I test this.)
Code: Select all
address :
batteryLevel : None
buttonGroupCount : 0
configured : True
coolIsOn : False
coolSetpoint : 0.0
dehumidifierIsOn : False
description :
deviceTypeId : proliphixTstat
enabled : True
energyAccumBaseTime : None
energyAccumTimeDelta : None
energyAccumTotal : None
energyCurLevel : None
errorState :
fanIsOn : False
fanMode : Auto
folderId : 89138017
globalProps : MetaProps : (dict)
     com.berkinet.ProliphixControl : (dict)
          NumHumidityInputs : 1 (string)
          NumTemperatureInputs : 1 (string)
          ShowCoolHeatEquipmentStateUI : false (bool)
          tstatAddress : 192.168.5.30 (string)
          tstatModel : IMT550c/w (string)
          tstatPass : foo (string)
          tstatPort : 10030 (string)
          tstatUser : admin (string)
heatIsOn : False
heatSetpoint : 0.0
humidifierIsOn : False
humidities : [0.0]
humiditySensorCount : 1
hvacMode : Off
id : 1082811091
lastChanged : 2000-01-01 00:00:00
model : Proliphix Thermostat
name : new device 1
pluginId : com.berkinet.ProliphixControl
pluginProps : com.berkinet.ProliphixControl : (dict)
     NumHumidityInputs : 1 (string)
     NumTemperatureInputs : 1 (string)
     ShowCoolHeatEquipmentStateUI : false (bool)
     tstatAddress : 192.168.5.30 (string)
     tstatModel : IMT550c/w (string)
     tstatPass : foo (string)
     tstatPort : 10030 (string)
     tstatUser : admin (string)
protocol : Plugin
remoteDisplay : True
states : States : (dict)
     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 :  (string)
     setpointCool : 0 (integer)
     setpointHeat : 0 (integer)
     temperatureInput1 : 0 (integer)
     temperatureInputsAll :  (string)
     thermCurrentClass :  (string)
     thermCurrentPeriod :  (string)
     thermFanState :  (string)
     thermHvacState :  (string)
     thermSetbackStatus :  (string)
subModel :
supportsAllLightsOnOff : False
supportsAllOff : False
supportsStatusRequest : True
temperatureSensorCount : 1
temperatures : [0.0]
version : 0

Posted on
Mon Sep 09, 2013 3:03 pm
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: Thermostat problem

A little more info...
After creating the device, attempts to read from it resulted in:
    2013-09-09 19:07:28 Error device "new device 1" state key hvacHeaterIsOn not defined (ignoring update request)
    2013-09-09 19:07:28 Error device "new device 1" state key hvacCoolerIsOn not defined (ignoring update request)
    2013-09-09 19:07:28 Error device "new device 1" state key humidityInput1 not defined (ignoring update request)
    2013-09-09 19:07:28 Error device "new device 1" state key humidityInputsAll not defined (ignoring update request)

But, after opening the device, Editing (no changes), saving and closing, the errors drop to:
    2013-09-09 19:07:28 Error device "new device 1" state key hvacHeaterIsOn not defined (ignoring update request)
    2013-09-09 19:07:28 Error device "new device 1" state key hvacCoolerIsOn not defined (ignoring update request)

And,of course, when looking at the device, the humidityInput1, humidityInputsAll states are created.

Question, is there a dependance on some device property for hvacHeaterIsOn & hvacCoolerIsOn - like humidityInput1 & humidityInputsAll depend on the NumHumidityInputs property?

Posted on
Mon Sep 09, 2013 3:06 pm
matt (support) offline
Site Admin
User avatar
Posts: 21411
Joined: Jan 27, 2003
Location: Texas

Re: Thermostat problem

I'm not sure what is going wrong. I just tried it with the Example Thermostat plugin (part of the SDK), and had it log the dev argument to startDeviceComm() immediately after creating a new device with a NumHumidityInputs set to 1:

Code: Select all
...
globalProps : MetaProps : (dict)
     com.perceptiveautomation.indigoplugin.example-device-thermo1 : (dict)
          NumHumidityInputs : 1 (string)
          NumTemperatureInputs : 1 (string)
          ShowCoolHeatEquipmentStateUI : false (bool)
          SupportsCoolSetpoint : true (bool)
          SupportsHeatSetpoint : true (bool)
          SupportsHvacFanMode : true (bool)
          SupportsHvacOperationMode : true (bool)
          address : 123456 (string)
heatIsOn : False
heatSetpoint : 0.0
humidifierIsOn : False
humidities : [0.0]
humiditySensorCount : 1
hvacMode : Off
id : 1316938611
lastChanged : 2000-01-01 00:00:00
model : Example Thermostat Module
name : new device 2
pluginId : com.perceptiveautomation.indigoplugin.example-device-thermo1
pluginProps : com.perceptiveautomation.indigoplugin.example-device-thermo1 : (dict)
     NumHumidityInputs : 1 (string)
     NumTemperatureInputs : 1 (string)
     ShowCoolHeatEquipmentStateUI : false (bool)
     SupportsCoolSetpoint : true (bool)
     SupportsHeatSetpoint : true (bool)
     SupportsHvacFanMode : true (bool)
     SupportsHvacOperationMode : true (bool)
     address : 123456 (string)
protocol : Plugin
remoteDisplay : True
states : States : (dict)
     backlightBrightness : 0 (integer)
     humidityInput1 : 0 (integer)
     humidityInputsAll :  (string)
     ...


so that seemed to work correctly. Why don't you email me the most recent version of your plugin and I'll glance at it?

As I mentioned before the states hvacHeaterIsOn & hvacCoolerIsOn depend on the property ShowCoolHeatEquipmentStateUI being set to True. They are independent of the humidity property / states.

Image

Who is online

Users browsing this forum: No registered users and 13 guests

cron