Graphing time spend in different input_select states

I’ve started using an input_select as a presence state (home, away, sleep). I’d like to graph how much time is spent in those states (like hours per day sleeping) - any pointers? The history-graph shows it switching between the different options, but it shows all of them. What if I want different graphs for the different states? (Or compare this week to the last N weeks)

Thanks in advance.

Then you would have to make binary template sensors to track each option.