Xiaomi button battery discovered but no on/off

Hi All,
recently expanded my zigbee network with a number of Xiaomi/Aqara temp sensors and all worked well straight out the box with my Nortek Zigbee/Z-wave Dongle connected to my NUC.

Now i have purchased 4 smart buttons from Xiaomi (Mija Buttons) and i cannot get these to work. It is paired with HA and the battery shows in the devices list. When watching the Zigbee logs i can see the different button pressses being registered but there is no device in my list where i can see this on off. Am i meant to create my own and if so how/where to start? (expected sensor to show)

There is no Xiaomi gateway this is directly connected to HA by ZHA interface so solutions which suggest Smartthings or Gateway push MQTT i cannot work out how to implement.

Many thanks

4 Likes

Pretty sure button presses are going to come as events.

Check out that section on the wireless button.

There is no state to this button. There is no on/off.

If you want to use it as a switch to control a light, you’d have to create a template_light. You would use the light as the state somehow (light sensor would work well, or just guess). Then you could tie the command_on/command_off to the button.

To explain how to handle the events:

- alias: Toggle dining light on single press
  trigger:
    # When the button is pressed, do something
    platform: event
    event_type: xiaomi_aqara.click
    event_data:
      entity_id: binary_sensor.switch_158d000xxxxxc2
      click_type: single
  action:
    # What to do when the button is pressed
    service: switch.toggle
    entity_id: switch.wall_switch_left_158d000xxxxx01
1 Like

Thank you, but without the gateway i do not see how i use that integration as it needs the gateway to send/receive the click events and forward to HA.

If it’s paired with your Home Assistant, I assumed you had a gateway of some sort. I count ZHA as a gateway.

Open up Dev Tools, and at the top, click EVENTS

In the middle of the page, there will be “Listen to events”

type “zha_event” (without the quotes) there and click “start listening”

Now press the button. I think ZHA events come over that ‘event topic’ or whatever it’s called.

- alias: Handle Double Clicky
  trigger:
  - event_data:
      args:
      - double
    command: click
    device_ieee: 00:15:8d:00:01:25:63:f6
    event_type: zha_event
    platform: event
  action:
  - data:
    entity_id: light.some_light
    service: light.turn_on

You’ll use the ieee device ID to know which device sent the event.

…in theory. I don’t have ZHA to test, sorry!

6 Likes

I’ve got some of the Aqara Buttons, which I have paired directly DeConz. As jocnnor says, the data arrives as events.

Using NodeRed, I’ve subscribed to deconz_event events.

When I click the button, I get a payload which includes a device name and an event Id.

e.g. smart_switch_02 and the event for single click is 1001.

I also have an Ikea switch, which has a device Id of tradfri_on_off_switch. It has a similar setup, raising events 1001 for on and 2002 for off.

Under the developer tools section, go to the Events tab and you can “listen” for the events. I used trial an error to determine how they worked.

Hello, I have a little guide for NodeRED here … maybe it helps you a little bit.

Thank you very much all, @jocnnor was correct it was the zha_event type I then needed to filter.
However i struggled with identifying what i wanted in HA and the Events tab, once i moved over to Node-Red as suggested it was dead easy to see what i needed to.

Now have 4 of these buttons i can set up and each has options of single/double/triple/quadruple/furious i can set different actions for.
Much appreciated for all the help

1 Like

Hi there - could I revive this? I’ve just been using ZHA to pair one of these Xiaomi buttons, and I too get a sensor for the battery, but no entities for the button switch itself.

Now, in one sense, this doesn’t matter, because it does generate zha_events, so I can write code to trigger on it.

But an identical button, which I added perhaps a year ago, did get a sensor entity of its own for the button, which means I can use its name in automations, rather than its IEEE ID. So either the functionality has been lost from HA, or perhaps there’s been change in firmware in the button? The two devices look pretty identical from what I can see of model IDs etc. The entries in core.device_registry are identical except for the MAC addresses.

I’m wondering if there’s a way I can give it an entity? Perhaps I should try editing core.entity_registry… but I wondered if there was an official way…

Hi.
Same problem and poor knowledge.
I had this button paired with zigbee2mqtt.
It was working using this automation:

- id: 'Toggle Ventilatore'
  alias: aqara shake
  trigger:
  - platform: state
    entity_id: sensor.pulsante_studio
    to: 'shake'
  action:
    - service: switch.toggle
      entity_id: switch.ventilatore

now I switched to sonoff zigbee gatway + tasmota and ZHA.
in the event I read:

{
    "event_type": "zha_event",
    "data": {
        "device_ieee": "00:15:8d:00:02:ad:e3:a2",
        "unique_id": "00:15:8d:00:02:ad:e3:a2:1:0x0012",
        "endpoint_id": 1,
        "cluster_id": 18,
        "command": "shake",
        "args": {
            "value": 18
        }
    },
    "origin": "LOCAL",
    "time_fired": "2020-10-09T19:04:01.977827+00:00",
    "context": {
        "id": "3193def20a6211eba85ea55b12a31725",
        "parent_id": null,
        "user_id": null
    }
}

How can I fix my automation?
Thank you very much!

ok, I did it:

- id: 'Toggle Ventilatore1'
  alias: aqara shake
  trigger:
  - event_data:
      device_ieee: 00:15:8d:00:02:ad:e3:a2
      unique_id: 00:15:8d:00:02:ad:e3:a2:1:0x0012
      command: shake
      args:
        value: 18
    event_type: zha_event
    platform: event
  action:
    - service: switch.toggle
      entity_id: switch.ventilatore
      
3 Likes

how did you do this? I have a Zigbee remote (Sengled) paired with ZHA and I want to listen and identify the buttons. I’ve installed node-red but i can’t figure out that part…

@ShaneSpina
You don’t have to use NodeRed.
In the Integration-ZHA select the button which gets you to the device page of it.
Click on Automation+ sign and it shows the events, you can easily auto generate an automation from here using the UI.

I’ve gotten to the bottom of my issue, I need a ZHA quirk built… so I am waiting on that…