Determine if device was turned on/off by user or system

I am going to see if I can implement it, and will report back how it goes. Also found this The order of cards executed in flows which essentially tries to solve the same thing.