- Add COMMAND mode variants for Aqara H1 dial blueprints

This commit is contained in:
nwithan8 2023-08-10 16:33:01 -06:00
parent 6e1b69d80b
commit 9d9e06e38b
4 changed files with 213 additions and 2 deletions

View File

@ -1,11 +1,16 @@
# This blueprint allows you to map actions to the different controls on an Aqara H1 Rotary Dial (https://homekitnews.com/2020/11/02/aqara-reveal-smart-rotary-dimmer-switch/)
#
# This ZigBee device is not currently supported by ZHA, and requires a custom ZHA quirk: https://gist.github.com/oxc/754d6436ce62d92af660d3671acd9346
# This ZigBee device is already supported by Z2M: https://github.com/zigpy/zha-device-handlers/issues/2266
#
# This automation is built for a device in EVENT mode rather than COMMAND mode. As there is some cross-over between the two modes, it is NOT recommended to use automations for both modes at the same time.
blueprint:
name: Aqara H1 Rotary Dial - Remote
name: Aqara H1 Rotary Dial - Remote (Event Mode)
aqara_h1_rotary_dial_remote:
yaml:
source_url: https://raw.githubusercontent.com/nwithan8/configs/main/home_assistant/blueprints/automations/aqara_h1_rotary_dial_remote.yaml
description: >-
This automation allows using an Aqara H1 Rotary Dial (ZigBee) to trigger actions.

View File

@ -0,0 +1,93 @@
# This blueprint allows you to map actions to the different controls on an Aqara H1 Rotary Dial (https://homekitnews.com/2020/11/02/aqara-reveal-smart-rotary-dimmer-switch/)
#
# This ZigBee device is not currently supported by ZHA, and requires a custom ZHA quirk: https://gist.github.com/oxc/754d6436ce62d92af660d3671acd9346
# This ZigBee device is already supported by Z2M: https://github.com/zigpy/zha-device-handlers/issues/2266
#
# This automation is built for a device in COMMAND mode rather than EVENT mode. As there is some cross-over between the two modes, it is NOT recommended to use automations for both modes at the same time.
blueprint:
name: Aqara H1 Rotary Dial - Remote (Command Mode)
source_url: https://raw.githubusercontent.com/nwithan8/configs/main/home_assistant/blueprints/automations/aqara_h1_rotary_dial_remote_command_mode.yaml
aqara_h1_rotary_dial_remote:
yaml:
description: >-
This automation allows using an Aqara H1 Rotary Dial (ZigBee) to trigger actions.
Requires a custom quirk if using with ZHA.
domain: automation
input:
dial:
name: Aqara H1 Rotary Dial
description: Select the rotary dial you wish to use
selector:
device:
integration: zha
manufacturer: LUMI
model: lumi.remote.rkba01
double:
name: Double Press
description: The action to perform on a double press of the dial button
selector:
action:
default: []
long:
name: Long Press
description: The action to perform on a long press of the dial button
selector:
action:
default: []
left:
name: Left Turn
description: The action to perform on rotating the dial to the left
selector:
action:
default: []
right:
name: Right Turn
description: The action to perform on rotating the dial to the right
selector:
action:
default: []
mode: restart
max_exceeded: silent
trigger:
- platform: event
event_type: zha_event
event_data:
device_id: !input dial
action:
- choose:
# Double press on the button
- conditions:
- condition: template
value_template: '{{ trigger.event.data.command == "toggle" }}'
sequence: !input double
# Long press on the button
- conditions:
- condition: template
value_template: '{{ trigger.event.data.command == "off" }}'
sequence: !input long
# Rotate dial to the left
- conditions:
- condition: template
value_template: '{{ trigger.event.data.command == "stop_rotation" and trigger.event.data.args.rotation_direction == -1 }}'
sequence: !input left
# Rotate dial to the right
- conditions:
- condition: template
value_template: '{{ trigger.event.data.command == "stop_rotation" and trigger.event.data.args.rotation_direction == 1 }}'
sequence: !input right
# Any other event will cancel the repeat loops.
default: []

