Use a template to feed boolean value into a configuration variable

I am using the generic_thermostat integration to control duct boosters installed in my home. I have created an automation that will intelligently control the boosters depending whether or not the following conditions are met:

  1. The desired room is calling for heating/cooling.
  2. The main HVAC handler is running.

This works great except for one quality-of-life issue I am experiencing with the generic_thermostat integration. This integration only permits one operation mode, that is - heat, or cool. And you cannot toggle between them in the UI. You may only turn the system on or off and set your desired temperature. This is configured using the ac_mode: true/false variable within configuration.yaml. As such, I will have to manually change my configuration for all rooms in my home as the seasons change. Not to mention, during seasonal changes (such as winter → spring) I may have to modify my configuration multiple times in a month or two since during these times, my thermostat is switching between heating or cooling often.

To try and resolve my issue, I created a single-line template to parse the state of the heating system into a true or false string. Then, I figured I could put this template into my configuration in place of the “true” or “false” ac_mode variable. But that doesn’t work. I get an invalid key error when reloading my configuration.

For reference, here is the thermostat config:

- platform: generic_thermostat
  unique_id: bcthermoroom
  name: Bradyn's Room
  target_sensor: sensor.bradyns_room_th_temperature
  heater: input_boolean.climate_call_bradyn_s_room
  ac_mode: {{ states('sensor.house_thermostat_mode') }}

And here is the error I get when checking config:

Error loading /config/configuration.yaml: invalid key: "{"states('sensor.house_thermostat_mode')": None}"
  in "/config/thermostats.yaml", line 6, column 0

Very few configuration options support templating. If they do it is explicitly stated in the documentation for the option.

Screenshot 2023-04-19 at 09-58-20 Generic Thermostat

(from another integration)
Screenshot 2023-04-19 at 09-58-46 Template Switch

Generally only keys under target:, service: and data: in automations and services can be templated.

There is a custom dual mode generic thermostat that may suit your needs better:

I’ve never used it so can not comment on it.

Thanks for the help! I am going to try out this integration!