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

[Feature request] Enhancing bar-card capability of managing 'time format'

Open liuk4friends opened this issue 4 years ago • 1 comments

Bar-card works flawlessy with 'history_stats' but, as you probably know, 'history_stats' reports time in a strange way. If I'm not wrong, 'history_stats' reports minutes in a decimal way. For instance, when 'history_stats' reports '1.91h', the correct time format should be '01:54' (one hour and fifty-four minutes)

So, we are forced to use a template for converting '1.91h' to a more readable format, ie '01h 54m'.

An example below:

  - platform: template
    sensors:
      luca_time_at_home_readable:
        friendly_name: "Luca tempo in casa (leggibile)"
        entity_id: sensor.luca_time_at_home
        value_template: "{{ state_attr('sensor.luca_time_at_home', 'value')}}"

If I configure 'bar-card' with this template, the result is that 'bar-card' doesn't show the correct amount of the bar itself. I mean that the bar is always ‘full’ and doesn’t show any kind of progression. If I choose a color, it is always ‘fully colored’. I'm attaching two screenshot because "a picture is worth more than a thousand words"

Here bar-card works perfectly ... Screeny Shot 9 Aug 2020 at 22 18 31

Here it doesn’t work... Screeny Shot 9 Aug 2020 at 22 18 57

So, I wonder if in the future 'bar-card' will be able to handle the 'standard time format' correctly. I would like to stress that your custom-card is superb! Thank you in advance, Luca

liuk4friends avatar Aug 09 '20 20:08 liuk4friends

+1 on this. I was trying just now to implement a custom bar chart to see how much time I've been siting at my computer using history_stats and ran into this issue :(

Another simpler way to do it would be letting the user choose what it displays on the Value field so we could use template strings directly there!

kauelima avatar Dec 20 '22 15:12 kauelima