Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty progress bar with remain_time #96

Open
jd1 opened this issue Jul 14, 2023 · 5 comments
Open

Empty progress bar with remain_time #96

jd1 opened this issue Jul 14, 2023 · 5 comments

Comments

@jd1
Copy link

jd1 commented Jul 14, 2023

Describe the bug
I tried to show the remaining charging time of my car, but the progress bar doesn't show any progress. It's always empty. Only the remaining time is updated.

Your card configuration

type: custom:timer-bar-card
entity: switch.tmbjc7ny6nf049498_charging
remain_time:
  entity: sensor.tmbjc7ny6nf049498_charging_time_left
  units: minutes
debug: true

Debug information

State: on (state mode = active)
Mode: active (auto mode = N/A, unused)
Duration: second
Time remaining: 10800
Counter: 10800
Attr: {"last_result":"N/A","last_timestamp":"1970-01-01T00:00:00","model":"Škoda Enyaq 80 iV 80/2022-05-31","icon":"mdi:battery-outline","friendly_name":"TMBJC7NY6NF049498 Charging"}

switch.tmbjc7ny6nf049498_charging automatically updates its state to 'on' if the car starts charging. This is recognized by the card. It's visible and the states changes in the debug information.
sensor.tmbjc7ny6nf049498_charging_time_left contains the remaining time in minutes. One problem of this entity is that it only updates every 5 minutes, but this shouldn't break the card.

I don't why the progress bar is not updating. According to the docs it should be enough to set Remaining Time + Active State and active state is detected correctly.

I got it working with a template sensor:

  - name: End of charging
    device_class: timestamp
    state: "{{ now() + timedelta(minutes=states('sensor.tmbjc7ny6nf049498_charging_time_left')|int) }}"

With this I can use end_time and the card is working as expected:

type: custom:timer-bar-card
entity: switch.tmbjc7ny6nf049498_charging
end_time:
  entity: sensor.end_of_charging
name: verbleibende Zeit
debug: true
@jd1
Copy link
Author

jd1 commented Jul 21, 2023

I created a small test setup to have a look at all values:
Screenshot 2023-07-14 at 12 32 27

  • The first row is the card with remain_time. It does not update at all. It always shows the same value. Only when you refresh the page, a new value is loaded.
  • The second row uses the template entity. It works.
  • The third row is the sensor with the remaining charging time: sensor.tmbjc7ny6nf049498_charging_time_left As mentioned above, it only updates every 5 minutes, but it updates.
  • The fourth row is the template sensor. Since sensor.tmbjc7ny6nf049498_charging_time_left updates every 5 minutes, the value of the template sensor jumps a little bit.

@schumi2004
Copy link

Hi @jd1 ,

Thanks for your tip on the template_sensor ;)

It seems this sensor also works for my issue: #93

@rianadon
Copy link
Owner

rianadon commented Nov 6, 2023

Sorry it's taken so long for me to reply. The v1.28 update back in June should have made the remain_time option more reliable when used with other entities.

Are you using this version or the latest version, or is this still an issue with the card?

@jd1
Copy link
Author

jd1 commented Nov 8, 2023

Thanks for the reply. I'm using version 1.29.1.

As you can see in the screenshots, the calculation of duration is not correct. Maybe remain_time wasn't taken into account for one of the calculations. I dug a little bit into the code and tried a fix in findDuration. It didn't work, but it was just a quick attempt without understanding the full context.

@rianadon
Copy link
Owner

Well, I guess those updates didn't fix whatever the problem may be here.

My guess is/was that the card is not re-rendering every time the entity changes. Since you're already digging into the code, try adding a console.log and see if it fires every second (or every minute, or however often that time left entity updates). The shouldUpdate function is what's responsible for deciding whether the card needs to re-render (and in doing so grab new information from Home Assistant).

That remain_time is difficult to test as no built-in components in Home Assistant use that scheme. Thus, I've also written no tests for it. The template is always going to be more reliable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants