Class property not reflecting state change

Posted on
Sat Dec 21, 2019 1:05 am
DPattee offline
Posts: 453
Joined: Jan 14, 2004
Location: Redmond, WA

Class property not reflecting state change

The class properties for a ThermostatDevice say that the coolIsOn / heatIsOn properties are just pointers to the state keys named hvacCoolerIsOn and hvacHeaterIsOn.

I've defined those two state ids in devices.xml, and I'm able to toggle them from true/false as expected with dev.updateStateOnServer("hvacHeaterIsOn", True)

But the heatIsOn never updates to match... I even set both of them to true just in case my tired eyes were messing up 'heater' or something...

Code: Select all
>>> print indigo.devices["Main Thermostat"]
[...]
coolIsOn : False
[...]
heatIsOn : False
[...]
states : States : (dict)
    [...]
     hvacCoolerIsOn : true (bool)
     [...]
     hvacHeaterIsOn : true (bool)
     [...]


That's always what I get though... The states can be toggled, but the main properties are always false.

I see that the hvacMode property is reflecting what is in the hvacOperationMode state... so something is working, but I'm not sure what the difference is / what trick I'm missing...

Posted on
Sat Dec 21, 2019 7:37 am
FlyingDiver offline
User avatar
Posts: 7211
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Class property not reflecting state change

If your plugin device is of type thermostat:

Code: Select all
    <Device type="thermostat" id="EcobeeThermostat">


Then you should not have to define those states, they will be pre-defined by the base class. Can you post the actual device definition?

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

Posted on
Sat Dec 21, 2019 10:38 am
DPattee offline
Posts: 453
Joined: Jan 14, 2004
Location: Redmond, WA

Re: Class property not reflecting state change

I'm trying to fix bugs in the Nest plugin, which is defined as a thermostat via:

Code: Select all
<Devices>
    <Device type="thermostat" id="nestThermostat">
      <Name>NEST Thermostat Module</Name>

But if I don't add these two definitions:
Code: Select all
      <State id="hvacHeaterIsOn">
        <ValueType>Boolean</ValueType>
        <TriggerLabel>asdf</TriggerLabel>
        <TriggerLabelPrefix>asdf</TriggerLabelPrefix>
        <ControlPageLabel>asdf</ControlPageLabel>
      </State>
      <State id="hvacCoolerIsOn" readonly="YES" >
        <ValueType>Boolean</ValueType>
        <TriggerLabel>asdf2</TriggerLabel>
        <TriggerLabelPrefix>asdf2</TriggerLabelPrefix>
        <ControlPageLabel>asdf2</ControlPageLabel>
      </State>

Then when I try to update them via:
Code: Select all
    dev.updateStateOnServer("hvacHeaterIsOn", True)

I get this type of error in the log:
Code: Select all
Error                           device "Main Thermostat" state key hvacHeaterIsOn not defined (ignoring update request)

Posted on
Sat Dec 21, 2019 11:32 am
matt (support) offline
Site Admin
User avatar
Posts: 21416
Joined: Jan 27, 2003
Location: Texas

Re: Class property not reflecting state change

Add the device property ShowCoolHeatEquipmentStateUI to the instance (and set it to True), either in the XML:

Code: Select all
         <Field type="checkbox" id="ShowCoolHeatEquipmentStateUI">
            <Label>Supports compressor/furnace feedback:</Label>
            <Description>Show compressor/furnace states in UI</Description>
         </Field>

or via code with dev.replacePluginPropsOnServer(), then the Indigo Server will automatically create those two states. Don't add the states manually to the XML. I'm not sure what will happen if you do that and also set the prop ShowCoolHeatEquipmentStateUI, but just using ShowCoolHeatEquipmentStateUI should take care of adding the states automatically.

Image

Posted on
Sat Dec 21, 2019 11:33 am
matt (support) offline
Site Admin
User avatar
Posts: 21416
Joined: Jan 27, 2003
Location: Texas

Re: Class property not reflecting state change

And thanks for looking at the Nest plugin!

Image

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 1 guest