deCONZ - Xiaomi Mijia Wireless Switch

Blueprint to support the Xiaomi Mijia Wireless Switch (single button). Combine actions for all gestures in a single automation.

Supported actions:

  • Single press (in)
  • Single press (release)
  • Double press
  • Tripple press
  • Quintuple press
  • Many presses (> 5 times in a row)
  • Long press

Blueprint to use:

blueprint:
  name: deCONZ - Xiaomi Mijia Wireless Switch
  description: Control anything using Xiaomi Mijia (single button) remote
  domain: automation
  input:
    remote:
      name: Remote
      description: Button to use
      selector:
        device:
          integration: deconz
          manufacturer: LUMI
          model: lumi.sensor_switch

    button_press_in:
      name: "Single pressed in"
      default: []
      selector:
        action: {}

    button_press_release:
      name: "Single press (release)"
      default: []
      selector:
        action: {}

    button_long_press:
      name: Long press
      default: []
      selector:
        action: {}

    button_double_press:
      name: Double press
      default: []
      selector:
        action: {}

    button_triple_press:
      name: Triple press
      default: []
      selector:
        action: {}

    button_quintuple_press:
      name: Quintuple press
      default: []
      selector:
        action: {}

    button_many_presses:
      name: Many presses
      description: "Action to run when the button is pressed more than 5 times in rapid succession"
      default: []
      selector:
        action: {}

mode: restart
max_exceeded: silent
trigger:
- platform: event
  event_type: deconz_event
  event_data:
    device_id: !input 'remote'
action:
- variables:
    event: '{{ trigger.event.data.event }}'
- choose:
  - conditions:
    - '{{ event == 1000 }}'
    sequence: !input 'button_press_in'

  - conditions:
    - '{{ event == 1002 }}'
    sequence: !input 'button_press_release'

  - conditions:
    - '{{ event == 1003 }}'
    sequence: !input 'button_long_press'

  - conditions:
    - '{{ event == 1004 }}'
    sequence: !input 'button_double_press'

  - conditions:
    - '{{ event == 1005 }}'
    sequence: !input 'button_triple_press'

  - conditions:
    - '{{ event == 1006 }}'
    sequence: !input 'button_quintuple_press'

  - conditions:
    - '{{ event == 1010 }}'
    sequence: !input 'button_many_presses'
5 Likes

This is excellent!
I think though the quadruple press is missing :wink:

Hi,
I’m testing this on my side and I have different event codes (via dev tool - event listener):
4 press = 1006
5 press or more = 1010

Could there be differences per device?

Hi all. has anyone found this switch has stopped working in Home assistant 21.7 onwards. I have 2 of these and they have both stopped working. still show in deconz and in home assistant they show in the blueprint but will not work

I have the some problem. 2 x switches stop working and I can not find them in the dropdown where I need to select them.

I am getting this error since last update

core-2021.10.3

UndefinedError: ‘dict object’ has no attribute ‘event’

Define variables event
Stopped because an error was encountered at 12 October 2021, 11:40:38 (runtime: 0.01 seconds)

UndefinedError: ‘dict object’ has no attribute ‘event’