Input_select and input_slider Help Please

My Trane Z-Wave Thermostat paired with HA, shows up in HA but the temperature adjustments are in .1 increments and they need to be whole numbers. The unit shows up as:

sensor.trane_model_tzemt400ab32maa_temperature_34_1
climate.trane_model_tzemt400ab32maa_heating_1_34_1
climate.trane_model_tzemt400ab32maa_cooling_1_34_2

I created an input select and input slider:

hvac_target_temp:
  name: 'Set Target Temp'
  min: 60
  max: 85
  step: 1
  initial: 75

Which shows up in the entities list as:

input_slider.hvac_target_temp

My question is, how do I point that to the Thermostat. As it is now, I move the slider and nothing happens. If I can get this to function correctly I can leave my thermostat in HA, otherwise, I will likely have to move it back to the Vera hub as it works as it should there.

in short, have an automation that when the input slider is changed, set the value on the thermostat.

Okay, I wondered about that. Well, off to write some automation. Thank you @turboc.

Okay, so I am going to need some help with the automation. First, the automation that I have. I found some examples that I was able to adapt:

### Set the thermostat temperature based on the setting of the related
### Input Slider.

  - alias: 'Thermostat Temperature Setpoint'
    trigger:
      - platform: state
        entity_id: input_slider.hvac_target_temp
    action:
      - service: climate.set_temperature
        data_template:
          entity_id: >-
            {% if is_state('input_select.hvac_operation_mode', 'Heat') %}
              climate.trane_model_tzemt400ab32maa_heating_1_34_1
            {% elif is_state('input_select.hvac_operation_mode', 'Cool') %}
              climate.trane_model_tzemt400ab32maa_cooling_1_34_2
            {% endif %}
          temperature: "{{ states('input_slider.hvac_target_temp') }}"


### Sets the hvac_target_temp input_slider when the thermostat 
### temperature is manually changed

  - alias: 'Set input_slider based on thermostat temperature'
    trigger:
      platform: state
      entity_id: climate.trane_model_tzemt400ab32maa_cooling_1_34_2
    condition:
      condition: template
      value_template: '{{ trigger.to_state.attributes.temperature != trigger.from_state.attributes.temperature }}'
    action:
      service: input_slider.select_value
      entity_id: input_slider.hvac_target_temp
      value_template:
        entity_id: >-
          {% if is_state('input_select.hvac_operation_mode', 'Heat') %}
             '{{ states.climate.trane_model_tzemt400ab32maa_heating_1_34_1.attributes.temperature }}'
          {% elif is_state('input_select.hvac_operation_mode', 'Cool') %}
             '{{ states.climate.trane_model_tzemt400ab32maa_cooling_1_34_2.attributes.temperature }}'
          {% endif %}


### Sets the thermostat fan_mode when the hvac_fan_mode input_select 
### is changed

  - alias: 'Set Thermostat Fan Mode'
    trigger:
      platform: state
      entity_id: input_select.hvac_fan_mode
    action:
      service: climate.set_fan_mode
      entity_id: climate.trane_model_tzemt400ab32maa_cooling_1_34_2
      data_template:
        fan_mode: >-
          {%- if is_state('input_select.hvac_fan_mode', 'Auto') -%}
              Auto Low
          {%- elif is_state('input_select.hvac_fan_mode', 'On') -%}
              On Low
          {%- endif -%}


### Sets the hvac_fan_mode input_select when the thermostat fan_mode is 
### manually changed


  - alias: 'Set input_select based on thermostat fan_mode'
    trigger:
      platform: state
      entity_id: climate.trane_model_tzemt400ab32maa_cooling_1_34_2
    condition:
      condition: template
      value_template: '{{ trigger.to_state.attributes.fan_mode != trigger.from_state.attributes.fan_mode }}'
    action:
      service: input_select.select_option
      entity_id: input_select.hvac_fan_mode
      data_template:
        option: >-
          {%- if is_state_attr('climate.trane_model_tzemt400ab32maa_cooling_1_34_2', 'fan_mode', 'Auto Low') -%}
              Auto
          {%- elif is_state_attr('climate.trane_model_tzemt400ab32maa_cooling_1_34_2', 'fan_mode', 'On Low') -%}
              On
          {%- endif -%}



### Sets the thermostat operation_mode when the hvac_operation_mode 
### input_select is changed

  - alias: 'Set Thermostat Operation Mode'
    trigger:
      platform: state
      entity_id: input_select.hvac_operation_mode
    action:
      service: climate.set_operation_mode
      entity_id: climate.trane_model_tzemt400ab32maa_cooling_1_34_2
      data_template:
        operation_mode: "{{ states('input_select.hvac_operation_mode') }}"



### Sets the hvac_operation_mode input_select when the thermostat 
### operation_mode is manually changed

  - alias: 'Set input_select based on thermostat operation_mode'
    trigger:
      platform: state
      entity_id: climate.trane_model_tzemt400ab32maa_cooling_1_34_2
    condition:
      condition: template
      value_template: '{{ trigger.to_state.attributes.operation_mode != trigger.from_state.attributes.operation_mode }}'
    action:
      service: input_select.select_option
      entity_id: input_select.hvac_operation_mode
      data_template:
        option: '{{ states.climate.trane_model_tzemt400ab32maa_cooling_1_34_2.attributes.operation_mode }}'

Most of it seems to work. It sets the default mode, the default temp, but I am seeing this error and I get the pop up about it being an invalid config:

16-12-29 19:13:16 homeassistant.bootstrap: Invalid config for [automation]: [value_template] is an invalid option for [automation]. Check: automation->action->0->value_template. (See ?:?). Please check the docs at https://home-assistant.io/components/automation/
16-12-29 19:13:19 homeassistant.helpers.condition: Error during template condition: UndefinedError: 'None' has no attribute 'attributes'
16-12-29 19:13:19 homeassistant.helpers.condition: Error during template condition: UndefinedError: 'None' has no attribute 'attributes'

It’s not reading back the values from the thermostat when changed at the thermostat. The three entities for my thermostat are listed in my first post. I had a few more errors than that to start, but I was able to run a few of them down, but cannot seem to get these last few taken care of and get the functionality. We do often change it manually at the thermostat instead of from the automation, so it would be a needed thing to get HA to update when it is changed that way.

Any help is much appreciated.

I thought I would perhaps bump this up for any fresh eyes on the scene.

From the error log, I get the impression it is trying to tell me that the ‘value_template’ line in the conditions won’t work, yet all the examples I have seen in the documentation, it is exactly where it needs to be. However, I reserve the right to be wrong as the documentation has bit me a time or two and I may not be understanding it all correctly.

I hate the format for conditions. Look at https://home-assistant.io/getting-started/automation-condition/ and see if that helps any

Thank you @turboc. I had looked there and on that page, one gets the impression that what I have is completely wrong. However, if you click on the link for the full list of available conditions, it has an example there for using a template condition which is exactly how I have it.

This has been my beef with the documentation. I LOVE the software but the documentation seems to contradict itself so you don’t know which is right or which one applies to your application.

At any rate, I will try a couple things following that information and see if it produces any fruit.

I’m right there with you on the documentation. I would submit updates to it if I could get to a point where I think even the results I get are consistent, but it’s still confusing. That’s one of the reasons I’ve been moving my automations over to AppDaemon since it uses python and programming in a language makes a lot more sense to me than YAML.

1 Like

Uggg, I wish I knew Python, I’d follow you. I have been meaning to install AppDaemon, but have not had a chance to look at the documents to see how to get that done.

So I tried this:

  - alias: 'Set input_slider based on thermostat temperature'
    trigger:
      platform: state
      entity_id: climate.trane_model_tzemt400ab32maa_cooling_1_34_2
    condition:
      condition: numeric_state
      conditions:
        - condition: template
          value_template: '{{ trigger.to_state.attributes.temperature != trigger.from_state.attributes.temperature }}'
    action:
      service: input_slider.select_value
      entity_id: input_slider.hvac_target_temp
      value_template:
        entity_id: >-
          {% if is_state('input_select.hvac_operation_mode', 'Heat') %}
             '{{ states.climate.trane_model_tzemt400ab32maa_heating_1_34_1.attributes.temperature }}'
          {% elif is_state('input_select.hvac_operation_mode', 'Cool') %}
             '{{ states.climate.trane_model_tzemt400ab32maa_cooling_1_34_2.attributes.temperature }}'
          {% endif %}

And it’s still barking at me with errors:

16-12-30 21:08:06 homeassistant.bootstrap: Invalid config for [automation]: [conditions] is an invalid option for [automation]. Check: automation->condition->0->conditions. (See ?:?). Please check the docs at https://home-assistant.io/components/automation/
16-12-30 21:08:06 homeassistant.bootstrap: Invalid config for [automation]: [conditions] is an invalid option for [automation]. Check: automation->condition->0->conditions. (See ?:?). Please check the docs at https://home-assistant.io/components/automation/
16-12-30 21:08:06 homeassistant.bootstrap: Invalid config for [automation]: [conditions] is an invalid option for [automation]. Check: automation->condition->0->conditions. (See ?:?). Please check the docs at https://home-assistant.io/components/automation/
16-12-30 21:08:06 homeassistant.bootstrap: Invalid config for [automation]: [value_template] is an invalid option for [automation]. Check: automation->action->0->value_template. (See ?:?). Please check the docs at https://home-assistant.io/components/automation/

I see the example you were referencing.

condition:
  condition: template
  value_template: '{{ states.device_tracker.iphone.attributes.battery > 50 }}'

so in your original code, trigger.to_state.attributes.temperature, trigger references back to the entity_id in trigger?

I’m reaching here.

Okay, I’ll have to work with my understanding of it from reading it. I found this example from another person that was using a ZWave thermostat in HA as well and got his working all nice and neat and I adopted his example to mine which basically just meant that I had to replace his entity id’s with mine.

That all said the:

trigger.to_state.attributes.temperature != trigger.from_state.attributes.temperature

is supposed to update HA when the thermostat is adjusted manually. That is, if I go physically to the thermostat and change the temperature, that bit is supposed to update the setting in HA. At least that is my understanding of it.

I did try the automation without those blocks (there are three total, one each for the temperature, the fan setting and the mode) and I can change the temp. from within HA but, of course, if it’s changed at the thermostat it is not reflected back to HA

I have not worked with templates so I am not very versed in them. The error in HA leads me to believe its not the template itself, but the fact I am using it within a condition. Unfortunately, I have absolutely no idea how else to go about accomplishing the same task. It seems pretty useless to be able to change settings from HA but not have HA update if they are changed at the thermostat.

I can always move the thermostat back to the Vera hub, but I am really trying to get away from that thing. I have my door locks and Linear garage door opener left on that hub. Everything else is in HA.

Read the manual carefully.

This is wrong:

action:
  service: input_slider.select_value
  entity_id: input_slider.hvac_target_temp
  value_template:
    entity_id: >-
      {% if is_state('input_select.hvac_operation_mode', 'Heat') %}
         '{{ states.climate.trane_model_tzemt400ab32maa_heating_1_34_1.attributes.temperature }}'
      {% elif is_state('input_select.hvac_operation_mode', 'Cool') %}
         '{{ states.climate.trane_model_tzemt400ab32maa_cooling_1_34_2.attributes.temperature }}'
      {% endif %}

You should use data_template, not value_template

action:
  service: input_slider.select_value
  entity_id: input_slider.hvac_target_temp
  data_template:
    value: >-
      {% if is_state('input_select.hvac_operation_mode', 'Heat') %}
         '{{ states.climate.trane_model_tzemt400ab32maa_heating_1_34_1.attributes.temperature }}'
      {% elif is_state('input_select.hvac_operation_mode', 'Cool') %}
         '{{ states.climate.trane_model_tzemt400ab32maa_cooling_1_34_2.attributes.temperature }}'
      {% endif %}
1 Like

Holy cow! I must have looked over that a hundred times and never caught that one was out of place, geeesh. I made the correction, and now the invalid config errors are gone. I am, however, getting this error:

16-12-31 06:07:44 homeassistant.helpers.condition: Error during template condition: UndefinedError: 'None' has no attribute 'attributes'
16-12-31 06:07:44 homeassistant.helpers.condition: Error during template condition: UndefinedError: 'None' has no attribute 'attributes'
16-12-31 06:07:44 homeassistant.helpers.condition: Error during template condition: UndefinedError: 'None' has no attribute 'attributes'

I am assuming that that is caused by the conditional statement:

condition:
condition: template
value_template: ‘{{ trigger.to_state.attributes.temperature != trigger.from_state.attributes.temperature }}’

Of which there are three. Temperature, Fan mode and Operational Mode (heat, cool, etc.). The input select and slider are setting their initial values correctly, so no issues there, but the input slider for the temperature does not pick up the current set point of the thermostat. I can change the slider up and down and it does now change the set point of the thermostat, but when I go and manually change the set point at the thermostat, nothing is being changed in HA.

Progress to be sure and I will keep looking at it. I have some ideas and will try them out. If successful I will post back here. Thanks everyone, so much, for the help so far. Very much appreciated.

Check the attribute tree for trigger. is temperature under to_state.attributes or somewhere else. It’s basically telling you that to_state is returning None and None doesn’t have an attributes value under it.

I remember looking for that and seeing it there, however, that was at the very start so I will check it again when I get home just to be sure I wasn’t looking at something else.

It’s all about the little steps, almost there, LOL

it gets better as you go on, and the error messages start to make more sense. I won’t say they totally make sense, but they start to make some sense. :slight_smile:

1 Like

So I am home, finally, another 11-hour shift in the books. I am not sure where you are asking me to look and I guess what I thought I saw before I, in fact, did not.

In the Developer Tool - Services, under Domain: Automation there is a Service: Trigger but that is all I see even remotely close to that.

In the entities list, if I click on the entity:

climate.trane_model_tzemt400ab32maa_heating_1_34_1

The State = Heat (obviously)

and the State Attributes are:

{
  "min_temp": 44.6,
  "fan_list": [
    "On Low",
    "Auto Low"
  ],
  "operation_mode": "Heat",
  "fan_mode": "Auto Low",
  "friendly_name": "Heating Set Point",
  "temperature": 73,
  "operation_list": [
    "Aux Heat",
    "Cool",
    "Heat",
    "Auto",
    "Off"
  ],
  "node_id": 34,
  "operating_state": [
    "Heating"
  ],
  "current_temperature": 72,
  "unit_of_measurement": "°F",
  "fan_state": "Idle",
  "max_temp": 95
}

I do not see anything anywhere else even remotely related to “to_state” or “from_state”. So I am not really sure, now, how to tell HA to differentiate between the slider set point from with in HA and the set point entered manually on the thermostat itself.

Okay, I think I made some progress in understanding where things are going wrong, but I am not sure what to do about it.

I tried using the HA template editor (didn’t previously know that was available, or that was what it was for I guess). You are correct @turboc, there is no to_state or a from_state. And, in fact when I put

{{ trigger.to_state.attributes.temperature != trigger.from_state.attributes.temperature }}

into the template editor it returns the very error I am seeing in the logs:

Error rendering template: UndefinedError: 'trigger' is undefined

So I started playing around, just to see if I could hit on, figure out, stumble into, the code that would return the temperature set point. After several iterations, I hit it:

{{ states.climate.trane_model_tzemt400ab32maa_heating_1_34_1.attributes.temperature }}

That returned the set point temperature whether I set it in HA or at the thermostat, it returned the correct set point value. S I then, to test out other values, tried:

{{ states.climate.trane_model_tzemt400ab32maa_heating_1_34_1.attributes.fan_mode }}
{{ states.climate.trane_model_tzemt400ab32maa_heating_1_34_1.attributes.operation_mode }}

Both returned the correct values. So that would seem to be the formatting to get the information. So the code:

value_template: '{{ trigger.to_state.attributes.temperature != trigger.from_state.attributes.temperature }}'

apparently needs to be changed but I am not sure how. How do I write that so that it is comparing the thermostat temperature set point, to the HA input slider temperature set point and updating HA if there is a difference?

This is the code that does the comparison:

  - alias: 'Set input_slider based on thermostat temperature'
    trigger:
      platform: state
      entity_id: climate.trane_model_tzemt400ab32maa_cooling_1_34_2
    condition:
      condition: template
      value_template: '{{ trigger.to_state.attributes.temperature != trigger.from_state.attributes.temperature }}'
    action:
      service: input_slider.select_value
      entity_id: input_slider.hvac_target_temp
      data_template:
        entity_id: >-
          {% if is_state('input_select.hvac_operation_mode', 'Heat') %}
             '{{ states.climate.trane_model_tzemt400ab32maa_heating_1_34_1.attributes.temperature }}'
          {% elif is_state('input_select.hvac_operation_mode', 'Cool') %}
             '{{ states.climate.trane_model_tzemt400ab32maa_cooling_1_34_2.attributes.temperature }}'
          {% endif %}

I ran the command:

sudo journalctl -fu home-assistant

So that I could watch the messages going back and forth. I then went to the thermostat and changed the temperature from 75* to 73* and I saw this come across:

Dec 31 19:45:55 HARPi3 hass[21176]: INFO:homeassistant.core:Bus:Handling <Event state_changed[L]: old_state=<state climate.trane_model_tzemt400ab32maa_heating_1_34_1=Heat; unit_of_measurement=°F, operating_state=(‘Heating’,), fan_mode=Auto Low, friendly_name=Heating Set Point, fan_list=[‘On Low’, ‘Auto Low’], max_temp=95.0, operation_list=[‘Aux Heat’, ‘Off’, ‘Cool’, ‘Heat’, ‘Auto’], fan_state=Idle, current_temperature=73.0, node_id=34, min_temp=44.6, operation_mode=Heat, temperature=75.0 @ 2016-12-31T19:42:34.956696-06:00>, new_state=<state climate.trane_model_tzemt400ab32maa_heating_1_34_1=Heat; unit_of_measurement=°F, operating_state=(‘Heating’,), fan_mode=Auto Low, friendly_name=Heating Set Point, fan_list=[‘On Low’, ‘Auto Low’], max_temp=95.0, operation_list=[‘Aux Heat’, ‘Off’, ‘Cool’, ‘Heat’, ‘Auto’], fan_state=Idle, current_temperature=73.0, node_id=34, min_temp=44.6, operation_mode=Heat, temperature=73.0 @ 2016-12-31T19:42:34.956696-06:00>, entity_id=climate.trane_model_tzemt400ab32maa_heating_1_34_1>

So the message is getting to HA and I can, in fact, see it update in HA, but, the input slider does not update.

That is where I currently stand. I kind of see the problem, I just have no idea how to fix it. How to get HA to update that input slider to reflect any manual changes at the thermostat itself.

I will also add that I tested the input select functions and they work perfectly. If I change from heat to cool at the thermostat, that gets near instantly reflected in HA. Same for the Fan Mode as well and I can change those in HA and they are reflected at the thermostat.

So the whole issue now is at the input slider temperature control.