Aqara/Xiaomi Wireless mini switch WXKG11LM

Here is a Z2M 2.0.0 compatible one.
It’s not the fanciest, but it works for me.

blueprint:
  name: Xiaomi WXKG11LM Aqara Wireless Switch Mini
  description:
    "Tested with Xiaomi WXKG11LM Aqara Wireless Switch Mini.\n\nController
    automation for executing any kind of action triggered by the provided Xiaomi WXKG11LM
    Aqara Wireless Switch Mini.
    \n\n You can have different actions on short press, long press, release and double press. \n\n
    Make sure to manually create a separate Text Helper per dimmer
    device and define its entity in the automation. It's used to store the last controller
    event to filter possible empty events. "
  domain: automation
  input:
    mqtt_topic:
      name: MQTT Topic
      description: Topic of the Xiaomi WXKG11LM
      default: zigbee2mqtt/<device name>
    helper_last_controller_event:
      name: (Required) Helper - Last Controller Event
      description:
        Input Text used to store the last event fired by the controller.
        You will need to manually create a text input Helper entity for this.
      default: ""
      selector:
        entity:
          domain:
            - input_text
          multiple: false
    short:
      name: SHORT button press
      description: Action to run
      default: []
      selector:
        action: {}
    long:
      name: LONG button press
      description: Action to run
      default: []
      selector:
        action: {}
    release:
      name: RELEASE of button
      description: Action to run
      default: []
      selector:
        action: {}
    double:
      name: DOUBLE button press
      description: Action to run
      default: []
      selector:
        action: {}
mode: queued
max_exceeded: silent
trigger:
  - platform: mqtt
    topic: !input mqtt_topic
condition:
  - condition: template
    value_template: "{{ trigger.payload_json.action != '' }}"
action:
  - variables:
      helper_last_controller_event: !input helper_last_controller_event
      command: "{{ trigger.payload_json.action }}"
      prev_command: "{{ states(helper_last_controller_event) }}"
  - service: input_text.set_value
    data:
      entity_id: !input helper_last_controller_event
      value: "{{ command }}"
  - choose:
      - conditions:
          - '{{ command == "single" }}'
        sequence: !input short
      - conditions:
          - '{{ command == "hold" }}'
        sequence: !input long
      - conditions:
          - '{{ command == "release" }}'
        sequence: !input release
      - conditions:
          - '{{ command == "double" }}'
        sequence: !input double

have fun
pOpY

1 Like