I created this EnergyMeterRoutine SmartApp to provide a simple integration of A/V equipment and ST Routine to adjust lighting. I have a URC brand remote that provides both IR and RF control over A/V equipment in the Home Theater and wasn’t interested in the Harmony Hub solution, its issues, or cost.
I used an Aeon Smart Energry Switch to monitor power consumption of the equipment, in my case the front projector. Also made a minor change to the device type to change reporting from default (5 minutes) to every 5 seconds. This way the lighting scene is triggered within seconds, not minutes. The routine is only triggered once each time the power threshold is crossed.
Code and examples were leveraged from the Laundry Monitor app and ST power monitor apps.
@jcholpuch I think this is exactly what i was looking for. I would like to trigger some action when i take my phone of the charger in the morning. You think your smartapp would work for this? Also wich Energy Meter would you recommend?
The key to this app is you only want to trigger once when you cross above/below the power threshold.
Rule Machine also has a lot of features now, it might be able to trigger a rule based on power consumption and a virtual switch to save the previous state.
My use case works well because the projector uses 200+ Watts of power so I can set the trigger/threshold to 100 Watts. Your phone will use about 5W when charging and the power consumption will drop after phone is charged to 100%. It might be difficult to detect phone changed vs. phone unplugged.
FYI, I use the Aeon switch above and it does not draw any power when the phone is charged (at least not enough to register). It uses about 5W when charging. I initially wanted to use the same setup that you are seeking, but it doesnt work for that reason.