Convert dataset of discrete changes

16 Views Asked by At

Hopefully I'm posting this in the correct community.

I'm trying to get my head around this issue. I've got a discrete dataset containing only 'changes'. It will only record a change of state at a particular time. In the table below the state was 0 for the whole time period between 19:33:14 and 20:18:20. At 20:18:20 it was 1 until 20:19:31 etcetera. Is there any mathematical / numerical way to get a dataset with timestamps (separated by X seconds) vs the amount of time that it was in that state?

I want to transform this dataset into Grafana graphs to observe some energy usages at home.

Timestamp State
19:33:14 0
20:18:20 1
20:19:31 0
20:20:00 1
20:20:13 0

edit: Is is possible in some non-numerical way to obtain the values

Timestamp Value
20:20:00 1
20:20:01 1
20:20:02 1
20:20:03 1
20:20:04 1
20:20:05 1
20:20:06 1
20:20:07 1
20:20:08 1
20:20:09 1
20:20:10 1
20:20:11 1
20:20:12 1
20:20:13 0