Xiaomi Aqara Square button not working

I’ve got a Xiaomi Aqara Gateway with one Xiaomi Aqara Square button, but I can’t get the button to work.

What I’ve tried:

   - id: deurbel
      alias: Notify iOS app
      trigger:
      - platform: event
        event_type: click
        event_data:
          entity_id: binary_sensor.switch_158d0001b86e90
          click_type: single
      action:
      - service: light.turn_on
        entity_id: light.bol_keuken
        data:
          brightness: 100
          rgb_color: [255, 0, 255]

But it isn’t working. When I use the states option from HA to play a ringtone on the gateway, it’s working, so communication between GW and HA should be fine?
When I fire the event from the event option, the light goes on fine.

Any help would be appreciated!

anything in the log?

Nope, when I press the button, nothing is noticable.

Try calling the light.turn_on service with a color name:

  - service: light.turn_on
    entity_id: light.bol_keuken
      data:
        brightness: 100
        color_name: red

Why should this work better? When I use the RGB mode in other automations, they work fine.

I can’t use “rgb_color” for my Xiaomi Gateway Lights, I must specify a human readable color name.

Another thing to try is to use a random digit-only string for the id of the automation.

I have a very similar working automation :

- action:
  - data:
      entity_id: light.luucht
    service: light.toggle
  alias: Luucht un-aus mat Xiaomi Taster Single Click
  id: '1151189265746'
  trigger:
  - event_data:
      click_type: single
      entity_id: binary_sensor.switch_158d00018dba3c
    event_type: click
    platform: event

Also, in the “States” View of the Developer Tools, do you see the state of the button changing when you press it?

Thanks again for your answer, forgot to mention that the
light.bol_keuken
is a Limitless light, so it does accept “rgb_color”.

Wil try to replace “deurbel” with a random number!

No, but I read somewhere that it isn’t supposed to change?

Actually they do, the state changes from “off” to “on”
Filter your states view for devices beginning with binary_sensor.switch and press the button a few times.
You should see something happening. This way you can verify if your button presses are correctly registered.

Tried that, but the state isn’t changing. After a couple of presses the gateway began talking to me in Chinese.

I have the square button, which I use as a doorbell. The only difference I can see is that in my automation I have “event_type: click” but I do not have “click_type: single”. Maybe try removing it and see if that works?

Thanks for your answer, already tried but no luck!

1 Like

Just one other thought, are the indentations correct? From what’s pasted it looks as if line 2 downwards is 1 space inset from line 1?

Naamloos

It’s exactly the same as my other automations that are working flawlessly.

The spacing looks fine, must be how it was formatted in the original post. If it helps, this is my working automation (created with the automation editor)

- action:
  - data:
      gw_mac: 7811dcb1fb51
      ringtone_id: '10'
      ringtone_vol: '100'
    service: xiaomi_aqara.play_ringtone
  - data:
      message: Button pushed
      title: Doorbell
    service: notify.notify
  - data:
      entity_id: switch.wall_switch_left_158d0001f5855f
    service: switch.turn_on
  - data:
      entity_id: script.1518189839995
    service: script.turn_on
  alias: Doorbell
  condition: []
  id: '1514924576622'
  trigger:
  - event_data:
      entity_id: binary_sensor.switch_158d0001b8f6d9
    event_type: click
    platform: event

Yeah, I was wrong about that. Just tried at Home with my Switches, and they only change state when the button is kept being pressed (long_click_press).

try action_type instead of click_type

- id: deurbel
      alias: Notify iOS app
      trigger:
      - platform: event
        event_type: click
        event_data:
          entity_id: binary_sensor.switch_158d0001b86e90
          click_type: single
      action:
      - service: light.turn_on
        entity_id: light.bol_keuken
        data:
          brightness: 100
          rgb_color: [255, 0, 255]

I’m guessing it’s the dash in front of service under the action section.

Try it like this:

- id: deurbel
      alias: Notify iOS app
      trigger:
      - platform: event
        event_type: click
        event_data:
          entity_id: binary_sensor.switch_158d0001b86e90
          click_type: single
      action:
        service: light.turn_on
        entity_id: light.bol_keuken
        data:
          brightness: 100
          rgb_color: [255, 0, 255]

If that doesn’t do it, try indenting the last 3 lines with two additional spaces.

Tried that, still no luck.

Tried both suggestions, but also doesn’t solve the problem.

Also deleted all my other automations and copied the version of MartinB and hiscorebob, but both don’t work.

Still think that it has to do with the binary_sensor that won’t communicate with HA. It does show up in the Xiaomi log, but nothing is visible in HA.

Hmmm, here’s mine from my automations.yaml that works no problem if it helps.

And now I’ve just noticed that it doesn’t have a dash in front of platform.

It’s the only remaining difference between yours & mine I can see. Fingers crossed :slight_smile:

- alias: Quick Click to toggle Stereo
  trigger:
    platform: event
    event_type: click
    event_data:
      entity_id: binary_sensor.switch_158d0001f9ce12
      click_type: single
  action:
    service: media_player.media_play_pause
    data:
      entity_id: media_player.hifi_pi

Sorry, I mixed up with my Xiaomi Cube automations which uses action_type.

This is working fine for me:

- alias: "Xiaomi Button - Single (Toggle bedroom light)"
  trigger:
    platform: event
    event_type: click
    event_data:
      entity_id: binary_sensor.switch_158d000122737e
      click_type: single
  action:
    - service: light.toggle
      entity_id: light.bedroom

Note: I do have another Xiaomi switch (the round one).
image