Xiaomi Aqara Wall Switch (single / double) decoupled mode support

Tags: #<Tag:0x00007f326bb66878> #<Tag:0x00007f326bb66760> #<Tag:0x00007f326bb665d0>

Hi,

Is there any plan (or test code) to support the decoupled mode of the Xiaomi Aqara wall switches (both single/double)?

Some of my switches are in decoupled mode in order to act as 3-way switches and I would like to setup the automations in HA instead of relaying on the Xiaomi automation platform.

Thanks!

It seems this is not supported by the API

Unfortunately in decoupled mode the button doesn’t report any informationen anymore.

1 Like

Thanks, so it seems the event is not exposed at all by the Gateway?

It is a pity: I’ve tried to implement 3-way switches (2 or more switches controlling the same light) in HA without the decoupled mode but there is no way to make it work: it alway ends up in an endless loop.

Any attempt to keep the status of the two/three switches in sync failed.

It works if I assume that one switch is master and controls the other, but I need the synchronization to be two ways and the natural delay of the switches causes endless loops (I assume due to race conditions).
I’ve also tried with delays, wait template (e.g. wait_template: “{{ states.switch.wall_switch_left_158d00015723e7.state == trigger.to_state.state }}”) and disabling the automation.

My last resort was to capture the decoupled click and use it to toggle the master switch.

Two of my last attempts below:

  - alias: Hallway 3-way sync
  initial_state: 'off'
  trigger:
    platform: state
    entity_id:
      - switch.wall_switch_right_158d00014df5ad # slave entrance
      - switch.wall_switch_right_158d0001f4864f # slave stairs
      - switch.wall_switch_158d000183b414 # master
  action:
   - service: homeassistant.turn_off
     entity_id: automation.hallway_3way_sync
   - service_template: >
        {% if trigger.to_state.state == "on" %}
        homeassistant.turn_on
        {% elif trigger.to_state.state == "off" %}
        homeassistant.turn_off
        {% endif %}
     entity_id:
      - switch.wall_switch_right_158d00014df5ad # slave entrance
      - switch.wall_switch_right_158d0001f4864f # slave stairs
      - switch.wall_switch_158d000183b414 # master
   - service: homeassistant.turn_on
     entity_id: automation.hallway_3way_sync

- alias: Hallway 3-way toggle
  initial_state: 'off'
  trigger:
    - platform: state
      entity_id:
        - switch.wall_switch_right_158d00014df5ad # slave entrance
        - switch.wall_switch_right_158d0001f4864f # slave stairs
      from: 'off'
      to: 'on'
  action:
   - service: homeassistant.turn_off 
     entity_id: automation.hallway_3way_toggle
   - service_template: switch.toggle
     entity_id: switch.wall_switch_158d000183b414 # master
   - service_template: switch.turn_off
     entity_id:
        - switch.wall_switch_right_158d00014df5ad # slave entrance
        - switch.wall_switch_right_158d0001f4864f # slave stairs
   - service: homeassistant.turn_on
     entity_id: automation.hallway_3way_toggle

I am going to try to setup a 3 way switch with appDeamon. I’m new to it but I’ll let you know how it works out.
what does decoupled mode actually mean?

what does decoupled mode actually mean?

Check the link I posted before.

Sorry if I’m missing the point but if you toggle a light (or group of lights) there should be no issue with the number of switches you’re using to toggle it, right?

Great idea! I haven’t used AppDeamon yet, why do you it could handle the race conditions we get Aqara & HA automations?

Sure - let me try to explain. A traditional 3 way switch has two switches controlling the same light (or set of lights). There are different ways to do it but he most common is here:

The problem is that the Aqara Wall Switches don’t support this kind of wiring because they only have live & switched live (the version with neutral has neutral too, but it is not relevant for this problem). When I replaced the traditional switches with the Aqara ones I had to hack the wiring: now one switch act as master, actually switching on & off the lights. The circuit on the other switch end is instead permanently closed: the switch is powered but it doesn’t switch on/off the lights.

An alternative to the approach above would have been to put the two Aqara switches in series or in parallel: in both cases it is required to create an automation to keep them in sync, plus - due to their internal electronic there was a real risk of having issues: lights blinking with the parallel setup or switches offline with the in-line option.

Back to my choice… I had to “decouple” the slave switch and create an automation in the Xiaomi app: when click on the slave switch is detected then toggle the master switch. It works as a real 3-way setup but there is a small delay (that is killing me…) when the lights are operated from the slave switch (due to the Xiaomi automation implementation based on a mix of cloud and LAN).

