hansen-hasst/packages/laundry/timer.yaml

30 lines
915 B
YAML
Raw Permalink Normal View History

2022-12-28 16:54:28 +00:00
timer:
laundry:
2023-07-14 23:04:33 +00:00
#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 %}