ZHA - Aqara Wireless Mini Switch (model lumi.sensor_swit)

This Blueprint is for the Xiaomi Aqara Wireless Mini Switch paired to the ZHA integration. The Zigbee ID for this button is lumi.sensor_swit.

Aqara_Mini

It supports 5 functions:

  • Single press
  • Double press
  • Long press
  • Release (after a long press)
  • Shake

Apparently, there are three (or more) variations of this switch. I got mine from Aliexpress.

All the blueprint variations, based on ID:

You can find the model ID from the devices list in Home Assistant (Configuration > Devices and search for LUMI). Mine looks like this:

Screenshot_2021-01-16 Configuration - Home Assistant

The blueprint is heavily based on Sean’s, with the addition of the shake action.

Blueprint:

blueprint:
  name: ZHA - Aqara Wireless Mini Switch
  description: Automate your Xiaomi Aqara Wireless Mini Switch using ZHA events.
  domain: automation
  input:
    aqara_mini_switch:
      name: Aqara Wireless Mini Switch
      description: Aqara Wireless Mini Switch to use
      selector:
        device:
          integration: zha
          manufacturer: LUMI
          model: lumi.sensor_swit
    button_single_press:
      name: Single Press
      description: Action to run on single press
      default: []
      selector:
        action: {}
    button_double_press:
      name: Double Press
      description: Action to run on double press
      default: []
      selector:
        action: {}
    button_long_press:
      name: Long Press
      description: Action to run when button is long pressed (held down)
      default: []
      selector:
        action: {}
    button_released:
      name: Released
      description: Action to run when button is released after a long press
      default: []
      selector:
        action: {}
    button_shaken:
      name: Shake
      description: Action to run when shaken
      default: []
      selector:
        action: {}
mode: restart
max_exceeded: silent
trigger:
- platform: event
  event_type: zha_event
  event_data:
    device_id: !input 'aqara_mini_switch'
action:
- variables:
    command: '{{ trigger.event.data.command }}'
- choose:
  - conditions:
    - '{{ command == ''single'' }}'
    sequence: !input 'button_single_press'
  - conditions:
    - '{{ command == ''double'' }}'
    sequence: !input 'button_double_press'
  - conditions:
    - '{{ command == ''hold'' }}'
    sequence: !input 'button_long_press'
  - conditions:
    - '{{ command == ''release'' }}'
    sequence: !input 'button_released'
  - conditions:
    - '{{ command == ''shake'' }}'
    sequence: !input 'button_shaken'

4 Likes

Hi there and thank you for sharing this,

I have two WXKG12LM Aqara buttons (with the shake function) and in ZHA they are registered as lumi.sensor_switch.aq3

So, I guess we should create another branch for this?

Yeah, you can either create another post here, or take my code and paste it in a gist, where you can then replace the model number. This gist would be the one to pull as a blueprint.

Just wanna pop in and say thanks for the blueprint. Just what I was looking for.

ill be testing this shortly. For those needing the aq3, i have posted a gist here with the model number revisions

ZHA Aqara aq3 mini switch blueprint based on thedudeabides

Thanks , works like a charm

Can’t seem to make an automations with this blueprint anymore. Keep getting the issue.

Executed: November 13, 2021, 12:24:07 PM
Error: UndefinedError: 'dict object' has no attribute 'event'

variables:
  command: '{{ trigger.event.data.command }}'

Any idea why is wrong? Google doesn’t seem to helping.

Same issue here

Error: UndefinedError: 'dict object' has no attribute 'event'

Did you ever get to the bottom of this, I suspect the device isn’t being detected properly thus doesn’t have the required events exposed for the automation but would be interested to know if you managed to resolve it ?

Managed to clear this error by deleting and re-adding the device a couple of times, working fine now so don’t think it was correctly paired when the error was coming up

I also use these buttons but then in Deconz. Any chance this can be converted to (also) work with Deconz?

Can this be adjusted to use with Matter? I don’t see any blueprints for Matter yet. Is that even a thing yet?

Hello, I have the same question.

Are there any blueprints for Matter for this device?

Thank you