core
core copied to clipboard
HomeKit Connected Aqara Mini Button not triggering press automations
The problem
I recently bought a aqara mini button and a hub and connected to the aqara app and paired with home assistant using the home kit controller but after making an automation to recognize each press type and do something with it the automation doesn't seem to be triggered when I click the button. (The aqara app records the press so the button is working)
Image of the automation trigger setup:

Image of the Button device data:

What version of Home Assistant Core has the issue?
core-2022.9.5
What was the last working version of Home Assistant Core?
No response
What type of installation are you running?
Home Assistant Supervised
Integration causing the issue
Homekit Controller
Link to integration documentation on our website
https://www.home-assistant.io/integrations/homekit_controller
Diagnostics information
homekit_controller-a5c6c1e1a2c8ceda4cf166859bc6d145-Button-364308a6081a4068d16fca645237982d.json.txt
Example YAML snippet
alias: HA - Turn on Pool Lights on Button Click
description: |-
There is a button in the door between the pool area and the living room.
Single Click - Turns on the dinner lights
Double Click - Turns all lights in the pool area
Long Press - Turns of all lights in the pool area
trigger:
- platform: device
device_id: 364308a6081a4068d16fca645237982d
domain: homekit_controller
type: button1
subtype: single_press
id: single-press
- platform: device
device_id: 364308a6081a4068d16fca645237982d
domain: homekit_controller
type: button1
subtype: double_press
id: double-press
- platform: device
device_id: 364308a6081a4068d16fca645237982d
domain: homekit_controller
type: button1
subtype: long_press
id: long-press
condition: []
action:
- choose:
- conditions:
- condition: trigger
id: single-press
sequence:
- service: switch.toggle
data: {}
target:
entity_id: switch.pool_dinner_table_lights
- conditions:
- condition: trigger
id: double-press
sequence:
- service: switch.turn_on
data: {}
target:
entity_id:
- switch.pool_dinner_table_lights
- switch.pool_lights
- conditions:
- condition: trigger
id: long-press
sequence:
- service: switch.turn_off
data: {}
target:
entity_id:
- switch.pool_lights
- switch.pool_dinner_table_lights
mode: single
Anything in the logs that might be useful for us?
No response
Additional information
No response
homekit_controller documentation homekit_controller source (message by IssueLinks)
Hey there @jc2k, @bdraco, mind taking a look at this issue as it has been labeled with an integration (homekit_controller) you are listed as a code owner for? Thanks!
(message by CodeOwnersMention)
@Jc2k or @bdraco is there a way to debug button "events" so i can maybe share more debugging with you guys? Or maybe check debugging data of Homekit?
I actually ordered one of these this afternoon to see if I could help. It should be here tomorrow.
In the meantime you could enable debug logs for aiohomekit.
I'm pretty sure there was an Aqara button that lied about what events it actually sent over homekit. But i can't remember if it was this one or not.
@Jc2k that wasn't need I guess but thanks for the effort into helping me figure this out. Let me know if I could be of any help.
Truly appreciate.
@Jc2k could you please let me know how I can enable logs?
Bit hard to do yaml config fragments on my phone sorry. And busy evening. I'll try and get to a computer and post something later but might not make it.
# Example configuration.yaml entry
logger:
default: info
logs:
homeassistant.components.homekit_controller: debug
aiohomekit: debug
And if you still need more to see events being fired (but this will be a bit chatty)
# Example configuration.yaml entry
logger:
default: info
logs:
homeassistant.components.homekit_controller: debug
aiohomekit: debug
homeassistant.core: debug
So some updates. Now its working for some reason? I activated debug mode and clicked the button to see if any logs appeared and now it work? I did bring my hub to my room so I'm going downstairs to test on the place it was see if it still works. Ill update you guys in a but
I'm honestly confused on why its working.
I did restart Home Assistant. Whats the probability that that fixed the issue? Is Home kit known to need a restart to propagate settings, automations or any data?
I have had the Aqara mesh fall over, and moving the hub has fixed it. So maybe that was all it was.
I'm disabling logs and doing a AP lock on the device to test the layout it was when it wasnt working to see if any of those where causing the problem for some reason
Also Aqara rotates it's tcp port a lot. So if zeroconf on your network is flakey it can miss that update, and be stuck on an old port. But it's unlikely restarting would help in that case.
Thanks for the help @Jc2k and @bdraco it seems to work now. For future people with same issue:
- Try restarting your HA
- Connecting the Aqara hub to a different AP or network.
So it looks like it is a registration order problem with the triggers and a restart is needed to make the triggers work.
I just tested this with an eve button and I had to restart to get it to work
So I guess I found a bug :) Anyway I could help fix it? Any information you need?
I think we need to write a test for the config entry being in a retry state at startup that ensures the trigger still attaches
This is effectively the same issue as #82495
@bdraco any news regarding fixes for this?
Nope. Haven’t had a chance to work on this
ok @bdraco if there is any way I could be useful let me know