Issue creating automation using Aqara H2 light switch over Matter

Hi,

Like many I’ve seen in the forum, I’m new to Home Assistant. The automations I’ve done so far have been using Apple’s Home app. But now, in our new house, there are devices that are not compatible with HomeKit, so I’ve decided to give a go to Home Assistant.

I’ve several Aqara H2 light switches, and they work well. The relay button works, even when the switch is not adopted by anything, which was my goal. I’ve added the switches to HomeKit via Thread, and there I can setup the WiFi buttons, but I’m limited to whatever devices HomeKit supports.

In Home Assistant, I’ve added all devices, including the light switches and other devices. I’ve tried to add an automation that, when the WiFi button is pressed, it should turn ON the electric tower radiator. After several attempts, I’ve accomplished nothing. I’ve looked in the Developer Tools to see which event type was triggered, and it was the following:

event_type: state_changed
data:
  entity_id: event.aqara_smart_wall_switch_button_5_4
  old_state:
    entity_id: event.aqara_smart_wall_switch_button_5_4
    state: "2025-11-24T10:49:39.931+00:00"
    attributes:
      event_types:
        - initial_press
      event_type: initial_press
      newPosition: 1
      device_class: button
      friendly_name: Bathroom light switch Button (5)
    last_changed: "2025-11-24T10:49:39.931471+00:00"
    last_reported: "2025-11-24T10:49:39.931471+00:00"
    last_updated: "2025-11-24T10:49:39.931471+00:00"
    context:
      id: 01KATQQJAVC0MAQZ7CAK9574QC
      parent_id: null
      user_id: null
  new_state:
    entity_id: event.aqara_smart_wall_switch_button_5_4
    state: "2025-11-24T10:49:50.587+00:00"
    attributes:
      event_types:
        - initial_press
      event_type: initial_press
      newPosition: 1
      device_class: button
      friendly_name: Bathroom light switch Button (5)
    last_changed: "2025-11-24T10:49:50.588060+00:00"
    last_reported: "2025-11-24T10:49:50.588060+00:00"
    last_updated: "2025-11-24T10:49:50.588060+00:00"
    context:
      id: 01KATQQWQWY3K6SP22JA28K9ZZ
      parent_id: null
      user_id: null
origin: LOCAL
time_fired: "2025-11-24T10:49:50.588060+00:00"
context:
  id: 01KATQQWQWY3K6SP22JA28K9ZZ
  parent_id: null
  user_id: null

I’ve tried several types of triggers, such as Entity, Device, Manual events, but no success.

I even connected the light switch to Home Assistant via Zigbee, but like this I couldn’t see the WiFi buttons. I read several older posts, saying it’s a limitation, or that it’s the trigger type, but nothing so far.

Has anyone been able to do something like this?

Thanks.
Hugo

I get your struggle, automating Matter buttons correctly is still cumbersome in HA.

This is the general tutorial to automate buttons, the main idea is automate on state change:

Luckily, the H2 only has initial press type so you don’t need the action conditions part where they check for the specific press type.

But you need the unavailable and unknown conditions, otherwise your automation will trigger for reasons that are not a button press.

The event automation is working really well and fast on the light switch H" (same by the way on the new shutter switch H2), but the events are still “fired” although there are “unavailable” and “unknown” condions in the automations are included. Anybody an idea what the problem could be? Actually, I´ve never seen the state “unknown” or “unavailable” in the state entity.
How could I check what state the event entity has when I e.g. kill the thread communication for a few seconds by unplugging the coordinator stick.

alias: Licht Ankleide an von Ankleide Taste 7 (rechts unten)
description: ""
triggers:
  - trigger: state
    entity_id:
      - event.ankleide_schlafzimmer_taste_7
conditions:
  - condition: not
    conditions:
      - condition: state
        entity_id: event.ankleide_schlafzimmer_taste_7
        state:
          - unavailable
      - condition: state
        entity_id: event.ankleide_schlafzimmer_taste_7
        state:
          - unknown
actions:
  - action: light.turn_on
    metadata: {}
    data:
      brightness_pct: 100
      color_temp_kelvin: 6500
    target:
      entity_id: light.ankleide_schlafzimmer_leuchte_1
mode: single