I have a Samsung washing machine and from that, i get a sensor telling me when the machine is done. How can I create a template sensor show me how many minutes is left until its done? Today I get a sensor showing UTC time, state is 2020-10-08T15:59:37.332Z and I made a sensor show the time in local and removed date and second (state. 17:59)
I would like to have that to show on my tablet in natural text like “The washing machine is ready in 34 minutes, at 17:59”
#sensor:
- platform: template
sensors:
washing_machine:
friendly_name: Washing Machine
value_template: >
{% if is_state('switch.tvattmaskin', 'on') %}
{% set t = as_timestamp(states.sensor.tvattmaskin_washer_completion_time.state) %}
{% set end = t | timestamp_custom("%H:%M") %}
{% set duration = ((t - now().timestamp())/60) | round(0) %}
Washing machine is done in {{duration}} minutes at {{end}}.
{% else %}
Washing machine is off.
{% endif %}
It may need further enhancement to prevent reporting negative values if switch.tvattmaskin continues to indicate on even when the washing cycle is finished. If that happens then the message could say something like “Washing machine finished X minutes ago at YY:ZZ”. Or something like that; I don’t know how your washing machine reports all aspects of its operation via those two entities.