[Square Xiaomi] Single click to light automation


I’m trying to create a basic automation using a Xiaomi Square (WXKG11LM) to turn_on a light.

I have checked on forum and googled it but still doesn’t work after some tests…

Here is the automation :

- id : 'light_bulb_automation_click'
  alias: Light Bulb Click
    platform: event
    event_type: xiaomi_aqara.click
        entity_id: sensor.0x00158d000204a63d_click
        click_type: single
    - service: light.toggle
        - light.bulb_floor

Everywhere, i see binary_sensor instead of sensor that i have, could it be the issue ?

Thank you for your help.


To complete the request, i can see the click status in the service tab.
I really don’t know what i missed.



Speaking alone but find my way.

Here is what i have done for someone looking to use it :

  • id : ‘light_bulb_automation_click’
    alias: Light Bulb Click
    initial_state: true
    hide_entity: true
    • platform: mqtt
      topic: ‘zigbee2mqtt/0x00158d000204a63d’
      condition: template
      value_template: “{{ ‘single’ == trigger.payload_json.click }}”
      • service: light.toggle
        entity_id: light.bulb_floor
      • service: notify.ios_iphax
        title: “[LIGHT] {{states(‘light.bulb_floor’)}}”
        message: “Floor Bulb”

Your initial automation would have worked if you were using the Xiaomi hub. Since you are using Zigbee2MQTT that’s why your latest attempt worked.

Yes indeed.
It’s why i have changed and used the platform mqtt instead.

My suggestion would be to use node-red for this type of automation.
its expecially easy if you also use hassio since the add-on for nodered is all preconfigured for home assistant integration.
Using xiaomi buttons your automation is as simple as this:

Event from the button --> Switch for whether its one click or two --> action for each 1/2 clicks

Look at the lists of entities shown on the States page. That’s where you will learn if the device is represented as a sensor or binary_sensor.

1 Like

@hijinx Indeed, i have nodered installed also but not yet try it. I’ll use for this automation and check how is it going.

@123 Thank for the tip.

I’m putting all my automations through node-red now.
I much prefer it to yaml.


With Nodered, just created the automation and click deploy directly work on Hassio ?

Yes, should do.

Ok let’s try later.

I’ll already created an automation for the Single and Double clicks :sunglasses: :

Same logic as you but it’s for test.

I was fumbling with this.

Then I came upon this post (#3) with the automation template you came up with.

Now it makes sense.