Skip to content

Instantly share code, notes, and snippets.

@niro1987
Last active January 15, 2024 13:02
Show Gist options
  • Save niro1987/f60ab7ec01facdc7d9cab861f4a4abe5 to your computer and use it in GitHub Desktop.
Save niro1987/f60ab7ec01facdc7d9cab861f4a4abe5 to your computer and use it in GitHub Desktop.
Home Assistant - Blueprint - Zigbee2MQTT - IKEA TRADFRI - 5 Button Remote - Custom Actions
---
# This automation simulates the use of the IKEA TRADFRI Remote control
# connected through Zigbee2MQTT.
blueprint:
source_url: https://gist.github.com/niro1987/f60ab7ec01facdc7d9cab861f4a4abe5
name: Zigbee2MQTT - IKEA TRADFRI - 5 Button Remote - Custom Actions
description: >-
This automation simulates the use of the IKEA TRADFRI Remote control
connected through Zigbee2MQTT.
domain: automation
input:
remote_entity:
name: Remote Sensor Entity
description: The sensor entity created by Zigbee2MQTT
selector:
entity:
domain: sensor
default: sensor.ikea_tradfri_action
power_short:
name: Short Press - Power Button
description: The action to perform on Short Press of the Power Button
selector:
action:
default: []
dimup_short:
name: Short Press - Dim Up Button
description: The action to perform on Short Press of the Dim Up Button
selector:
action:
default: []
dimdown_short:
name: Short Press - Dim Down Button
description: The action to perform on Short Press of the Dim Down Button
selector:
action:
default: []
colorup_short:
name: Short Press - Color Up Button
description: The action to perform on Short Press of the Color Up Button
selector:
action:
default: []
colordown_short:
name: Short Press - Color Down Button
description: The action to perform on Short Press of the Color Down Button
selector:
action:
default: []
power_long:
name: Long Press - Power Button
description: The action to perform on Long Press of the Power Button
selector:
action:
default: []
dimup_long:
name: Long Press - Dim Up Button
description: The action to perform on Long Press of the Dim Up Button
selector:
action:
default: []
dimdown_long:
name: Long Press - Dim Down Button
description: The action to perform on Long Press of the Dim Down Button
selector:
action:
default: []
colorup_long:
name: Long Press - Color Up Button
description: The action to perform on Long Press of the Color Up Button
selector:
action:
default: []
colordown_long:
name: Long Press - Color Down Button
description: The action to perform on Long Press of the Color Down Button
selector:
action:
default: []
mode: restart
trigger:
- platform: state
entity_id: !input remote_entity
to:
- "toggle"
- "toggle_hold"
- "brightness_up_click"
- "brightness_down_click"
- "arrow_left_click"
- "arrow_right_click"
- "brightness_up_hold"
- "brightness_down_hold"
- "arrow_left_hold"
- "arrow_right_hold"
- "brightness_up_release"
- "brightness_down_release"
- "arrow_left_release"
- "arrow_right_release"
action:
- choose:
# Short-Press on the power button.
- conditions:
- condition: template
value_template: '{{ trigger.to_state.state == "toggle" }}'
sequence: !input power_short
# Short-Press on the dim-up button.
- conditions:
- condition: template
value_template: '{{ trigger.to_state.state == "brightness_up_click" }}'
sequence: !input dimup_short
# Short-Press on the dim-down button.
- conditions:
- condition: template
value_template: '{{ trigger.to_state.state == "brightness_down_click" }}'
sequence: !input dimdown_short
# Short-Press on the color-up button.
- conditions:
- condition: template
value_template: '{{ trigger.to_state.state == "arrow_left_click" }}'
sequence: !input colorup_short
# Short-Press on the color-down button.
- conditions:
- condition: template
value_template: '{{ trigger.to_state.state == "arrow_right_click" }}'
sequence: !input colordown_short
# Long-Press on the power button.
- conditions:
- condition: template
value_template: '{{ trigger.to_state.state == "toggle_hold" }}'
sequence: !input power_long
# Long-Press on the color-up button.
- conditions:
- condition: template
value_template: '{{ trigger.to_state.state == "arrow_left_hold" }}'
sequence: !input colorup_long
# Long-Press on the color-down button.
- conditions:
- condition: template
value_template: '{{ trigger.to_state.state == "arrow_right_hold" }}'
sequence: !input colordown_long
# Long-Press on the dim-up button.
- conditions:
- condition: template
value_template: '{{ trigger.to_state.state == "brightness_up_hold" }}'
sequence: !input dimup_long
# Long-Press on the dim-down button.
- conditions:
- condition: template
value_template: '{{ trigger.to_state.state == "brightness_down_hold" }}'
sequence: !input dimdown_long
# Any other event will cancel the repeat loops.
default: []
@made-indrayana
Copy link

made-indrayana commented Sep 19, 2022

Hey man, great code! I am enjoying your hard work right now with my new Home Assistant learning journey :)

I have a suggestion that is already implemented in your zha script but not here, which is the default: [] configuration for each button. Without this I am forced to add all action to each buttons.

Thanks again and have a good day :)

@niro1987
Copy link
Author

Hey man, great code! I am enjoying your hard work right now with my new Home Assistant learning journey :)

I have a suggestion that is already implemented in your zha script but not here, which is the default: [] configuration for each button. Without this I am forced to add all action to each buttons.

Thanks again and have a good day :)

updated the code

@made-indrayana
Copy link

Hey man, great code! I am enjoying your hard work right now with my new Home Assistant learning journey :)
I have a suggestion that is already implemented in your zha script but not here, which is the default: [] configuration for each button. Without this I am forced to add all action to each buttons.
Thanks again and have a good day :)

updated the code

thanks a lot man!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment