Time-dependent target_sensors for generic_ thermostat

Folks, I am a noob to Hassio, running HassOS/Hassio (1.103.5) on a RPi2 (will upgrade soon, just a testbed).
As a replacement for my standard wall thermostat I am employing the climate.generic_thermostat platform, the target_sensor is defined as the min (platform: min_max) of three RTL_433 sensors received via the RTL4332MQTT-bridge add-on. Everything working fine so far the heater runs until the coldest room reaches the target temp. Simple.
What I would like to add is a way to use a different target_sensor early mornings and evenings (ie the min of only two of the three sensors). This to reflect that I usually leave a window open in the bedroom overnight.
Seems to me that a template sensor could be used, with a timer function in the value_template part? Or is there another way, eg putting the timer into the min_max platform?
I’d appreciate any guidance/ hints from you. Thanx in advance!
frankie

Take a look at this custom integration.

Interesting custom component. However, I don’t see how that will satisfy the request in the OP. It’s not the target temperature that needs to change throughout the day, but how the actual temperature is sensed, as I understand the request.

@frankiethehun, yes, this can certainly be done with a template sensor, which does seem like probably the easiest solution. Can you post the configuration of your min_max sensor and generic_thermostat?

I can see doing it one of two ways. Either make a second min_max sensor with just the two temperature sensors, and then have a template sensor (used for target_sensor of the thermostat) that outputs the value of one or the other min_max sensors depending on time of day. Or insert a template sensor “between” the min_max sensor and the one temperature sensor that you want to ignore for part of the day that either outputs the temperature sensor normally, or outputs a very large number instead when you want to ignore it (so that it doesn’t change the min output of the min_max sensor during that time frame.)

Took me some time to start tinkering with HA again. I have since revised my set-up and included an Aquara window sensor to detect the state of a bedroom window. So rather than making the target temp for the generic_thermostat time-dependent I now have the state of the window define whether the min of all rooms incl the bedroom is to be used, or whether the bedroom temp is excluded.
My sensor.yaml code for the min_ temp runs as follows:

  - platform: min_max
    name: temp_degc_min
    entity_ids:
      - sensor.temp_degc_ez
      - sensor.temp_degc_wz
      - sensor.temp_degc_sz
    type: min
    round_digits: 1
    
  - platform: min_max
    name: temp_degc_min_wz_ez
    entity_ids:
      - sensor.temp_degc_ez
      - sensor.temp_degc_wz
    type: min
    round_digits: 1  
    
  - platform: template
    sensors:
        temp_degc_target:
          value_template: >-
           {% if is_state('binary_sensor.0x00158d00039d11eb_contact', 'on') %} {{ states('sensor.temp_degc_min_wz_ez') }}
           {% else %} {{states('sensor.temp_degc_min')}} {% endif %}`

temp_degc_target is the sensor for the thermostat.
@pnbruckner, many thanx for confirming my hunch that a template_sensor should be utilized; also gave me second thoughts re the time dependency vs. checking a state.
Works like a charm.

1 Like