Access template sensor through entity card

Hey,

I’m using a mushroom template card with this code to show open windows.

{{ states.binary_sensor|selectattr('name','contains','Offen')|selectattr('state','equalto','on')|list|length }}

This works and I want to use this in ha. Therefor I add the following into the configuration.yml

template:
  - sensor:
      - name: "Anzahl Fenster Gekippt"
        state: >
          {% set gekippt = states.binary_sensor|selectattr('name','contains','Gekippt')|selectattr('state','equalto','on')|list|length %}
          {{ (gekippt) }}
      - name: "Anzahl Fenster Offen"
        state: >
          {% set gekippt = states.binary_sensor|selectattr('name','contains','Gekippt')|selectattr('state','equalto','on')|list|length %}
          {% set offen = states.binary_sensor|selectattr('name','contains','Offen')|selectattr('state','equalto','on')|list|length %}
          {{ (offen - gekippt) }}

There are no errors, but I cant’t access the two sensor with a entity card.

What I’m doing wrong?

If you mean the dialog box, give Our sensors a unique id:


  - sensor:
      - unique_id: '202309181523'
        name: "Anzahl Fenster Gekippt"

or


  - sensor:
      - unique_id: 'anzahl_fenster_gekippt'
        name: "Anzahl Fenster Gekippt"

Thanks! It works. But I had also the restart HA and not only reload the yaml.