Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Wymaga stworzenia grupy domowników
- group.awesome_people = moja nazwa grupy domowników ( nazwa do edycji/podmiany)
- Grupę można stworzyć za pomocą HA > ustawienia > "Pomocnicy"
- person1
- person2
- ...
- #################################################
- W template.yaml
- #################################################
- - sensor:
- name: Kto w domu
- unique_id: kto_w_domu
- state: >
- {%- set people = expand('group.awesome_people') %}
- {{ people | selectattr('state', 'in', ['home', 'on'] ) | list | count }}
- icon: >
- {%- set icons = ['account-off', 'account', 'account-multiple'] %}
- {%- set people = expand('group.awesome_people') %}
- {%- set cnt = people | selectattr('state', 'in', ['home', 'on'] ) | list | count %}
- {%- if cnt >= 0 %}
- mdi:{{ icons[cnt] if cnt in range(icons | count) else 'account-group' }}
- {%- else %}
- mdi:account-alert
- {%- endif %}
- attributes:
- template: "template"
- osoby: >
- {%- set people = expand('group.awesome_people') | selectattr('state', 'eq', 'home') | map(attribute='name') | list %}
- {%- set company = expand('group.awesome_people') | selectattr('state', 'eq', 'on') | map(attribute='name') | list %}
- {%- set people = people + company %}
- {{ people }}
- A_i_B: >
- {%- set people = expand('group.awesome_people') | selectattr('state', 'eq', 'home') | map(attribute='name') | list %}
- {%- set company = expand('group.awesome_people') | selectattr('state', 'eq', 'on') | map(attribute='name') | list %}
- {%- set people = people + company %}
- {%- if people | count > 0 %}
- {{- [people[:-1] | join(', '), 'i', people[-1]] | join(' ') if people | count > 1 else people[0] }}
- {%- else %}unknown
- {%- endif %}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement