History data for a 7day history stacked bar chart

I have been playing around with HomeAssistant for about a month now and its really impressive.
But there is one thing I would like to do that I just cannot figure out how to do or if its possible to do.

Background:
In our house we have a rule that our son is only allowed to play games on the computer for one hour a day. All his games are on steam so using HA i built a steam game sensor and use the history graph (see pic).

Using this I can see how long he has played and what game when hovering over. I would like to expand on this and here I have run into a brick wall.
I would like to have a rolling 7 day stacked bar graph showing how much he has played per day and what game.

I think the main problem is that I need a sensor that records the time played per game. In HA logic I think that would be the time the sensor is in a state.
I looked at the History Stats sensor (https://www.home-assistant.io/integrations/history_stats/) but as I understand it you need to define the states that you want to measure time on. That would require me to manually add all games he has and need to edit the sensor every time he gets a new game and I don’t like static systems. Is there a way to record a sensor state and time in the state? Like the standard history graph is doing?
What I have read leads me to believe that if I have data in that format grafana can make the stacked bar chart anyone know if that is correct?

TLDR: I want a 7day history stacked bar chart of time played per game, how do I do that?

below pic is an example of the type of stacked bar chart i mean.

also looking for this!

Hi i looked into it and made something simalr for my energy consumption with peak and offpeak
i hope you have HACS on your hassio server
Install min-card-graph from HACS

make a manual card with this code:

> type: 'custom:mini-graph-card'
> name: Energy consumption
> bar_spacing: 2
> decimals: 3
> group_by: date
> height: 200
> hours_to_show: 168
> icon: 'mdi:flash'
> unit: kWh
> entities:
>   - entity: sensor.monthly_energy_peak
>     name: Peak
>     aggregate_func: max
>     color: orange
>   - entity: sensor.monthly_energy_offpeak
>     name: Offpeak
>     aggregate_func: max
>     color: 'rgb(52, 152, 219)'
> show:
>   labels: false
>   graph: bar
>   hour24: true
>   extrema: false
>   average: false

more info on

2 Likes

Awsome!
I have been bussy with life latly so missed your reply. Your solution looks promising and I will take a look this weekend and see if I cant applay it to my problem.

Thanks man!

1 Like

do you know if there is any way to show the value on each bar?

in my research no i dont think o, hovering over it is possible and shows it then on top
ask the devs of the addon for an implementation :wink:

Hi Matthi,

Two quick follow-up questions:
(1) does this stack the bars?
(2) what happens when either value is negative?

Thing is that I want to show the prodution of my solat panels split up in (1) how much was used in the home and (2) how much was sent back to the grid. On dark days it could be that I consume from the grid rather than send back to it, so this value may be negative.

Thomas

I would be also very interested to have the bar stacked !

Sorry to resurrect this thread but have you found by any chance how to stack the bars?

Still looking to stack the bars

This sounds awesome,

I also have my energy usage seperated by appliance. Each appliance has a off-peak, on-peak and solar consumption sensor. Do you know if it’s possible to create a graph like this?