View File

@ -3,6 +3,8 @@
#
# This ZigBee device is not currently supported by ZHA, and requires a custom ZHA quirk: https://gist.github.com/oxc/754d6436ce62d92af660d3671acd9346
# This ZigBee device is already supported by Z2M: https://github.com/zigpy/zha-device-handlers/issues/2266
#
# # This automation is built for a device in EVENT mode rather than COMMAND mode. As there is some cross-over between the two modes, it is NOT recommended to use automations for both modes at the same time.
blueprint:
name: Aqara H1 Rotary Dial - Media Controls

View File

@ -0,0 +1,111 @@
# This blueprint allows you to control a media player with a Aqara H1 Rotary Dial (https://homekitnews.com/2020/11/02/aqara-reveal-smart-rotary-dimmer-switch/)
# This automation requires a boolean (toggle) helper to maintain state: https://www.home-assistant.io/integrations/input_boolean/
#
# This ZigBee device is not currently supported by ZHA, and requires a custom ZHA quirk: https://gist.github.com/oxc/754d6436ce62d92af660d3671acd9346
# This ZigBee device is already supported by Z2M: https://github.com/zigpy/zha-device-handlers/issues/2266
#
# # This automation is built for a device in COMMAND mode rather than EVENT mode. As there is some cross-over between the two modes, it is NOT recommended to use automations for both modes at the same time.
blueprint:
name: Aqara H1 Rotary Dial - Media Controls (Command Mode)
source_url: https://raw.githubusercontent.com/nwithan8/configs/main/home_assistant/blueprints/automations/aqara_h1_rotary_dial_remote_media_command_mode.yaml
description: >-
This automation allows using an Aqara H1 Rotary Dial to control a media player.
Requires a custom ZHA quirk until official ZHA support is added.
Requires a boolean (toggle) helper to store modes.
domain: automation
input:
dial:
name: Aqara H1 Rotary Dial
description: Select the rotary dial you wish to use
selector:
device:
integration: zha
manufacturer: LUMI
model: lumi.remote.rkba01
media_player:
name: Media Player
description: The media player to control
selector:
target:
entity:
domain: media_player
mode_helper:
name: Mode toggle helper
description: A boolean (toggle) helper to store the current mode in
selector:
entity:
domain: input_boolean
mode: restart
max_exceeded: silent
trigger:
- platform: event
event_type: zha_event
event_data:
device_id: !input dial
action:
- choose:
# Play/pause on long press
- conditions:
- condition: template
value_template: '{{ trigger.event.data.command == "off" }}'
sequence:
- service: media_player.media_play_pause
data: {}
target: !input media_player
# Toggle mode on double press
- conditions:
- condition: template
value_template: '{{ trigger.event.data.command == "toggle" }}'
sequence:
- service: input_boolean.toggle
data: {}
target:
entity_id: !input mode_helper
# Volume down / previous track on left turn
- conditions:
- condition: template
value_template: '{{ trigger.event.data.command == "stop_rotation" and trigger.event.data.args.rotation_direction == -1 }}'
sequence:
- if:
- condition: state
entity_id: !input mode_helper
state: "on"
then:
- service: media_player.media_previous_track
data: {}
target: !input media_player
else:
- service: media_player.volume_down
data: {}
target: !input media_player
# Volume up / next track on right turn
- conditions:
- condition: template
value_template: '{{ trigger.event.data.command == "stop_rotation" and trigger.event.data.args.rotation_direction == 1 }}'
sequence:
- if:
- condition: state
entity_id: !input mode_helper
state: "on"
then:
- service: media_player.media_next_track
data: {}
target: !input media_player
else:
- service: media_player.volume_up
data: {}
target: !input media_player
# Any other event will cancel the repeat loops.
default: []