Can't get template binary sensor to work

I’ve got a template sensor (which works):

sensor:
  - platform: template
    sensors: 
      main_floor_hvac_action:
        friendly_name: "Main Floor HVAC Action"
        value_template: "{{ state_attr('climate.main_floor', 'hvac_action') }}"

So I created a template binary sensor to simply check when my template sensor has the state of “cooling”

binary_sensor:
  - platform: template
    sensors:
      main_floor_hvac_cooling:
        entity_id: "sensor.main_floor_hvac_action"
        friendly_name: "Main Floor HVAC Cooling"
        value_template: >-
          {{ is_state_attr('sensor.main_floor_hvac_action', 'cooling') }}

But the binary sensor is always off. I can query the sensor and see that the state shows “cooling” but the binary sensor just doesn’t see it.

Any ideas?

1 Like

change
is_state_attr
To
is_state

State_attr is used when you want to check an attribute of an entity, however you just want to check the state of the entity. Check the docs here for more info.

2 Likes

Thank you so much! I can’t believe I missed that…I was going absolutely nuts.