Power consumption based on state

So I’ve got a kill-a-watt and some smart devices, that got me thinking:

I know how much power some devices use when on, and when off (assume 0 for the moment).

Is there a decent way to take the boolean status of a light, air conditioner, space heater, etc, and the wattage when operational to keep track of power consumption? It could be interesting to take some of the data i’m inherently collecting.

Anyone do something like this before and have some ideas on implementing?

That’s just perfect. Spot on.

Thanks!