Stop automation from running if power socket has been turned on

Hi Everyone,

I have an automation that triggers a Shelly S20 socket everyday @ 8AM to power up a coffee machine and get me a fresh cup of coffee but sometimes I have to trigger it manually earlier and when it happens I need to remember to turn it off after 8AM because the automation will trigger anyway. What I wanted is to find a way for the automation to detect if the power socket has been turned on earlier and do nothing. I’ve tried a condition before but it didn’t worked as expected…also, I thought about creating a dummy boolean sensor to determine if the power socket has been turned on or off but it seems a bit of an overkill…

Do you guys have any idea that you can share?

Have a state condition requiring the switch to have been off for X hours?

One way to solve this would be to check if the switch has been on in the past X amount of hours.

Use a state condition.

Well it appear Tinkerer was faster than me.

I think the state condition as it’s mentioned in the documentation isn’t possible to configure in Lovelace, right, due to the “for” that doesn’t appear. The closest one is as shown in the printscreen,.sonoffcofee

You can still edit the YAML manually there, using the three dot menu

Yes, I’ll give a try. Still wandering if my approach will work though. I’ll perform some tests and keep this up to date.

Just to provide an update. The “device” condition also works. I’ll close this thread.

Thanks everybody for your help.