Calculate time online - InfluxDB 1.8

I am logging if my PC and TV is on to a InfluxDB 1.8. I want to determine the total time the PC is on for and display it in a bar graph.

Online/Offline	time	device
1	12:00	pc
1	12:00	tv
1	12:08	pc
1	12:08	tv
1	12:10	pc
1	12:16	tv
1	12:17	pc
1	12:20	tv
1	12:22	pc
1	12:25	tv
1	12:25	pc
1	12:30	tv
1	12:34	pc
1	12:35	tv
1	12:35	pc
1	12:40	tv
1	12:40	pc
1	12:45	tv
1	12:45	pc
0	12:53	tv
0	12:53	pc
0	12:55	tv
0	12:55	pc
1	13:04	tv
1	13:03	pc
1	13:05	tv
1	13:05	pc
1	13:10	tv
1	13:10	pc
1	13:15	tv
1	13:15	pc
1	13:20	tv
1	13:20	pc
0	13:26	tv
1	13:29	pc
0	13:30	tv
1	13:30	pc
0	13:33	tv
1	13:35	pc
1	13:40	tv
0	13:43	pc
1	13:45	tv
0	13:45	pc
1	13:50	tv
0	13:50	pc
0	13:57	pc
1	14:00	pc
1	14:05	pc
1	14:10	pc
1	14:15	pc

@johans

In InfluxQL, have you tried using the elapsed() function? You would have to separate out the PC and TV tags (or whatever they are), but that should be straightforward.