Flags/states in automations

Hi Aqara users!

I would like to share my workaround of adding flags to the Aqara app to track different states of my home

Examples from my real live:

  1. I have a smart master switch which turns off all the light in the home. But, if I left my dog at home - the whole light should be turned of except the light near the front door. So I need to set a flag “pet_at_home” and use this flag as a condition in automations

  2. when I have guests, some my automations should be disabled. I don’t want to manually enable and disable them, I want just to set a flag “guests” and add this flag to the required automations as a condition

Solution - use automations as a flags

  1. Create always disabled automation, let’s call it “always_disabled”. The trigger and action can be any as the automation is always disabled

  2. Create a “flag” automation with name “guest_at_home”. The trigger can be any (timer), the action - “disable always_disabled automation” - so actually nothing will happen

But now we can enable and disable “guest_at_home” automation and use this state as a flag

You can create as many as you need such flags - they will have the same action - disable the first automation, but each of them could represent some state

Other examples of my flag:

  1. “someone_at_home” - use HomeKit automation to enable/disable the flag when the first person arrived or the last left

  2. “without_presence” - condition in all automations based on presence (fp300). Sometimes I need to disable such devices by one single click

2 Likes

Thanks for the sharing, but I don’t understand if you don’t need to trigger anything then why do you need an “always_disabled” automation?

You cannot create an automation without action, so you need some safe action which do nothing

From my opinion, the best option is disabling always disabled automation as action

Another way is add impossible condition to IF-part of the flag-automation, but what if it happened…

1 Like

Hello, did I understand correctly, you are talking about these virtual switches? Automation 2.0, lesson 12, blitz topic, VIRTUAL Aqara switch

Your ‘hack’ is not interestingly different than any of the other ways described to achieve the same thing (shared variables/flags to use in another automation).

The point is we should not need to do this. @AqaraOfficial should just recognise this need and add variables and counters (which is what these hacks do).

Hello, yes, I also made an Aqara request to add a virtual switch.