My Samsung washer and dryer only show completion time and no remaining time.
I found how to get this data and successfully tested in dev tools template:
Now, my stupid problem is that I have no clue how to add this correctly in the sensors.yaml, the syntax…
This was how I tried but isn’t right:
> #Template for washer and dryer
> - platform: template
> sensors:
> remainingtime_laveuse:
> value_template: {% set ct = states('sensor.laveuse_washer_completion_time') | as_datetime %}
> {{ '00:00' if now() > ct else (ct - now()).total_seconds() | timestamp_custom('%H:%M', false) }}
Thanks in advance
rossk
March 29, 2023, 3:40pm
2
Wrong formatting at a guess:
template:
- sensor:
- name: your sensors name
state: >
{% set ct = states('sensor.laveuse_washer_completion_time') | as_datetime %}
{{ '00:00' if now() > ct else (ct - now()).total_seconds() | timestamp_custom('%H:%M', false) }}
Example can be found here:
EDiT: adding missing colon from “state: >”
Still is not valid when trying to add this in my sensors.yaml…
template:
- sensor:
- name: Laveuse temps restant
state >
{% set ct = states('sensor.laveuse_washer_completion_time') | as_datetime %}
{{ '00:00' if now() > ct else (ct - now()).total_seconds() | timestamp_custom('%H:%M', false) }}
123
(Taras)
March 29, 2023, 4:12pm
4
You’re adding it to the wrong place.
If you have the following line in configuration.yaml
template: !include templates.yaml
then the suggested example goes in templates.yaml
but without including the first line containing template:
If you do not have that line in configuration.yaml
, then put the suggested example directly in configuration.yaml
.
ok tried adding this directly in configuration.yaml (I don’t have the templates.yaml link) but HA showing me this error:
My lines in configuration.yaml:
123
(Taras)
March 29, 2023, 4:31pm
6
The error message says it was expecting to find a colon but it was missing.
You’re missing a colon here:
state >
Change it to this:
state: >
Thank you so much for this it works!
Very sorry, I always mess up in yaml syntax when I need to jump back in it after months…