Using AppDaemon I managed to add dimmer functionality to the xiaomi button Model no. WXKG11LM.
The AppDaemon script adds a binary sensor state which allows automations like:
- alias: Button - Hold 1s to dim lights
trigger:
platform: state
entity_id: binary_sensor.xiaomi_button
to: 'on'
for:
seconds: 1
action:
- service: light.turn_on
entity_id: all
data:
brightness_pct: 75
- alias: Button - Hold 2s to dim lights
trigger:
platform: state
entity_id: binary_sensor.xiaomi_button
to: 'on'
for:
seconds: 2
action:
- service: light.turn_on
entity_id: all
data:
brightness_pct: 50
- alias: Button - Hold 3s to dim lights
trigger:
platform: state
entity_id: binary_sensor.xiaomi_button
to: 'on'
for:
seconds: 3
action:
- service: light.turn_on
entity_id: all
data:
brightness_pct: 25
- alias: Button - Hold 4s to dim lights
trigger:
platform: state
entity_id: binary_sensor.xiaomi_button
to: 'on'
for:
seconds: 4
action:
- service: light.turn_on
entity_id: all
data:
brightness_pct: 1
So holding the button will make the light to decrease. In top of that is possible to create automations like the xiaomi binary sensor:
- alias: Button - Click to toggle ligths
trigger:
platform: event
event_type: xiaomi_aqara.click
event_data:
entity_id: binary_sensor.xiaomi_button
action_type: single
action:
- service: light.toggle
entity_id: all
Take a look to my previous post if you are interested to add extra functionality to the xiaomi magic cube