Fire an event when both conditions are met

Hi all,

I’ve tried my best to search the forums for an answer to this, but half the issue is I can’t really figure out the right search terms.

I have a z-wave smart plug that is functioning properly and I have manual control via the HA interface. I want to use this plug to make a smart charging system that stops my phone and laptop batteries from sitting for long periods at 100% charge before I come along and unplug them (e.g overnight).

As this plug provides sensor info about power use, I would like to have an automation whereby when I plug my devices in and turn on the smart plug I get 1 hour of charging that won’t be interrupted regardless of the power usage, but after this 1 hour if the power usage goes below 5W (i.e. everything plugged into it is fully or close to fully charged), then turn off the smart plug.

The only way I can think to do this is with 2 boolean operators, and multiple automations, but as I started to build that I thought there must be a simpler way. Can any of you crafty experts please point me in the right direction for how to build this within preferably just the one automation?