Advertisement
JLindvig

Garbage

Feb 7th, 2020
417
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 1.96 KB | None | 0 0
  1. sensor:
  2.   - platform: template
  3.     sensors:
  4.       affald_hentes:
  5.         friendly_name: "Affald:"
  6.         value_template: >-
  7.           {% if states('sensor.affald') <= states('sensor.affald_sommer') %}
  8.             {% set days = state_attr('sensor.affald', 'days') %}
  9.             {% set next_date = state_attr('sensor.affald', 'next_date') %}
  10.           {%- else -%}
  11.             {% set days = state_attr('sensor.affald_sommer', 'days') %}
  12.             {% set next_date = state_attr('sensor.affald_sommer', 'next_date') %}
  13.           {%- endif -%}
  14.  
  15.           {% if days == 0 %}
  16.             i dag
  17.           {%- elif days == 1 %}
  18.             i morgen
  19.           {%- else -%}
  20.             {% set time_stamp = as_timestamp(next_date | regex_replace(":[0-9][0-9][0-9].*$","")) %}
  21.               om {{ ((time_stamp - as_timestamp(now())) / ( 60 * 60 * 24 )) | round(0, 'ceil') }} dage (
  22.             {{- states("var.weekdays_dk").split(",")[time_stamp | timestamp_custom('%w') | int - 1] }}dag den {{ time_stamp | timestamp_custom('%-d.') }}
  23.    {{ states("var.months_dk").split(",")[time_stamp | timestamp_custom('%-m') | int - 1] }})
  24.           {%- endif -%}
  25.  
  26.       genbrug_hentes:
  27.         friendly_name: "Genbrug:"
  28.         value_template: >-
  29.           {% set days = state_attr('sensor.genbrug', 'days') %}
  30.           {% set next_date = state_attr('sensor.genbrug', 'next_date') %}
  31.  
  32.           {% if days == 0 %}
  33.             i dag
  34.           {%- elif days == 1 %}
  35.             i morgen
  36.           {%- else -%}
  37.             {% set time_stamp = as_timestamp(next_date | regex_replace(":[0-9][0-9][0-9].*$","")) %}
  38.             om {{ ((time_stamp - as_timestamp(now())) / ( 60 * 60 * 24 )) | round(0, 'ceil') }} dage (
  39.             {{- states("var.weekdays_dk").split(",")[time_stamp | timestamp_custom('%w') | int - 1] }}dag den {{ time_stamp | timestamp_custom('%-d.') }}
  40.    {{ states("var.months_dk").split(",")[time_stamp | timestamp_custom('%-m') | int - 1] }})
  41.           {%- endif -%}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement