Use template sensor to increment Thermostat

I’m building a Thermostat interface using Floorplan.

I had to create this template in order to get the value of the target temperate . sensor.ground temp is the value the thermostat is set too.

- platform: template
  sensors:
    ground_temp:
      friendly_name: "Ground Therm"
      value_template: "{{ state_attr('climate.thermostat', 'temperature') }}"
      unit_of_measurement: "°F"

I’m trying to use a button to increment the setting up 1 degree.

If I just use an integer, it works, like this.

- element: set_temp_down
   entity: climate.thermostat
   tap_action:
     - service: climate.set_temperature
       service_data:
         temperature: 78

I want to be able to increment it up or down from its current value so I use sensor.ground_temp

When I try the value string in the developer tools templates, the value works so not sure what I’m missing in the code below.

- element: set_temp_up
   entity: climate.thermostat
   tap_action:
     - service: climate.set_temperature
       service_data:
         temperature: '{{ states("sensor.ground_temp") |float + 1 }}'

The error I get is:
Failed to call service climate/set_temperature. expected float for dictionary value @ data[‘temperature’]

this is what my interface looks like.

You can’t use templates in most card actions, even many card types that allow templates for other aspects often don’t allow them in actions.

Instead create a script that contains the templated logic and climate.set_temperature service, then set the card action to call the script

1 Like

thanks I’ll research. I’m fairly new to HA and have never created a script.

They’re just like automations without trigger or condition blocks. Basically just the action section (though it is called “sequence”) that you can run manually.

Even the syntax for automation actions is called “script syntax”:

I got the example script to run and send the message however my sequence to change my value doesn’t seem to do anything. I ran it use the developer->services.

This is in my log:
Referenced entities sensor.ground_temp are missing or not currently available

not sure why it says missing as I can read its value?

message_temperature:
    sequence:
      # This is Home Assistant Script Syntax
      - service: notify.notify
        data:
          message: "Current temperature is {{ states('sensor.ground_temp') }}"

adjust_temp_up:
    sequence:
      - service: climate.set_temperature
        target:
          entity_id: sensor.ground_temp
        data:
          temperature: '{{ states("sensor.ground_temp") |float + 1 }}'

You are trying to call a climate service on a sensor instead of a climate entity… based on your original post, the target of the service should be climate.thermostat.

ok, this worked

adjust_temp_up:
    sequence:
      - service: climate.set_temperature
        target:
          entity_id: climate.thermostat
        data:
          temperature: '{{ states("sensor.ground_temp") |float + 1 }}'

A climate entity is for controlling a heating/cooling device. It’s designed for setting the target temperature. That’s why there are service calls available for a climate entity (to set mode/temperature/etc).

In contrast, a sensor entity is for reporting a value, typically some property of a device. There are no service calls for sensor entities and you can’t use a climate entity’s service calls for a sensor entity (like what you had originally attempted to do).

Your latest attempt is more correct. You’re setting the climate entity’s target temperature to the sensor entity’s value.

Be advised that when you use the float filter, you should provide it with a default value. If you don’t, and the sensor’s value is ever non-numeric (like unavailable), the float filter will fail (thereby causing your script to fail with an error message). For example, if you want a default of 70 then specify it like this:

float(70)

go it, thanks for the explanation.