Skip to content

Instantly share code, notes, and snippets.

@nediam
Last active June 9, 2020 08:07
Show Gist options
  • Select an option

  • Save nediam/6d7a8cb4f1253c247a9697191f6f3e41 to your computer and use it in GitHub Desktop.

Select an option

Save nediam/6d7a8cb4f1253c247a9697191f6f3e41 to your computer and use it in GitHub Desktop.
{% set days_translation = ["Poniedziałek","Wtorek","Środa","Czwartek","Piątek", "Sobota","Niedziela"] %}
{% set trash_translation = {"rest": "Zmieszane","glass": "Szkło","paper": "Papier","plastic": "Plastik","bio": "Bio","green": "Zielone","bulk": "Gabaryty"} %}
{% set trash = states('sensor.trash')|from_json %}
{% for item in trash %}
{%- set date = trash[item] -%}
{%- set days_to = (((as_timestamp(strptime(date, '%Y-%m-%d'))-as_timestamp(now()))/86400))|round(0,'ceil')-%} **{{ trash_translation[item] }}:** {{ days_to }} dni *({{ days_translation[strptime(date, '%Y-%m-%d').weekday()] }})*
{% endfor %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment