Dynamic target_sensor in thermostat

Hi
Given the following sensors that detect the temperature:
sensor.living_room_temperature
sensor.chamber_temperature
sesnor.kitchen_temperature

and the following generic_thermostat

  - platform: generic_thermostat
    name: Riscaldamento termosifoni
    heater: switch.rele_caldaia
    target_sensor: input_select.my_selection
    min_temp: 15
    max_temp: 30

Is it possible to have a dynamic target_sensor, assigning it with an input_select where the sensors are those listed above?

No that is not possible.

Create an input select helper with your temperature entity ids and use its state as described in the former topic.


input_select:

  thermostat_target:
    name: Thermostat Target
    options:
      - sensor.one_temperature
      - sensor.two_temperature
      - sensor.three_temperature

You cant use that in the generic thermostat configuration. Unless I am mistaken.

I tested it and it is working. What are your concerns?

My concern was that the entity would be set when home assistant loaded the integration at start up and would then be unable to be changed during runtime.

Might be a caveat*, don’t know. But this is a bit different to ‘is not possible’.

P.S.: *in regard to the use in automations. But then I would use a start delay.

I solved this with a input select and a template sensor.
the input select is used to select what sensor the thermostat will use (Internal room, floor sensor or external HUE-sensor)

sensor: 
  - platform: template
    sensors:
      bedroom1_climate_control_sensor:
        value_template: >-
          {% if is_state('input_select.bedroom1_climate_control_sensor','Gulvføler') %}
            {{ states('sensor.bedroom1_thermostat_floor_tempeature')|float(18) }}
          {% elif is_state('input_select.bedroom1_climate_control_sensor','Romføler') %}
            {{ states('sensor.bedroom1_thermostat_room_tempeature')|float(15) }}
          {% elif is_state('input_select.bedroom1_climate_control_sensor','HUE-sensor') %}
            {{ states('sensor.pir_bedroom1_temperature_15m')|float(15) }}
          {% else %}'N/A'
          {% endif %}
climate:
  - platform: generic_thermostat
    name: "Soverom1"
    heater: input_boolean.bedroom1_heating
    target_sensor: sensor.bedroom1_climate_control_sensor
    target_temp_step: 0.5
    max_temp: 20
    min_temp: 15
    hot_tolerance: 0.5
    cold_tolerance: 0.5
    comfort_temp: 18
    activity_temp: 18
    home_temp: 18
    sleep_temp: 18
    away_temp: 18
2 Likes

I don’t know how to handle different float defaults, otherwise you can shorten it a bit:


template:
  - sensor:
      - name: Thermostat Target
        unique_id: thermostat_target_202211232124
        icon: mdi:fire
        state: |-
          {% set target = states('input_select.thermostat_target') %}
          {{ states(target)|float(22) }}

Or prettified:


input_select:
  thermostat_target_prettified:
    name: Thermostat Target
    options:
      - Loggia
      - Eingang
      - Küche


template:
  - sensor:
      - name: Thermostat Target prettified
        unique_id: thermostat_target_prettified_202211232124
        icon: mdi:fire
        state: |-
          {% set target = states('input_select.thermostat_target_prettified')
          |replace('Loggia', 'sensor.loggia_temperature')
          |replace('Eingang', 'sensor.eingang_temperature')
          |replace('Küche', 'sensor.kuche_temperature')
          %}
          {{ states(target)|float(22) }}



2 Likes

Thank you all, you have been very kind.
I adopted Pedolsky’s “prettified” solution but I’m sure Froschi’s solution would have been fine too
Thanks again