Climate - Select temperature

Hi,

Currently trying to setup a thermostat with the “generic_thermostat”. Which is going well except one problem. I would like to change the comfort temperature dynamically to be 3deg above current temperature. So I can switch into comfort mode okay and set the target temperature okay using the following:

service: climate.set_temperature
data:
  temperature: "{{ state_attr('climate.under_floor_heating','current_temperature') + 3 }}"
target:
  entity_id: climate.under_floor_heating 

The problem comes if the current setpoint is higher than the new comfort temperature setpoint. This causes heating control to switch off… even though the target is still above the actual temperature by 3deg. I’m assuming this is bug.

So what I would like to do is the following logic:

IF current_temperature + 3 > target_temperature THEN
SET current_temperature +3
ELSE
SET target_temperature
ENDIF

But how… I tried

{% if (climate.under_floor_heating.attribute.current_temperature + 3) > climate.under_floor_heating.attribute.target_temperature %}
    "{{ climate.under_floor_heating.attribute.current_temperature + 3 }}"
{% else %}
    "{{ climate.under_floor_heating.attribute.target_temperature }}"
{% endif %}

And

{% if (state_attr('climate.under_floor_heating','current_temperature') + 3) > state_attr('climate.under_floor_heating','target_temperature') %}
    "{{ state_attr('climate.under_floor_heating','current_temperature') + 3 }}"
{% else %}
    "{{ state_attr('climate.under_floor_heating','target_temperature') }}"
{% endif %}

What am I doing wrong?

climate:
  - platform: generic_thermostat
    name: Under Floor Heating
    heater: switch.heating_underfloor_heating_control
    target_sensor: sensor.lumi_lumi_weather_temperature_2
    min_temp: 12
    max_temp: 36
    ac_mode: false
    target_temp: 17
    cold_tolerance: 1.0
    hot_tolerance: 0
    min_cycle_duration: 15
    keep_alive: 0
    initial_hvac_mode: "off"
    away_temp: 12
    comfort_temp: 21
    precision: 0.1
service: climate.set_temperature
data:
  temperature: |-
    {% set comfort = state_attr('climate.under_floor_heating', 'current_temperature') + 3 %}
    {% set target = state_attr('climate.under_floor_heating', 'temperature') %}
    {{ comfort if comfort > target else target }}
target:
  entity_id: climate.central_heating 

Thanks, that logic helps & leads to the next problem. I thought target temperature was exposed as an attribute, but it does not seem like it is?

Any ideas how to access that value another way? Its displayed in the UI so I assume it’s accessible some where?

It is, but it’s just called temperature… unless you are using the heat_cool mode which uses target_temp_high and target_temp_low.

Ah yeah you are right. I tried that but dismissed it as it was not giving me the value I was expecting.

Turns out that by the time the temperature action has happened the default comfort temperature preset had taken over and was giving me that value for temperature instead of the one I was expecting.

Moving the logic to a variable within the automation fixed the problem, as it gets the target value before the actions start to run.

Thanks for the help.

  - service: climate.set_temperature
    data:
      temperature: "{{ target_temp }}"
    target:
      entity_id: climate.under_floor_heating
variables:
  target_temp: >-
    {% set comfort = state_attr('climate.under_floor_heating',
    'current_temperature') + 3 %}

    {% set target = state_attr('climate.under_floor_heating', 'temperature') %} {{
    comfort if comfort > target else target }}