timer-bar-card icon indicating copy to clipboard operation
timer-bar-card copied to clipboard

Trouble setting time properties for progress bar

Open FLpilot opened this issue 1 year ago • 7 comments

Hello,

I am using the GE appliances integration for a washer and dryer, and having a bit of trouble getting the card to correctly show a progress bar for time remaining.

In that integration, there is a laundry time remaining sensor with the time remaining set as the state. It's a format of 1:14 for 1 hour and 14 minutes left, or 0:20 for 20 minutes left, and seems to update every minute, and does not show seconds.

In the card, I've set as shown in example 4 of the configuration of time properties in the readme. duration: state: true debug: true

When I do that, I get a message of: "Could not convert duration: 1:14 is not of format 0:10:00. If you are passing in a number, specify the units property.".

So I've referenced example 2 (duration isn't in 0:10:00 format) and example 1 (attribute that looks like a duration) and tried variations of that code, but get errors such as "Expected duration 1:14 to be a number since units is minutes".

I'm a novice at coding and such, so looking to see if someone could help with what I would need to write in order to get a 0:32, 1:05, etc. state value to work for a progress bar.

Thank you.

FLpilot avatar Jun 25 '23 21:06 FLpilot

Thank you for the great write-up! However like you've concluded, the card will not support a duration in the 1:14 format.

That's because most integrations use the 1:14:00 format for expressing time durations, so I haven't had to deal with this format before. I'm also not entirely sure how to proceed, because if the card is given a timestamp like 1:14, it's ambiguous whether it's 1 hour 14 minutes or 1 minute 14 seconds. That would require some extra configuration.

Do you have a link to the integration's source code? I'd like to take a peak and see if the lack of seconds in the duration is a limitation of the integration or a limitation of the washer (which may only report the time in minutes-resolution).

My only solution to you is to write a template. However, templates are a pain to deal with and so if you haven't made one before, I suggest instead waiting until I can figure out a solution to this.

I've been realizing some integrations just don't give you data in seconds-resolution (which sucks for a card that tries to show you the number of seconds left), and aside from the new resolution: minutes configuration option I haven't figured out yet how to deal with these integrations. So hopefully once I figure out a solution to that problem I'll also have a fix for your washer.

rianadon avatar Jun 26 '23 07:06 rianadon

Hello,

The integration I am using is: https://github.com/simbaja/ha_gehome.

I was able to eventually get it to work via trial and error and some YAML assistance from Chat GPT.

Here is what I did:

In the configuration.yaml file, I added this:

sensor:
  - platform: template
    sensors:
      washer_time_formatted:
        friendly_name: "Washer Time Formatted"
        value_template: "{{ states('sensor.gv323127n_laundry_time_remaining') + ':00' }}"
        icon_template: "mdi:clock"

I believe that just takes the H:MM value and adds :00 for the seconds to use the correct time format for the progress bar.

Then in the card configuration I did this:

type: custom:timer-bar-card
entities:
  - entity: sensor.gv323127n_laundry_machine_state
    name: Washer
active_state: Run
duration:
  entity: sensor.washer_time_formatted
  state: true
  invert: true

So far, the progress bar seems to be working as it should as I'm running a wash, but I will check to see what happens when it reaches 0.

Thanks for the help.

EDIT - Progress bar doesn't seem to work correctly. Seems to start out correctly and work for awhile, but will disappear and show "Run" instead of time remaining at some point. I will continue to troubleshoot. I have noticed that if the progress bar disappears, and I restart Home Assistant, the progress bar will reappear for the time remaining, but will eventually disappear again.

FLpilot avatar Jun 27 '23 17:06 FLpilot

Congrats on setting up the template! We do love Chat GPT despite it being wrong sometimes :) The template and configuration look like they should work perfectly to me, so seeing that the bar still doesn't work correctly makes me sad.

Would you mind adding debug:true and posting a screenshot of what the card looks like when the progress bar disappears?

Also just a nitpick on the card configuration you posted: since you specified entity for duration, you don't need state. That's because entity always pulls from the other entity's state (I don't have entity working in combination with attribute yet, although that would be cool).

Also, I assume it's an error with the pasting but invert: true should not be indented.

rianadon avatar Jun 29 '23 00:06 rianadon

Hello,

Apologies for the delay - been out of town.

Doing some more troubleshooting, and this is what I see from the washer after letting it run:

Screenshot washer

So something seems to be off with the counter and duration, as the time remaining is showing 15:43, but the duration in the debug code is showing 1920 seconds (32:00) which matches the time shown on the washing machine. It seems when the countdown gets to zero, the progress bar disappears but there is still a duration:

Washer 2

I am going to do some more troubleshooting, as perhaps when then washer is changing cycles (wash, spin, etc.), something is changing with the timing. I'll update once I do some more checking.

I also corrected the state and invert code as you mentioned - thank you.

FLpilot avatar Jul 08 '23 16:07 FLpilot

I'm running into this problem as well. It works fine when the Washing cycle first starts and the sate mode = active, but for some reason it changes to idle even though the state is in "Run". Any ideas on how to capture only the "Run" part and not the "idle"?

chelupa avatar Jun 10 '24 20:06 chelupa

If this is still what the debug mode shows when the state changes to "Run" image then the issue is that the time remaining becomes negative. Even if the card modes are set up correctly, the state will be "idle" anytime the remaining time goes under zero.

I assume what must be happening is that when the duration is updating whenever a new cycle starts, but because the "sensor.gv323127n_laundry_machine_state" entity is always "Run" during the entire time the washing machine is on, the card isn't recognizing that a new cycle is starting.

Is there any entity that shows you what cycle the machine is in? Really, anything that updates every cycle would work for the card. If such a thing existed then you could use:

type: custom:timer-bar-card
entities:
  - entity: sensor.gv323127n_laundry_machine_cycle
    name: Washer
active_state:
  - Wash
  - Dry
duration:
  entity: sensor.washer_time_formatted
  state: true
  invert: true

which should work better.

rianadon avatar Jun 10 '24 22:06 rianadon

There is a sensor.gt340478n_laundry_sub_cycle where it has Rinse and Spin. I'll try it out! Thanks!

chelupa avatar Jun 10 '24 22:06 chelupa