Is this the best way to add a template sensor into a group of input_booleans?

I have added a template sensor to a group with an input_boolean entity. It behaves like a usual group of input_booleans (e.g. if any member goes “on” the group is “on” and the group only goes “off” if all members go “off”). The way I’m currently doing this is like so:

should_boost_erv:
  entities:
    - sensor.inside_air_wetter_than_outside
    - input_boolean.co2_is_high

sensor:
  - platform: template
    sensors:
      inside_air_wetter_than_outside:
        friendly_name: "inside air is wetter than outside air"
        value_template: '{% if states.sensor.abs_hum_indoor.state | float > states.sensor.abs_hum_outdoor.state | float -%}on{%- else -%}off{%- endif %}'

It seems like it’s working, but I was hoping to mix True / False with ‘on’ and ‘off’ but it doesn’t look like this is possible.

If I’ve read your post correctly, the value template is a sensor and not a binary_sensor type. If you change that, it will probably work and you can use true/false as well.

Oh! Is it as simple as moving my template sensor out of ‘sensor’ and into ‘binary_sensor’ in my configuration? Then leaving it as true/false and not the ‘on’/‘off’ strings that I have now?

Guess so. You probably only need to prefix sensor: with binary_

binary_sensor:
  - platform: template
    sensors:
      inside_air_wetter_than_outside:
        friendly_name: "inside air is wetter than outside air"
        value_template: '{% if states.sensor.abs_hum_indoor.state | float > states.sensor.abs_hum_outdoor.state | float -%}on{%- else -%}off{%- endif %}'

are you just trying to make a sensor that tells you when to boost your erv? There are ways to get what you want. This for example is a template sensor that would work with your current template sensors:

sensor:
  - platform: template
    sensors:
      should_boost_erv:
        {{ states | selectattr('entity_id', 'in', state_attr('group.should_boost_erv','entity_id')) | selectattr('state', 'eq','on') | list | length >= 1 }}

This searches all state objects in your group entity list. If it finds any that have the state ‘on’ it returns it in the list. If the list is greater than or equal to 1 item, then you should boost your erv.

That worked. Thanks!

Interesting. To clarify, I have two triggers for boosting the ERV. One is high CO2 level, and the other is inside air being more humid than outside air (when in cooling mode). So I do want the group to be “on” if any reason for boosting the ERV is “on.” This works as long as any entity I put into the group is compatible with the others.

well you can modify this line to give you what you want with multiple states by changing the last selectattr from ‘eq’ ‘on’ to ‘in’ [‘a’,‘b’]. for example, i want to see when lights are and and someones home inside a group that i made. The code would look like this:

sensor:
  - platform: template
    sensors:
      should_boost_erv:
        {{ states | selectattr('entity_id', 'in', state_attr('group.should_boost_erv','entity_id')) | selectattr('state', 'in',['on','home']) | list | length >= 1 }}