AUTOMATION: To turn off device if it was turned on outside home assistant

Hi all,
What is a proper way to set this up?

To give a bit of context:
I have this Tuya switch, which for some reason turns on completely on its own every morning at 6am. Have no idea why. I installed it 3 days ago and yesterday it did that at 6:00:08 AM and today at 6:00:05 AM. So it is unlikely a coincidence. It does it only at 6am, despite there are no automations set in Tuya, SmartLife, nor HA.

I’m sure I’ll be able to sort it out, either by factory-reset, or by replacing the device. However, what I’m interested in is to have some kind of fail-safe automation for the future and to figure out automation that will:

When:
Always

If:
Any device got activated from outside HA. Meaning, it has not been activated by HA user or automation.

Then:
Turn off this device

Have any of you have something like this running?

1 Like