The two automations I’ve posted are an attempt to disable the decouple mode and use the slave switch as a click button. The main point is that when I trigger the slave switch I don’t want the Xiaomi relay (inside the switch) to stay on when the lights are off, this would shorten its lifespan. Hence either I keep the two switches in sync or I use the slave to go on and then off (a fake button).

In some other switches I’ve successfully implemented the 3-way switches with the Aqara wireless wall switch, but I didn’t want to use them in the rooms that I use more frequently because the idea of changing batteries of a wall switch is quite unusual.

I hope it makes sense, otherwise I’ll try to make a drawing to explain the wiring.

Everything would have been easier is Xiaomi had thought about adding hardware support (switched live 1 & switched live 2) to the switches.

Finally, a part from this issue with the 3 way setup, I am quite happy with the Xiaomi switches and HA integration: I’ve now 25 switches (a mix of wall / wireless & single / double) and they are all controlled via HA and Google Assistant.

1 Like

@ReX Thanks for the detailed explanation.

Hi. I only have the wireless switches bit I’m guessing that a script in appDeamon should work for both. it should be as easy as toggling the light when either of the switches is triggered.
maybe you could use one wired and one wireless switch.
I went with smart bulbs and wireless switches because I don’t have neutral at the light switch.

I bought the Xiaomi Aqara also because they don’t need neutral at the switch. The only issue, as said, is the missed click event of the decoupled switches. Unfortunately I couldn’t go for wireless switches because I’ve some double switch that act as real switch on one button and wireless on the other.

@ReX did you manage to solve this?
I was looking into the Xiaomi switches as well (didn’t buy yet) until I saw that this might (also) be an issue…

Eventually I decided to use Xiaomi actions for the three-way automations, since all the other methods gave me problems due to race conditions. I would have required decouple mode support to do in HA. The plus is that my switches work also when I experiment on HA.

It is not really an issue since from my point of view, the switches are still the best you can get on the market (look, quality, price, reactiveness).

@ReX Nice! Good to know…

Any chance you can share a description of you final setup ad scripts?
Also, do you have dimmers with those switches?

M.

Do the wall switches without a neutral not have a battery?
I’m in the process of buying a double wall switch with neutral wiring (one of my current switch boxes has a neutral in it) and 2 wireless switches. I had assumed the version of the switch that doesn’t require a neutral would have a battery in it anyway so I’d be better off just using the wireless switch. Have I got it wrong?

Why not simply using one switch as a press button only, that command the other switch via ha?
So one as a real switch, the other as a simple input?

That’s my plan with the 2 wireless switches, have them control the main switch. As @ReX though I’d rather not have to ever change the batteries in the slave switches so if the wall switches that don’t require a neutral also don’t require a battery then buying those instead and using them in decoupled mode might be a better option for me (I was assuming they required a battery too).

These switches have no dimmer, this is the only real limitation. I don’t mind because I have floor lamps around (dimmable), but for some it might be annoying.

Regarding the scripts, they are classic three-way actions constructed in the Xiaomi app. Do you refer to these rules?

No, Xiaomi/Aqara managed to keep a neglectable amount of current flowing when the switch is off, this is enough to power the switches without having the lights on. What is really amazing is that it works with all the types of lights: led, parallel of leds, neon, etc. I’ve tried all the possible setups (I’ve about 40 switches) and it works always. Lights never flashes and the switches are always online. In addition to that there is close to zero power consumption when off (tested with a meter), also with a sensible number of switches.

I’ve tried other switches working with a similar principle and they never worked properly.

In my case I couldn’t do it because some switches have two buttons and I need to use one of them as virtual (decoupled) and one as real.

Thanks for the info, I’ll use them in place of the wireless ones I was going to use.

I wish xaiomi sold this stuff locally, gearbest are taking forever to ship at the moment.

I got most of mine from Gearbest, but I wouldn’t recommend it. Once there were missing items, also proved by the fact that the weight of the parcel was wrong. They refused to provide a refund but accepted after a negative review.

I never had a problem w gearbest, but I am sure that all shops make mistakes sometimes.
Personally I think they are one of the best “direct from china” suppliers.
That said I would not plan to make an expensive purchase (e.g. >$100) from them or any other “direct from china” supplier due to possible customs issues (UK customs stop high value parcels and charge you. they always stop from reliable carriers that you’d want to use for expensive items).