How can I get the time show right in the moment the washing machine start and stored

Hi, I have a washing machine with a sensor that show the reaming time in minutes. I want to make a progress bar in my dashboard and I think I’m in the correct way why but I do not how to get the total time.

I’m using (time pass/ total time)*100 to get the percentage.

How can I get the time show right in the moment the washing machine start and stored? If I use the sensor obviously the time will be decreasing and I need the first data, if at the moment of start show 250 minutes I need to store the 250 and use it later. I think that should be easy right? Maybe and automation and an input text?

Thanks in advance

When the washing machine starts (how do you know it? some kind of power monitoring sensor?) → then store the time in the helper. The “time pass” will be “current time” minus “start time”.

1 Like

The washing machine have a sensor that shows if is running or finished. Can I do something with this?


What do you mean? Is it already integrated into Home Assistant? Do you have HA’s entity (representing the sensor’s value)?

Yes is integrated in HA with the Candy custom integration from HACS

The device show 3 sensors.

The first one shows if is washing, drying…
The second one if is running, finished
And the third one the remaining time in minutes.

I just need to know the remaining time at the exact right moment the washing start. That will be the 100% off the remaining time.
I want to display a card with a custom progress bar.
Will be correct with an automation an stored in an input text?

As an example: if when the washing machine start shows 240 minutes I need that total. Then in the card (remaining time/total time) *100 get the current % and use that value as a width of a bar in a custom button card

Sth. like this might work:

  - platform: template
        friendly_name: "Washing Machine Time Elapsed Percentage"
        unit_of_measurement: '%'
        value_template: >
          {% if states('sensor.washing_machine_time_remaining') != 'unknown' and states('sensor.washing_machine_time_remaining') | int > 0 %}
            {% set total_time = states('sensor.washing_machine_time_total') | int %}
            {% set remaining_time = states('sensor.washing_machine_time_remaining') | int %}
            {{ ((total_time - remaining_time) / total_time * 100) | round(2) }}
          {% else %}
          {% endif %}
  - alias: "Update Washing Machine Time Elapsed Percentage"
      - platform: time_pattern
        minutes: '/1'
      - condition: state
        entity_id: binary_sensor.washing_machine
        state: 'on'
      - service: homeassistant.update_entity
        entity_id: sensor.washing_machine_time_elapsed_percentage
  - alias: "Set Washing Machine Total Time"
      - platform: state
        entity_id: binary_sensor.washing_machine
        to: 'on'
      - service: input_number.set_value
          entity_id: input_number.washing_machine_time_total
          value: "{{ states('sensor.washing_machine_time_remaining') | int }}"

I ‘ll give it a try thanks :blush:

Just to note, this is the old, legacy format for template sensors. You should avoid using it for newly configured entries. It is ok for old sensors, but if you setup a new one, you should use the new format. :slight_smile: Gives a lot more possibilities! :+1:

The new template format gives room for trigger-based sensors, so you could avoid the very agressive time pattern. I mean, this is running 24/7, so more than 98.8% of the time the trigger fires for…nothing! :laughing:

You could use the sensor of the washing machine to trigger an update of the template sensor.

Uff, that’s way better, thanks!