Home Assistant Community

[Square Xiaomi] Single click to light automation

#1

Hello,

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
  trigger:
    platform: event
    event_type: xiaomi_aqara.click
    event_data:
        entity_id: sensor.0x00158d000204a63d_click
        click_type: single
  action:
    - service: light.toggle
      entity_id:
        - light.bulb_floor

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

Thank you for your help.

#2

Hello,

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

Axel

#3

Hello,

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
    trigger:
    • platform: mqtt
      topic: ‘zigbee2mqtt/0x00158d000204a63d’
      condition:
      condition: template
      value_template: “{{ ‘single’ == trigger.payload_json.click }}”
      action:
      • service: light.toggle
        entity_id: light.bulb_floor
      • service: notify.ios_iphax
        data:
        title: “[LIGHT] {{states(‘light.bulb_floor’)}}”
        message: “Floor Bulb”
#4

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.

#5

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

#6

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

#7

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
#8

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

#9

@123 Thank for the tip.

#10

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

#11

Ok.

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

#12

Yes, should do.

#13

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.