hansen-hasst/packages/laundry/timer.yaml
2023-07-15 01:04:33 +02:00

30 lines
915 B
YAML

timer:
laundry:
#duration: "03:20:00"
sensor:
- platform: template
sensors:
laundry_remaining:
friendly_name: "Laundry Remaining"
value_template: >
{% set f = state_attr('timer.laundry', 'finishes_at') %}
{{ '00:00:00' if f == None else
(as_datetime(f) - now()).total_seconds() | timestamp_custom('%H:%M:%S', false) }}
template:
- trigger:
- platform: state
entity_id:
- timer.laundry
attribute: remaining
sensor:
# Keep track how many days have past since a date
- name: laundry_remaining
state: >
{% set f = state_attr('timer.laundry', 'finishes_at') %}
{% set res = '00:00:00' %}
{% if f != None %}
{{ (as_datetime(f) - now()).total_seconds() | timestamp_custom('%H:%M:%S', false) }}
{% else %}
{{ res }}
{% endif %}