timer-bar-card
timer-bar-card copied to clipboard
Miele Washing Machine - Active_State = Idle
I'd originally raised a query under the closed previous issue for a Miele washing machine integration.
I've been playing around with the template and with the help of GPT can can get it to calculate and format.
- start time
- end time
- duration (total between start and finish)
- duration (current time since start)
- remaining time but i can't seem to get the card to detect that the timer should be active. I've tried mapping the status "running" using the active_state variable, but that doesn't seem to work.
I've even got it to try and do some maths to check if the end time falls on the following day, i think this sort of works, but produces some interesting results considering that the start date is constantly checked and updated based on current date. so i'll see if i can get this to be consistent tomorrow.
Template:
name: "Washing Machine Timer v2"
state: "{{ states('sensor.washing_machine_status') }}"
attributes:
start_time: "{{ now().strftime('%Y-%m-%dT') + states('sensor.washing_machine_started_at') }}:00"
end_time: "{% set start_time = as_timestamp(now().strftime('%Y-%m-%dT') + states('sensor.washing_machine_started_at') + ':00') %}{% set end_time = as_timestamp(now().strftime('%Y-%m-%dT') + states('sensor.washing_machine_finish_at') + ':00') %}{% if end_time < start_time %}{% set end_time = end_time + 86400 %}{% endif %}{{ end_time | timestamp_custom('%Y-%m-%dT%H:%M:%S') }}"
duration(total): "{% set start_time = as_timestamp(now().strftime('%Y-%m-%dT') + states('sensor.washing_machine_started_at') + ':00') %}{% set end_time = as_timestamp(now().strftime('%Y-%m-%dT') + states('sensor.washing_machine_finish_at') + ':00') %}{% if end_time < start_time %}{% set end_time = end_time + 86400 %}{% endif %}{% set duration_seconds = end_time - start_time %}{% set duration_hours = duration_seconds // 3600 %}{% set duration_minutes = (duration_seconds % 3600) // 60 %}{% set duration_seconds = duration_seconds % 60 %}{{ '%02d:%02d:%02d' | format(duration_hours, duration_minutes, duration_seconds) }}"
duration(to now): "{% set start_time = as_timestamp(now().strftime('%Y-%m-%dT') + states('sensor.washing_machine_started_at') + ':00') %}{% set end_time = as_timestamp(now().strftime('%Y-%m-%dT') + states('sensor.washing_machine_finish_at') + ':00') %}{% if end_time < start_time %}{% set end_time = end_time + 86400 %}{% endif %}{% set remaining_time = states('sensor.washing_machine_remaining_time') | int %}{% set duration_seconds = end_time - start_time - remaining_time * 60 %}{% set duration_hours = duration_seconds // 3600 %}{% set duration_minutes = (duration_seconds % 3600) // 60 %}{% set duration_seconds = duration_seconds % 60 %}{{ '%02d:%02d:%02d' | format(duration_hours, duration_minutes, duration_seconds) }}"
remain_time: "{% set total_minutes = states('sensor.washing_machine_remaining_time') | int %}{% set hours = total_minutes // 60 %}{% set minutes = total_minutes % 60 %}{% set seconds = 0 %}{{ '%02d:%02d:%02d' | format(hours, minutes, seconds) }}"
which returns (noting that with the start, end and remain and status, it shouldn't need the duration.
name: "Washing Machine Timer v2"
state: "running"
attributes:
start_time: "2024-04-29T22:35:00"
end_time: "2024-04-30T01:07:00"
duration(total): "02:32:00"
duration(to now): "01:31:00"
remain_time: "01:01:00"
for the card i'm using
type: custom:timer-bar-card
entity: sensor.washing_machine_timer_2
name: Washing Machine
active_state:
- Running
- running
debug: true
guess_mode: false
sync_issues: ignore
But the output gets stuck stating that it's idle, even when active state has been defined as "running" and it can see that the state is "running"
note sure if this is an issue with the template or with the card, or both?