rianadon / timer-bar-card

A progress bar display for Home Assistant timers
Other
340 stars 15 forks source link

Duration: "script" does not work if UI language is not English #102

Closed bartkummel closed 4 months ago

bartkummel commented 10 months ago

Describe the bug As you properly describe in the documentation, the duration: script option relies on the name of the delay step in the script. This does not work if the language of the Home Assistant UI is set to something other than English. By searching through the code and some trial and error, I found out that it works if the delay step is named delay 0:00:30 for a delay of 30 seconds.

I think the least you should do is describe the format you expect, so we can manually rename our delay steps, even if we have a different language set.

Your card configuration

type: custom:timer-bar-card
name: Zet uit over 30 sec
entity: script.licht_uit_na_30_sec
duration:
  script: script.licht_uit_na_30_sec
tap_action:
  action: call-service
  service: script.licht_uit_na_30_sec
hold_action:
  action: more-info
mushroom: null

Debug information

State: on (state mode = active)
Mode: active (auto mode = N/A, unused)
Duration: 30 second
Time remaining: 23.892
Counter: 23.892
Attr: {"last_triggered":"2023-08-17T09:52:19.809589+00:00","mode":"single","current":1,"icon":"mdi:lightbulb-off","friendly_name":"Licht uit na 30 sec","last_action":"Do delay 0:00:30"}

Note that it works correctly now, since I've figured out the right format and manually renamed the delay step of the script.

rianadon commented 10 months ago

Thanks for the long investigation!

It would be a good idea to document the format the script option expects. It would furthermore be great to make the parsing work for all languages. The idea behind the script option is to parse the automatically generated delay step names so that the timer duration stays in sync with the script.

Is the format generally ..... 0:00:30?

bartkummel commented 10 months ago

In Dutch it says Vertraging voor 10:00. Note, though, that hours are stripped if they are zero and if it is below a minute, only the seconds will be shown:

All in all, parsing the title of the delay doesn't seem like the most reliable solution to me...

rianadon commented 4 months ago

All in all, parsing the title of the delay doesn't seem like the most reliable solution to me...

Unfortunately, it's the best I can do without writing a lot of code to query the Home Assistant API for this information. I'll stick a note in the README about the action name and change the parsing to only look for the time at the end.