Aqara switch state changes, but Matter lights sometimes do not follow automation

Hi Aqara community,

I’m having an intermittent issue with an Aqara switch and Aqara Home automation.

Setup:

  • Hub: Aqara Hub M3
  • Switch: Aqara Toilet Switch, about one concrete wall away from the Hub M3
  • Automation is shown as Local
  • Automation logic:
    • WHEN switch turns ON → turn ON lights
    • WHEN switch turns OFF → turn OFF lights
  • Target devices are 3rd-party Matter devices , not Aqara Zigbee lights:
    • Toilet Light1
    • Toilet Light2
    • Toilet LED

Issue:
Sometimes when I press the switch, the switch state updates correctly in Aqara Home, for example it changes to OFF, but the lights stay ON. So it seems the switch event is received, but the automation action to the Matter lights does not always complete.

The Zigbee signal for the switch looks mostly excellent in the Aqara app. I also attached screenshots of the Zigbee signal and automation setup.

Questions:

  1. Is this a known issue when Aqara automation controls 3rd-party Matter devices?
  2. Does “Local” automation fully support Matter device actions through Hub M3?
  3. Is there any command retry mechanism if a Matter light does not respond?
  4. Would adding delay between each light action improve reliability?
  5. Any recommended setup to make switch → automation → Matter lights more reliable?

Thanks.

1 Like

Hi.

“Aqara Toilet Switch”? That must be a brand new Aqara product! :rofl:

Jokes aside, to get a better idea of the situation, could you share which exact switch model you are using? Is it a wired wall switch, like the Smart Wall Switch H1?

Also, just to clarify, when you say “the switch state changes”, do you mean that you physically press the switch? Or do you mean that you see the correct state update in the Aqara app, even when the lights fail to respond?

I’d also love to know more about your setup in general. How are the Matter lights physically connected to the switch? Are they connected directly to the load line of this switch, or do they receive constant power from another source?

By the way, have you heard of or are you currently using the “Change to wireless switch” feature (often called decoupled mode) in the switch’s settings? If you don’t necessarily have to switch a physical “dumb” load alongside the smart lights, this might be an interesting option for your setup.

Yes, there have definitely been reports that the current status of Matter devices is displayed incorrectly in the Aqara app. I’ve noticed this myself when I turn Matter power outlets on and off very quickly in succession.

That’s also the reason why I set up my automations so that clicking the switch simply sends a toggle command to the light. Or, like with my H2 switch, it just sends a “brighter” or “darker” command to the light, making the actual state irrelevant.

That’s definitely how it should be.

I don’t think so, but you could just tweak your automation to send the “off” or “on” command once, and then again after a short delay.

I unfortunately don’t know for sure, but you could just give it a try. Simply add one or more delays under “Action” in your automation and see if it helps.

Yes, if possible, you should avoid relying on “reading” the current state in your automations, as the state always has to be queried first, or the last received state is read from a cache or memory.

So, if possible, it’s better to set it up like this:
a) Trigger: Switch is pressed (depending on the switch or mode)
b) Action: Turn on/off (instead of just Turn on or Turn off)

This means that you only need one automation instead of two.

2 Likes

In my experience sometimes Aqara hub issues a command (like “turn off”) to the Matter over WiFi devices, but it sometimes fails. And weirdly enough, sometimes it’s related to the automation/what triggers the action.

I had this problem with my custom Matter over WiFi dimmer and an P1 motion sensor, I thought the problem was how I implemented the firmware for the dimmer, but when I manually controlled the device, it worked almost every time correctly. What is strange, that when I changed the automation trigger from the P1 to the FP2, it started working flawlessly.

I have a hub M3 if you’re interested.

So I think in your case you can add a delay and duplicate “turn off” to make sure it works (sort of a “retry” mechanism)

1 Like

Haha yes, “Aqara Toilet Switch” is not a new secret Aqara product — that was just my very “professional” naming style. :joy:

Thanks a lot for the detailed explanation. That helps me understand the logic better.

To clarify my setup:

  • Switch model: Aqara D1 single gang with neutral
  • I physically press the switch.
  • The switch state then changes correctly in the Aqara app.
  • However, sometimes the lights do not follow the automation.
  • The lights are 3rd-party Matter devices.
  • The lights receive constant power from another source.
  • There is no load wire between this switch and the lights.

I have seen the “Change to wireless switch” / decoupled mode option before, but because there is no physical wire between the switch and the lights, I didn’t really understand how it would apply in my case. From what you explained, I think I may have misunderstood the purpose of decoupled mode.

Also, yes, I noticed that when I turn the Aqara switch on/off quickly, the automation sometimes does not seem to trigger properly.

About using “Turn on/off” instead of separate “Turn on” and “Turn off” actions: I avoided it before because I was trying to keep the switch state matching the light state. For example, switch ON = lights ON, switch OFF = lights OFF.

But now I think maybe I should remove this “requirement” from my mind, because the light state can also be changed by other sources such as Siri, PIR sensor, or other automations. So the physical switch state may not always represent the actual light state anyway.

This is my first time doing a DIY smart home automation setup, so I’m still learning the best practice. Could you share more about how you set up your automation in a similar case, where smart lights can be controlled by a smart switch but also by other sources?

Thanks again for the help. Your explanation is very useful.

1 Like

Hi, since you described the operation of the switch, I assume you have cloud automation. Check that.

1 Like

You’ve already got some good advice here. Funnily enough I’ve been building something somewhat similar over the last week. I have also used 3rd party lights (Nanoleaf Essentials Matter over Thread Bulbs/Globes), an Aqara M3 hub and, in my case, an Aqara H2 EU Switch which can work with, or without, Neutral.

That last aspect was really important to me, as I have an older UK home and it is often the case that Neutral does not go to the light switch.

The room does have an FP2 sensor in it, but it is a huge room, and the señor is at the top of the stairs into the room, which is the attic. The thinking here being you want the lights on when you walk up, not when you’ve got to the top (Safety).

We also use the attic as a place for visitors to stay when more than just a couple, and I try to make areas that visitors use to be as “normal person” (i.e. not smart home person) friendly as possible.

So, what I did.

Added the Lights to the M3 over Matter (Shared from Apple Home). Grouped the lights inside Aqara’s UI… which ultimately was pointless as teh automation doesn’t enable you to use groups.

Added the H2 Switch in Zigbee mode and then decoupled. Because I do not have a neutral, this is a must otherwise turning off the switch would disconnect the power and so the lights would become unavailable in Apple Home and the Aqara M3.

Added automations as, for some reason, Aqara doesn’t let you use Matter lights directly from the device.

I have one automation.

IF Top Button or Bottom Button is pressed THEN turn on/off the lights.

So far, they’ve worked just fine all the time except when one light was briefly not available over Thread.

I’d not really worry about rapid pressing of the button, as that doesn’t happen in real life. If the lights don’t come on, just pressing the button again should make it work. (The usual Microsoft “ctrl-alt-del/ Turn it on/off again” style solution).

M3 switch and lights are quite a distance from my M3, and still have a good signal. With the lights, I have quite an extensive Thread network so the Thread mesh helps. I have very little in Zigbee (Basically only when forced), but still good.

I’m actually going to write this all up in more detail for my blog, and will cross-post it here. Having said that, I hope what I posted helps you.

3 Likes

Not that this helps anyone here I though I’s mention it.

I’ve been bugging Aqara to implement proper light groups like home assistant does in that once a group is created it’s status and actions are directly pointed to the group entitiy and the lights based on the group just follow zero latency and zero popcorn effects.

I’ve also asked for a toggle option for light / switch groups which would ultimately make automations so much easier and finally allow groups to be exposed though matter / homekit.

There are clearly some issues doing the above and i suspect it’s all to do with how groups are currently created & processed.

1 Like

@david You are probably referring to direct device-to-device communication, such as Zigbee Binding or Matter Bindings. I totally agree that it would be awesome if Aqara fully implemented proper support for this, as it eliminates latency and the “popcorn effect” entirely. However, it probably wouldn’t solve the issue for the OP in this specific case. Since they are mixing a Zigbee switch with 3rd-party Matter lights, a direct binding isn’t possible across different protocols anyway. The hub will always have to act as the translator in the middle.

@chunjye088 Regarding your question on how to best set this up: As a software developer, my approach is always to make things as reusable as possible (the “DRY” principle – Don’t Repeat Yourself!).

Instead of adding all the individual lights directly into every single automation, I highly recommend managing this via Scenes in the Aqara app first.

Here is how I would structure it:

  1. Create Base Scenes: Put all the lights you want to control together into a Scene. Depending on your needs, you can create a “Toggle Toilet Lights” scene, or two separate ones (“Toilet Lights ON” and “Toilet Lights OFF”).
  2. Reuse and Nest Scenes: You can reuse these scenes inside other scenes. For example, if you want a “Good Night / All Home Off” scene, you don’t need to add 50 individual bulbs to it. You just add your already existing “Toilet Lights OFF”, “Kitchen OFF”, and “Living Room OFF” scenes to it.
  3. Use in Automations: Now, in your automation for the physical switch, your action is simply to trigger the specific scene.
  4. Cross-Ecosystem Control: The biggest advantage: Once your lights are neatly organized into scenes, you can expose these Aqara scenes to other ecosystems like Apple Home or Home Assistant via Matter/HomeKit. This means Siri, an external PIR sensor in Apple Home, or a Home Assistant script can trigger the exact same scene, without having to rebuild the logic everywhere.

So, decouple your physical switch (Change to wireless switch), create a Scene for the lights, and let the switch trigger that scene. This makes your setup much cleaner and easier to maintain!

I must admit, though, that this scene-based approach is how I used to do things in the past. Nowadays, I’ve offloaded everything regarding lights, motion sensors, and presence sensors to Home Assistant. It simply gives me far more possibilities and allows me to use just a single automation for relatively complex scenarios (like waiting for specific triggers, or ignoring the motion sensor if the smart light switch was used, etc.). In HA, you can also (at least with experimental features) control the lights for an entire room at once, without needing any scenes or groups, simply by targeting the room assignment. That would actually be a great feature idea for the Aqara app, too!

1 Like

I’ve written up how I did it for my blog. I’ve already posted in “Automation Inspirations”, but here’s a direct link: Using an Aqara H2 EU Switch to control Smart Lights

1 Like