Template Sensor to combine existing sensors

Tags: #<Tag:0x00007f73aaf55210> #<Tag:0x00007f73aaf54d38> #<Tag:0x00007f73aaf54a90>

I want to make a script that will check the open windows and call the tts to say open window locations.
The idea I came is to make a template sensor and then vocalize it’s state :slight_smile:
But I’m having some troubles with templates. Separetaly the values work great, but the sensors state is Unknown.

  - platform: template
    sensors:
      open_windows:
        friendly_name: "Open windows"
        value_template: >-
          {% if is_state('binary_sensor.0x00158d00040c243c_contact', 'on') %}
            Home office
          {%- endif %}
          {%- if is_state('binary_sensor.0x00158d00042453d7_contact', 'on') -%}
            , Kitchen
          {%- endif -%}
          {%- if is_state('binary_sensor.0x00158d00045086c4_contact', 'on') -%}
            , Bed Room
          {%- endif -%}
          {%- if is_state('binary_sensor.0x00158d00040c2427_contact', 'on') -%}
            , Teracce
          {% endif %}

I asked a very similar question at almost the same time:

https://community.home-assistant.io/t/how-to-get-device-class-window-sensors-in-a-template-expression/208216/7

Does that help?