# Licznik otwarcia drzwi

**URL:** <https://forum.arturhome.pl/t/licznik-otwarcia-drzwi/357>\
**Category:** Konfiguracja HA\
**Tags:** template, history\_stats, device\_class\
**Created:** [29 Sierpień 2020 21:22 UTC](https://forum.arturhome.pl/t/licznik-otwarcia-drzwi/357 "2020-08-29T21:22:26Z")\
**Posts on this page:** 1\
**Showing post:** 11

<div class="post-metadata">

**Autor:** ![macek](https://forum.arturhome.pl/user_avatar/forum.arturhome.pl/macek/32/1647_2.png) [@macek](https://forum.arturhome.pl/u/macek)\
**Data wpisu:** [30 Sierpień 2020 14:29 UTC](https://forum.arturhome.pl/t/licznik-otwarcia-drzwi/357/11 "2020-08-30T14:29:37Z")

</div>

Ja korzystam z `group`:

```auto
group:
  doors:
    name: Doors
    icon: mdi:door
    entities:
      - binary_sensor.0x00158d00053fac0e_contact
      - binary_sensor.0x00158d00045ca805_contact

```

a potem `sensor` do tego:

```auto
sensor:
  - platform: template
    sensors:
      open_door_count:
        value_template: {{expand('group.doors') | selectattr ('state','eq','on') | list | count }}
        icon_template: >
          {% if states.group.doors.state == 'off' %}
            mdi:door-closed
          {% elif states.group.doors.state == 'on' %}
            mdi:door-open
          {% else %}
            mdi:help
          {% endif %}

```

ale niestety to nie działa poprawnie - `sensor.open_door_count` powinien mieć wartość `2`

![Capture](https://forum.arturhome.pl/uploads/default/original/1X/6eae3f9773ff413f327d6c827eababe5646baac5.png)

Natomiast w menu Developer Tools -\> TEMPLATE wszystko działa poprawnie.  
Jest bug w HA dotyczący tego (w kolejności):

> <https://github.com/home-assistant/core/issues/35872>
>
> The problem
> A recent PR modified how the expand function is handled in Template Sensors but the new functionality does not appear...

  

> <https://github.com/home-assistant/core/pull/37766>

  

> <https://github.com/home-assistant/core/issues/38909>
>
> The problem
> According to PR 37766, and this post by bdraco, a listener will be assigned to each light entity:
> {{ states.light |...

  
i otwarty issues:

> <https://github.com/home-assistant/core/issues/22587>
>
> Tracking issue for architecture#208
> Implement the algorithm
> update helpers/template.py with the new algorithm. Done #23283
> update helpers/event.py to use the new algorithm....

---

_[View the full topic](https://forum.arturhome.pl/t/licznik-otwarcia-drzwi/357)._
