Skip to content

Instantly share code, notes, and snippets.

@chpego
Created May 28, 2021 19:16
Show Gist options
  • Save chpego/7020e104b63456eac694ba7f8599eaf8 to your computer and use it in GitHub Desktop.
Save chpego/7020e104b63456eac694ba7f8599eaf8 to your computer and use it in GitHub Desktop.
{% set mystates = states|selectattr('entity_id', 'in', state_attr('light.all', 'entity_id')) |selectattr('state', 'equalto', 'on') | list %}
{% set names = mystates | map(attribute='name') | list %}
{% set times = mystates | map(attribute='last_updated') | list %}
{% for i in range(mystates | length) %}
{{ names[i] }} depuis ( {{ as_timestamp(times[i])|timestamp_custom("%Hh:%M") }} ),
{%- endfor %}
@chpego
Copy link
Author

chpego commented May 29, 2021

Une version pour voir, depuis combien de temps les lumières ont changés d'état !

{% set mystates = states|selectattr('entity_id', 'in', state_attr('light.all', 'entity_id')) |selectattr('state', 'equalto', 'on') | list %}
{% set names = mystates | map(attribute='name') | list %}
{% set times = mystates | map(attribute='last_changed') | list %}
{% for i in range(mystates | length) %}
{{ names[i] }} depuis {{ relative_time(times[i]) }},
{%- endfor %}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment