WXKG12LM - Aqara Wireless Mini Switch

I recently purchased Aqara Wireless Mini Switch [WXKG12LM].

When I add it to my homeassistant using Aqara Gateway Integration, it doesn’t give me the action types it is only showing On/Off and battery level change in automations. (as shown in the image below)

I tried looking for answers in the community and ran into this option of using blueprint. So I used the following blueprint Link

But when I go to automations and click on this print, it says no device found. Sharing a screenshot below:

Would be grateful if someone could kindly guide me in the right direction on how to get the missing entities/triggers for this mini switch.

Would appreciate if anyone who is using this model of Aqara Wireless Mini Switch could kindly share a fix. Thank you :slight_smile:

Hello, I’m working on a similar item and am currently drafting an blueprint to address a related issue. I to have this button hooked up through the Aqara gateway. I then have it published to HA through Matter.

The blueprint you are using is assuming you have it published to HA via ZHA. I am not sure that you can do that with the Aqara hub. This is what I feel is leading to the mismatch you show above.

I have gotten some data using the event monitor and have rigged up an automation by hand that fires.
The data from the Monitor:

event_type: state_changed
data:
  entity_id: event.steph_s_button
  old_state:
    entity_id: event.steph_s_button
    state: "2024-03-04T16:34:41.772+00:00"
    attributes:
      event_types:
        - initial_press
        - short_release
        - long_press
        - long_release
        - multi_press_ongoing
        - multi_press_complete
      event_type: initial_press
      newPosition: 1
      device_class: button
      friendly_name: Steph's Button
    last_changed: "2024-03-04T16:34:41.773034+00:00"
    last_updated: "2024-03-04T16:34:41.773034+00:00"
    context:
      id: 01HR552GZDH1GVJ6Y7RKDEXYQ9
      parent_id: null
      user_id: null
  new_state:
    entity_id: event.steph_s_button
    state: "2024-03-04T16:34:41.775+00:00"
    attributes:
      event_types:
        - initial_press
        - short_release
        - long_press
        - long_release
        - multi_press_ongoing
        - multi_press_complete
      event_type: short_release
      previousPosition: 1
      device_class: button
      friendly_name: Steph's Button
    last_changed: "2024-03-04T16:34:41.775231+00:00"
    last_updated: "2024-03-04T16:34:41.775231+00:00"
    context:
      id: 01HR552GZF9S9W4T8BQ4HS8Y1D
      parent_id: null
      user_id: null
origin: LOCAL
time_fired: "2024-03-04T16:34:41.775231+00:00"
context:
  id: 01HR552GZF9S9W4T8BQ4HS8Y1D
  parent_id: null
  user_id: null

I latched on the the event_type of multi_press_complete and the totalNumberOfPressesCounted to get responsed to both single and double presses. It isn’t pretty and is very much me stumbling around in the dark. Here is the automation:

- id: '1709081381187'
  alias: SButton
  description: ''
  trigger:
  - platform: state
    entity_id:
    - event.steph_s_button
    attribute: event_type
    to: multi_press_complete
  condition: []
  action:
  - choose:
    - conditions:
      - condition: numeric_state
        entity_id: event.steph_s_button
        attribute: totalNumberOfPressesCounted
        above: 0
        below: 2
      sequence:
      - service: switch.toggle
        metadata: {}
        data: {}
        target:
          entity_id: switch.readinglight
    - conditions:
      - condition: numeric_state
        entity_id: event.steph_s_button
        above: 1
        below: 3
        attribute: totalNumberOfPressesCounted
      sequence:
      - service: tts.speak
        metadata: {}
        data:
          cache: true
          media_player_entity_id: media_player.kitchen_group
          message: Two
        target:
          entity_id: tts.google_en_com

I am trying to shoehorn it into a blueprint that i’ll happily share for criticism and destruction hopefully soon.

1 Like

Thank you for the kind response.

I will try adding the button via ZHA and update you if my current blueprint works then.

Meanwhile will also be looking forward to your blueprint.

Here are things roughed in without any testing. I’m sure there are plenty of things to fix to make it work. I had hoped to at least rough out the structure and logic. Only accounts for completed sequences as it is based off the multi_press_complete state change.

First attempt sloggin thought this. Don’t laugh too loudly. Thank you!

blueprint:
  name: Matter - Aqara Wireless Mini Switch
  description: Automate your Aqara Wireless Mini Switch when run via Matter
  author: EFH52
  domain: automation
  input:
    target_switch:
      name: Aqara Wireless Mini Switch
      description: Target Aqara Wireless Mini Switch to monitor
      selector:
        entity:
          integration: matter
          model: Aqara Wireless Mini Switch
    short_release_action:
      name: Short Press Complete
      description: Action to take when Short Press is completed
      default: []
      selector:
        action: {}
    long_release_action:
      name: Long Press Complete
      description: Action to take when Long Press is completed
      default: []
      selector:
        action: {}
    two_release_action:
      name: Double Press Complete
      description: Action to take when Double Press is completed
      default: []
      selector:
        action: {}
    three_release_action:
      name: Triple Press Complete
      description: Action to take when Triple Press is completed
      default: []
      selector:
        action: {}
    four_release_action:
      name: Quadruple Press Complete
      description: Action to take when Quadruple Press is completed
      default: []
      selector:
        action: {}

mode: restart
max_exceeded: silent

trigger:
  platform: state
  entity_id: !input target_switch

action:
  - variables:
      - command: "{{ trigger.to_state.attributes.event_type }}"
      - presses: "{{ trigger.to_state.attributes.totalNumberOfPressesCounted }}"
  - sequence:
      - condition: "{{ command == 'multi_press_complete' }}"
        sequence:
          - choose:
              - condition: "{{ presses == 1 }}"
                sequence:
                  - choose:
                      - condition: "{{ command == 'short_release' }}"
                        sequence: !input short_release_action
                      - condition: "{{ command == 'long_release' }}"
                        sequence: !input long_release_action
              - condition: "{{ presses == 2 }}"
                sequence: !input two_press
              - condition: "{{ presses == 3 }}"
                sequence: !input three_press
              - condition: "{{ presses == 4 }}"
                sequence: !input four_press

Hi there,

Not sure if it would be off topic but i have a quick question on your experience with Aqara mini switch.
Like you, I recently purchased it and linked it through matter.
When I click on the button, I get multiple events (2 to 3) and not just a single one.
Aqara app shows right amount of click.
I am trying to make an automation based on single/double click but this behavior prevents any correct interpretation of the action.

I found this old topic on GitHub about this behavior saying Aqara fixed it… but it seems not.

Are you experiencing the same issue?
Any idea if blueprint would solve issue?

Thanks :pray:t2:

That link was for the Aqara app having fixed things. I’ve gotten it to work for single and double by tracking the multipress event.

Use event type for the trigger.

Choose your entity, choose event type as the attribute, choose to multipresscomplete. Then set the upper and lower limits either side the number of presses you each to trigger. It is messy, but it works.

Many thanks for your advice!
I am trying the event type you suggested but it seems I cannot define upper/lower limits.


Is there a subsection I am missing?

The Upper/Lower limits you’re searching for can’t be found in the Trigger (When) section you’re showing.

You have to set them as Conditions (And if section) as per the post further up.

Sorry, I am not yet super fluent in YAML. :sweat_smile:
I followed steps and it works now ! Although I really do not understand how. :man_facepalming:t3:

Here is my final automation.


alias: Télécommande Victoria Rose
description: ""
trigger:
  - platform: state
    entity_id:
      - event.telecommande_victoria
    attribute: event_type
    to: multi_press_complete
condition: []
action:
  - choose:
      - conditions:
          - condition: numeric_state
            entity_id: event.telecommande_victoria
            attribute: totalNumberOfPressesCounted
            above: 0
            below: 2
        sequence:
          - service: light.turn_on
            metadata: {}
            data:
              rgb_color:
                - 255
                - 0
                - 255
              brightness_pct: 1
            target:
              device_id: 613053aaaf513ff719827a83e8d3c578
      - conditions:
          - condition: numeric_state
            entity_id: event.telecommande_victoria
            attribute: totalNumberOfPressesCounted
            above: 1
            below: 3
        sequence:
          - service: light.turn_on
            metadata: {}
            data:
              rgb_color:
                - 0
                - 0
                - 255
              brightness_pct: 1
            target:
              device_id: 613053aaaf513ff719827a83e8d3c578
mode: single

Here is where I landed. I have function (debugging still shows in this blueprint), but it stops at the double press. In the Aqara app, it only shows single, double, and long as options. So i’m guessing things changes in the firmware.

blueprint:
  name: Matter - Aqara Wireless Mini Switch
  description: Automate your Aqara Wireless Mini Switch when run via Matter (with long/short press differentiation)
  author: EFH52 (enhanced by AI)
  domain: automation
  input:
    target_switch:
      name: Aqara Wireless Mini Switch
      description: Target Aqara Wireless Mini Switch to monitor
      selector:
        entity:
          integration: matter
          domain: event
          device_class: button

    short_press_action:
      name: Short Press Action
      description: Action to take on a short press
      default: []
      selector:
        action: {}

    long_press_action:
      name: Long Press Action
      description: Action to take on a long press
      default: []
      selector:
        action: {}

    double_press_action:
      name: Double Press Action
      description: Action to take on a double press
      default: []
      selector:
        action: {}

    triple_press_action:
      name: Triple Press Action
      description: Action to take on a triple press
      default: []
      selector:
        action: {}

    quadruple_press_action:
      name: Quadruple Press Action
      description: Action to take on a quadruple press
      default: []
      selector:
        action: {}

mode: single
max_exceeded: silent

trigger:
  - platform: state
    entity_id: !input target_switch
    attribute: event_type

action:
  - service: persistent_notification.create
    data:
      title: "Aqara Mini Switch Debug"
      message: "Event triggered:  event_type={{ trigger.to_state.attributes.event_type }}"

  - choose:
      - conditions:
          - condition: template
            value_template: "{{ trigger.to_state.attributes.event_type == 'short_release' }}"
        sequence: !input short_press_action

      - conditions:
          - condition: template
            value_template: "{{ trigger.to_state.attributes.event_type == 'long_press' }}"
        sequence: !input long_press_action

      - conditions:
          - condition: template
            value_template: "{{ trigger.to_state.attributes.event_type == 'multi_press_complete' and trigger.to_state.attributes.totalNumberOfPressesCounted == 2 }}"
        sequence: !input double_press_action

      - conditions:
          - condition: template
            value_template: "{{ trigger.to_state.attributes.event_type == 'multi_press_complete' and trigger.to_state.attributes.totalNumberOfPressesCounted == 3 }}"
        sequence: !input triple_press_action

      - conditions:
          - condition: template
            value_template: "{{ trigger.to_state.attributes.event_type == 'multi_press_complete' and trigger.to_state.attributes.totalNumberOfPressesCounted == 4 }}"
        sequence: !input quadruple_press_action

Seems, i misread my model number. I have the WXKG11LM.

Am I just crazy or did the recent version of home assistant make it so that the “to” field only works if it’s different from the current state?