Instantly share code, notes, and snippets.
Last active
September 7, 2025 16:48
-
Star
0
(0)
You must be signed in to star a gist -
Fork
0
(0)
You must be signed in to fork a gist
-
-
Save thomasmaxson/1b776b184882ba9c85c90c20c02b423a to your computer and use it in GitHub Desktop.
Home Assistant Blueprint to control your devices with an IKEA TRÅDFRI 5 button remote using ZHA and MQTT.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This blueprint uses an IKEA TRÅDFRI 5 Button Remote Control connected through ZHA or MQTT. | |
| # This blueprint allows you to control lights and run custom actions with the remote's buttons | |
| # | |
| # | Button Type | Interaction | Action Choices | | |
| # | -------------------- | ------------ | ------------------------------------------ | | |
| # | Power | Press | - Toggle light(s) state | | |
| # | | | - Run custom action | | |
| # | -------------------- | ------------ | ------------------------------------------ | | |
| # | Brightness, Increase | Press | - Increase light brightness (once) | | |
| # | | | - Run custom action | | |
| # | -------------------- | ------------ | ------------------------------------------ | | |
| # | Brightness, Increase | Press & Hold | - Increase light brightness (repeat) | | |
| # | | | - Run custom action | | |
| # | -------------------- | ------------ | ------------------------------------------ | | |
| # | Brightness, Decrease | Press | - Increase light brightness (once) | | |
| # | | | - Run custom action | | |
| # | -------------------- | ------------ | ------------------------------------------ | | |
| # | Brightness, Decrease | Press & Hold | - Decrease light brightness (repeat) | | |
| # | | | - Run custom action | | |
| # | -------------------- | ------------ | ------------------------------------------ | | |
| # | Arrow, Left | Press | - Adjust color temperature (once) | | |
| # | | | - Adjust light hue and saturation (once) | | |
| # | | | - Run custom action | | |
| # | -------------------- | ------------ | ------------------------------------------ | | |
| # | Arrow, Left | Press & Hold | - Adjust color temperature (repeat) | | |
| # | | | - Adjust light hue and saturation (repeat) | | |
| # | | | - Run custom action | | |
| # | -------------------- | ------------ | ------------------------------------------ | | |
| # | Arrow, Right | Press | - Adjust color temperature (once) | | |
| # | | | - Adjust light hue and saturation (once) | | |
| # | | | - Run custom action | | |
| # | -------------------- | ------------ | ------------------------------------------ | | |
| # | Arrow, Right | Press & Hold | - Adjust color temperature (repeat) | | |
| # | | | - Adjust light hue and saturation (repeat) | | |
| # | | | - Run custom action | | |
| # | -------------------- | ------------ | ------------------------------------------ | | |
| blueprint: | |
| name: IKEA TRÅDFRI, 5 Button Remote Control | |
| description: Control devices with your IKEA TRÅDFRI 5 button remote. | |
| author: Thomas Maxson | |
| source_url: https://gist.github.com/thomasmaxson/1b776b184882ba9c85c90c20c02b423a | |
| homeassistant: | |
| min_version: 2024.6.0 | |
| domain: automation | |
| input: | |
| remote: | |
| name: IKEA TRÅDFRI remote control | |
| description: Select the IKEA TRÅDFRI remote to trigger your automations. | |
| selector: | |
| device: | |
| multiple: false | |
| filter: | |
| - integration: mqtt | |
| manufacturer: IKEA | |
| model: TRADFRI remote control | |
| - integration: zha | |
| manufacturer: IKEA of Sweden | |
| model: TRADFRI remote control | |
| light: | |
| name: Light(s) | |
| description: Select the light entities you wish to control. | |
| default: [] | |
| selector: | |
| entity: | |
| multiple: true | |
| filter: | |
| domain: light | |
| power_button_config: | |
| name: Power Button Configuration | |
| icon: mdi:power | |
| collapsed: true | |
| input: | |
| event_button_power: | |
| name: Button Event Type | |
| description: >- | |
| Select the event you want the **Power Button** to do. | |
| <br>• _Toggle light_: Toggle the power state of the light(s) | |
| <br>• _Custom action_: Trigger your own custom action | |
| default: "Toggle light" | |
| selector: | |
| select: | |
| options: | |
| - label: Toggle light | |
| value: toggle | |
| - label: Custom action | |
| value: action | |
| brightness_on_percent: | |
| name: Brightness Level When Light Turns on | |
| description: >- | |
| Level of brightness to set the light(s) to when turning on. | |
| <br>• Set 1-100 to use a specific brightness level | |
| <br>• Set to 0 to use the lights last brightness level | |
| selector: | |
| number: | |
| mode: slider | |
| unit_of_measurement: "%" | |
| min: 0 | |
| max: 100.0 | |
| step: 1.0 | |
| default: 0 | |
| action_button_press_power_toggle: | |
| name: Custom Press Action | |
| description: The action to perform on _press_. | |
| default: [] | |
| selector: | |
| action: null | |
| brightness_buttons_config: | |
| name: Brightness Button Configuration | |
| icon: mdi:brightness-6 | |
| collapsed: true | |
| input: | |
| event_buttons_brightness: | |
| name: Button Event Type | |
| description: >- | |
| Select the event you want the **Brightness Buttons** to do. | |
| <br>• _Adjust brightness_: Increase/Decrease brightness of the light(s) | |
| <br>• _Custom action_: Trigger your own custom action | |
| default: "Adjust brightness" | |
| selector: | |
| select: | |
| options: | |
| - Adjust brightness | |
| - Custom action | |
| brightness_step: | |
| name: Brightness Step | |
| description: Incremental value to increase or decrease light brightness. | |
| selector: | |
| number: | |
| mode: slider | |
| unit_of_measurement: "%" | |
| min: 5 | |
| max: 100 | |
| step: 5.0 | |
| default: 20 | |
| action_button_press_raise_single: | |
| name: Brightness Increase, Press Action | |
| description: The action to perform on _press_. | |
| default: [] | |
| selector: | |
| action: null | |
| action_button_press_raise_hold: | |
| name: Brightness Increase, Press and Hold Action | |
| description: >- | |
| The action to perform on _press and hold_. | |
| <br>Use with care, before the _press and hold_ action, this buttons _press_ action gets triggered. | |
| default: [] | |
| selector: | |
| action: null | |
| action_button_press_lower_single: | |
| name: Brightness Decrease, Press Action | |
| description: The action to perform on _press_. | |
| default: [] | |
| selector: | |
| action: null | |
| action_button_press_lower_hold: | |
| name: Brightness Decrease, Press and Hold Action | |
| description: >- | |
| The action to perform on _press and hold_. | |
| <br>Use with care, before the _press and hold_ action, this buttons _press_ action gets triggered. | |
| default: [] | |
| selector: | |
| action: null | |
| arrow_buttons_config: | |
| name: Arrow Button Configuration | |
| icon: mdi:code-tags | |
| collapsed: true | |
| input: | |
| event_buttons_arrows: | |
| name: Left/Right Arrow Button Event | |
| description: >- | |
| Select what you wish for the left/right arrow buttons to manage. | |
| <br> | |
| <br>_Adjust light hue and saturation_: Adjust your selected light(s) hue and saturation. | |
| <br>• Left arrow adjusts your light(s) saturation | |
| <br>• Right arrow adjusts your light(s) hue | |
| <br> | |
| <br>_Adjust color temperature_: Adjust your selected light(s) color temperature. | |
| <br>• Left arrow decreases your light(s) color temperature | |
| <br>• Right arrow increases your light(s) color temperature | |
| <br> | |
| <br>_Custom action_: Trigger your own custom actions | |
| default: "Adjust light hue and saturation" | |
| selector: | |
| select: | |
| options: | |
| - Adjust color temperature | |
| - Adjust light hue and saturation | |
| - Custom action | |
| kelvin_temp_min: | |
| name: Color Temperature, Minimum | |
| description: >- | |
| Only used when _Adjust color temperature_ is selected | |
| selector: | |
| number: | |
| mode: slider | |
| unit_of_measurement: "K" | |
| min: 2000 | |
| max: 6500 | |
| step: 100 | |
| default: 2000 | |
| kelvin_temp_max: | |
| name: Color Temperature, Maximum | |
| description: >- | |
| Only used when _Adjust color temperature_ is selected | |
| selector: | |
| number: | |
| mode: slider | |
| unit_of_measurement: "K" | |
| min: 2000 | |
| max: 6500 | |
| step: 100 | |
| default: 6500 | |
| kelvin_step: | |
| name: Color Temperature, Step | |
| description: >- | |
| Only used when _Adjust color temperature_ is selected | |
| selector: | |
| number: | |
| mode: slider | |
| min: 0 | |
| max: 1000 | |
| step: 100 | |
| default: 250 | |
| hue_max: | |
| name: Hue, Maximum Level | |
| description: >- | |
| Only used when _Adjust light hue and saturation_ is selected | |
| selector: | |
| number: | |
| mode: slider | |
| unit_of_measurement: "degrees" | |
| min: 0 | |
| max: 360 | |
| step: 1 | |
| default: 360 | |
| hue_step: | |
| name: Hue, Step | |
| description: >- | |
| Only used when _Adjust light hue and saturation_ is selected | |
| selector: | |
| number: | |
| mode: slider | |
| min: 0 | |
| max: 36 | |
| step: 1 | |
| default: 10 | |
| saturation_min: | |
| name: Saturation, Minimum Level | |
| description: >- | |
| Only used when _Adjust light hue and saturation_ is selected | |
| selector: | |
| number: | |
| mode: slider | |
| unit_of_measurement: "%" | |
| min: 0 | |
| max: 100 | |
| step: 1 | |
| default: 0 | |
| saturation_max: | |
| name: Saturation, Maximum Level | |
| description: >- | |
| Only used when _Adjust light hue and saturation_ is selected | |
| selector: | |
| number: | |
| mode: slider | |
| unit_of_measurement: "%" | |
| min: 0 | |
| max: 100 | |
| step: 1 | |
| default: 100 | |
| saturation_step: | |
| name: Saturation, Step | |
| description: >- | |
| Only used when _Adjust light hue and saturation_ is selected | |
| selector: | |
| number: | |
| mode: slider | |
| min: 0 | |
| max: 100 | |
| step: 1 | |
| default: 10 | |
| action_button_press_left_single: | |
| name: Left Arrow, Press Action | |
| description: The action to perform on _press_. | |
| default: [] | |
| selector: | |
| action: null | |
| action_button_press_left_hold: | |
| name: Left Arrow, Press and Hold Action | |
| description: > | |
| The action to perform on _press and hold_. | |
| <br>Use with care, before the _press and hold_ action, this buttons _press_ action gets triggered. | |
| default: [] | |
| selector: | |
| action: null | |
| action_button_press_right_single: | |
| name: Right Arrow, Press Action | |
| description: The action to perform on _press_. | |
| default: [] | |
| selector: | |
| action: null | |
| action_button_press_right_hold: | |
| name: Right Arrow, Press and Hold Action | |
| description: > | |
| The action to perform on _press and hold_. | |
| <br>Use with care, before the _press and hold_ action, this buttons _press_ action gets triggered. | |
| default: [] | |
| selector: | |
| action: null | |
| automation_config: | |
| name: Configuration | |
| icon: mdi:cog | |
| collapsed: true | |
| input: | |
| sync_lights: | |
| name: Synchronize Lights | |
| description: >- | |
| Choose if all the lights will change to the same state or if all the lights should update individually based on their current state. | |
| default: true | |
| selector: | |
| boolean: | |
| repeat_delay: | |
| name: Repeat Delay | |
| description: Delay between interations when pressing and holding a button. | |
| selector: | |
| number: | |
| mode: slider | |
| unit_of_measurement: seconds | |
| min: 0.5 | |
| max: 5 | |
| step: 0.5 | |
| default: 1 | |
| repeat_max_count: | |
| name: Maximum loop repeats | |
| description: >- | |
| Maximum number of times to repeat event(s). | |
| <br>• Used as a safety limit to prevent an endless loop, just in case the corresponding stop event is not received. | |
| default: 10 | |
| selector: | |
| number: | |
| mode: slider | |
| unit_of_measurement: "times" | |
| min: 1 | |
| max: 100 | |
| step: 1 | |
| config_mode: | |
| name: Automation Mode | |
| description: Mode that automation runs in. | |
| default: restart | |
| selector: | |
| select: | |
| options: | |
| - single | |
| - restart | |
| - queued | |
| - parallel | |
| custom_value: false | |
| multiple: false | |
| config_max_num: | |
| name: Mode Max | |
| description: > | |
| Maximum number of runs that can be executed or queued at a time. | |
| <br>Ignored by _Single_ and _Restart_ Modes. | |
| default: 10 | |
| selector: | |
| number: | |
| mode: slider | |
| unit_of_measurement: "runs" | |
| min: 1.0 | |
| max: 15.0 | |
| step: 1.0 | |
| mode: !input config_mode | |
| max: !input config_max_num | |
| max_exceeded: silent | |
| variables: | |
| var_remote: !input remote | |
| var_light: !input light | |
| var_event_button_power: !input event_button_power | |
| var_event_buttons_brightness: !input event_buttons_brightness | |
| var_event_buttons_arrows: !input event_buttons_arrows | |
| var_sync_lights: !input sync_lights | |
| var_brightness_on_percent: !input brightness_on_percent | |
| var_brightness_step: !input brightness_step | |
| var_kelvin_temp_min: !input kelvin_temp_min | |
| var_kelvin_temp_max: !input kelvin_temp_max | |
| var_kelvin_step: !input kelvin_step | |
| var_hue_max: !input hue_max | |
| var_hue_step: !input hue_step | |
| var_saturation_min: !input saturation_min | |
| var_saturation_max: !input saturation_max | |
| var_saturation_step: !input saturation_step | |
| var_repeat_delay: !input repeat_delay | |
| var_repeat_max_count: !input repeat_max_count | |
| triggers: | |
| - alias: Power Button Press (via ZHA event) | |
| trigger: event | |
| event_type: zha_event | |
| event_data: | |
| device_id: !input remote | |
| command: toggle | |
| id: trigger_power_single_press_zha | |
| - alias: Power Button Press (via MQTT event) | |
| trigger: device | |
| domain: mqtt | |
| device_id: !input remote | |
| type: action | |
| subtype: "toggle" | |
| id: trigger_power_single_press_mqtt | |
| - alias: Brightness Increase Button Press (via ZHA event) | |
| trigger: event | |
| event_type: zha_event | |
| event_data: | |
| device_id: !input remote | |
| command: step_with_on_off | |
| id: trigger_raise_single_press_zha | |
| - alias: Brightness Increase Button Press (via MQTT event) | |
| trigger: device | |
| domain: mqtt | |
| device_id: !input remote | |
| type: action | |
| subtype: "brightness_up_click" | |
| id: trigger_raise_single_press_mqtt | |
| - alias: Brightness Increase Button Press and Hold (via ZHA event) | |
| trigger: event | |
| event_type: zha_event | |
| event_data: | |
| device_id: !input remote | |
| command: move_with_on_off | |
| id: trigger_raise_hold_press_zha | |
| - alias: Brightness Increase Button Press and Hold (via MQTT event) | |
| trigger: device | |
| domain: mqtt | |
| device_id: !input remote | |
| type: action | |
| subtype: "brightness_up_hold" | |
| id: trigger_raise_hold_press_mqtt | |
| - alias: Brightness Increase Button Release (via ZHA event) | |
| trigger: event | |
| event_type: zha_event | |
| event_data: | |
| device_id: !input remote | |
| command: stop_with_on_off | |
| id: trigger_raise_release_zha | |
| - alias: Brightness Increase Button Release (via MQTT event) | |
| trigger: device | |
| domain: mqtt | |
| device_id: !input remote | |
| type: action | |
| subtype: "brightness_up_release" | |
| id: trigger_raise_release_mqtt | |
| - alias: Brightness Decrease Button Press (via ZHA event) | |
| trigger: event | |
| event_type: zha_event | |
| event_data: | |
| device_id: !input remote | |
| command: "step" | |
| id: trigger_lower_single_press_zha | |
| - alias: Brightness Decrease Button Press (via MQTT event) | |
| trigger: device | |
| domain: mqtt | |
| device_id: !input remote | |
| type: action | |
| subtype: "brightness_down_click" | |
| id: trigger_lower_single_press_mqtt | |
| - alias: Brightness Decrease Button Press and Hold (via ZHA event) | |
| trigger: event | |
| event_type: zha_event | |
| event_data: | |
| device_id: !input remote | |
| command: move | |
| id: trigger_lower_hold_press_zha | |
| - alias: Brightness Decrease Button Press and Hold (via MQTT event) | |
| trigger: device | |
| domain: mqtt | |
| device_id: !input remote | |
| type: action | |
| subtype: "brightness_down_hold" | |
| id: trigger_lower_hold_press_mqtt | |
| - alias: Brightness Decrease Button Release (via ZHA event) | |
| trigger: event | |
| event_type: zha_event | |
| event_data: | |
| device_id: !input remote | |
| command: stop | |
| id: trigger_lower_release_zha | |
| - alias: Brightness Decrease Button Release (via MQTT event) | |
| trigger: device | |
| domain: mqtt | |
| device_id: !input remote | |
| type: action | |
| subtype: "brightness_down_release" | |
| id: trigger_lower_release_mqtt | |
| - alias: Left Arrow Button Press (via ZHA event) | |
| trigger: event | |
| event_type: zha_event | |
| event_data: | |
| device_id: !input remote | |
| command: press | |
| args: [257, 13, 0] | |
| id: trigger_left_single_press_zha | |
| - alias: Left Button Press (via MQTT event) | |
| trigger: device | |
| domain: mqtt | |
| device_id: !input remote | |
| type: action | |
| subtype: "arrow_left_click" | |
| id: trigger_left_single_press_mqtt | |
| - alias: Left Arrow Button Press and Hold (via ZHA event) | |
| trigger: event | |
| event_type: zha_event | |
| event_data: | |
| device_id: !input remote | |
| command: hold | |
| args: [3329, 0] | |
| id: trigger_left_hold_press_zha | |
| - alias: Left Arrow Button Press and Hold (via MQTT event) | |
| trigger: device | |
| domain: mqtt | |
| device_id: !input remote | |
| type: action | |
| subtype: "arrow_left_hold" | |
| id: trigger_left_hold_press_mqtt | |
| - alias: Left Arrow Button Release (via ZHA event) | |
| trigger: event | |
| event_type: zha_event | |
| event_data: | |
| device_id: !input remote | |
| command: release | |
| id: trigger_left_release_zha | |
| - alias: Left Arrow Button Release (via MQTT event) | |
| trigger: device | |
| domain: mqtt | |
| device_id: !input remote | |
| type: action | |
| subtype: "arrow_left_release" | |
| id: trigger_left_release_mqtt | |
| - alias: Right Arrow Button Press (via ZHA event) | |
| trigger: event | |
| event_type: zha_event | |
| event_data: | |
| device_id: !input remote | |
| command: press | |
| args: [256, 13, 0] | |
| id: trigger_right_single_press_zha | |
| - alias: Right Arrow Button Press (via ZHA event) | |
| trigger: device | |
| domain: mqtt | |
| device_id: !input remote | |
| type: action | |
| subtype: "arrow_right_click" | |
| id: trigger_right_single_press_mqtt | |
| - alias: Right Arrow Button Press and Hold (via ZHA event) | |
| trigger: event | |
| event_type: zha_event | |
| event_data: | |
| device_id: !input remote | |
| command: hold | |
| args: [3328, 0] | |
| id: trigger_right_hold_press_zha | |
| - alias: Right Arrow Button Press and Hold (via MQTT event) | |
| trigger: device | |
| domain: mqtt | |
| device_id: !input remote | |
| type: action | |
| subtype: "arrow_right_hold" | |
| id: trigger_right_hold_press_mqtt | |
| - alias: Right Arrow Button Release (via ZHA event) | |
| trigger: event | |
| event_type: zha_event | |
| event_data: | |
| device_id: !input remote | |
| command: release | |
| id: trigger_right_release_zha | |
| - alias: Right Arrow Button Release (via MQTT event) | |
| trigger: device | |
| domain: mqtt | |
| device_id: !input remote | |
| type: action | |
| subtype: "arrow_right_release" | |
| id: trigger_right_release_mqtt | |
| conditions: | |
| - alias: "Check if remote to use is set" | |
| condition: template | |
| value_template: "{{ var_remote | count > 0 }}" | |
| actions: | |
| - variables: | |
| var_all_lights_on: >- | |
| {{ expand( var_light ) | selectattr( "state", "eq", "on" ) | map( attribute = "entity_id" ) | unique | list }} | |
| var_all_lights_off: >- | |
| {{ expand( var_light ) | selectattr( "state", "eq", "off" ) | map( attribute = "entity_id" ) | unique | list }} | |
| var_first_light_on: >- | |
| {{ expand( var_light ) | selectattr( "state", "eq", "on" ) | map( attribute = "entity_id" ) | unique | list | first }} | |
| - alias: "Determine button event to execute" | |
| choose: | |
| - alias: "Button: Power, Press" | |
| conditions: | |
| - alias: "Check if triggered by Power button press" | |
| condition: trigger | |
| id: | |
| - trigger_power_single_press_zha | |
| - trigger_power_single_press_mqtt | |
| sequence: | |
| - alias: "Determine event action to trigger" | |
| choose: | |
| - alias: "For Power button press, manage light on/off state" | |
| conditions: | |
| - alias: "Check if correct action choice is selected" | |
| condition: and | |
| conditions: | |
| - alias: "Check if should toggle light(s)" | |
| condition: template | |
| value_template: "{{ var_event_button_power == 'toggle' }}" | |
| - alias: "Check if light(s) to be controlled are set" | |
| condition: template | |
| value_template: "{{ var_light | length > 0 }}" | |
| sequence: | |
| - alias: "Determine weather to turn the light(s) on or off" | |
| if: | |
| - alias: "Check if the light(s) are currently off" | |
| condition: template | |
| value_template: "{{ var_all_lights_on | length == 0 }}" | |
| then: | |
| - alias: "Determine how to turn on light(s)" | |
| if: | |
| - alias: "Check if light brightness option is greater than 0" | |
| condition: template | |
| value_template: "{{ var_brightness_on_percent | int > 0 }}" | |
| then: | |
| - alias: "Turn on light(s) with the set brightness option" | |
| action: light.turn_on | |
| target: | |
| entity_id: "{{ var_all_lights_off }}" | |
| data: | |
| brightness_pct: !input brightness_on_percent | |
| else: | |
| - alias: "Turn on light(s)" | |
| action: light.turn_on | |
| target: | |
| entity_id: "{{ var_all_lights_off }}" | |
| else: | |
| - alias: "Turn off light(s)" | |
| action: light.turn_off | |
| target: | |
| entity_id: "{{ var_all_lights_on }}" | |
| - alias: "For Power button press, run custom action" | |
| conditions: | |
| - alias: "Check if correct action choice is selected" | |
| condition: template | |
| value_template: "{{ var_event_button_power == 'action' }}" | |
| sequence: !input action_button_press_power_toggle | |
| - alias: "Button: Increase Brightness, Press" | |
| conditions: | |
| - alias: "Check if triggered by Brightness Increase button press" | |
| condition: trigger | |
| id: | |
| - trigger_raise_single_press_zha | |
| - trigger_raise_single_press_mqtt | |
| sequence: | |
| - alias: "Determine event action to trigger" | |
| choose: | |
| - alias: "For Increase Brightness button press, manage light on/off state" | |
| conditions: | |
| - alias: "Check if correct action choice is selected" | |
| condition: and | |
| conditions: | |
| - alias: "Check if should adjust brightness" | |
| condition: template | |
| value_template: "{{ var_event_buttons_brightness == 'Adjust brightness' }}" | |
| - alias: "Check if light(s) to be controlled are set" | |
| condition: template | |
| value_template: "{{ var_all_lights_on | length > 0 }}" | |
| sequence: | |
| - alias: "Determine if to turn on or increase brightness for light(s)" | |
| if: | |
| - alias: "Check if light(s) are on or off" | |
| condition: state | |
| entity_id: !input light | |
| state: "off" | |
| then: | |
| - alias: "Determine how to turn on light(s)" | |
| if: | |
| - alias: "Check if light brightness option is greater than 0" | |
| condition: template | |
| value_template: "{{ var_brightness_on_percent | int > 0 }}" | |
| then: | |
| - alias: "Turn on light(s) with the configured brightness level" | |
| action: light.turn_on | |
| target: | |
| entity_id: "{{ var_all_lights_off }}" | |
| data: | |
| brightness_pct: !input brightness_on_percent | |
| else: | |
| - alias: "Turn on light(s)" | |
| action: light.turn_on | |
| target: | |
| entity_id: "{{ var_all_lights_off }}" | |
| - alias: "For Increase Brightness button press, run custom action" | |
| conditions: | |
| - alias: "Check if correct action choice is selected" | |
| condition: template | |
| value_template: "{{ var_event_buttons_brightness == 'Custom action' }}" | |
| sequence: !input action_button_press_raise_single | |
| - alias: "Button: Increase Brightness, Press and Hold" | |
| conditions: | |
| - alias: "Check if triggered by Brightness Increase button press and hold" | |
| condition: trigger | |
| id: | |
| - trigger_raise_hold_press_zha | |
| - trigger_raise_hold_press_mqtt | |
| sequence: | |
| - alias: "Determine event action to trigger" | |
| choose: | |
| - alias: "For Increase Brightness button press, manage light on/off state" | |
| conditions: | |
| - alias: "Check if correct action choice is selected" | |
| condition: and | |
| conditions: | |
| - alias: "Check if should adjust brightness" | |
| condition: template | |
| value_template: "{{ var_event_buttons_brightness == 'Adjust brightness' }}" | |
| - alias: "Check if light(s) to be controlled are set" | |
| condition: template | |
| value_template: "{{ var_all_lights_on | length > 0 }}" | |
| sequence: | |
| - alias: "Repeat brightness increase for the light(s) that are on" | |
| repeat: | |
| until: | |
| - alias: "Check if triggered by button press" | |
| condition: trigger | |
| id: | |
| - trigger_raise_release_zha | |
| - trigger_raise_release_mqtt | |
| - alias: "Check if the maximum repeat count reached" | |
| condition: template | |
| value_template: "{{ repeat.index > var_repeat_max_count | int }}" | |
| - alias: "Wait for button to be released" | |
| condition: template | |
| value_template: "{{ wait.trigger is not none }}" | |
| sequence: | |
| - alias: "Increase brightness for light(s) that are on" | |
| action: light.turn_on | |
| target: | |
| entity_id: "{{ var_all_lights_on }}" | |
| data: | |
| brightness_step_pct: "{{ var_brightness_step * 1 | int }}" | |
| - alias: "Delay between brightness increase steps" | |
| delay: | |
| hours: 0 | |
| minutes: 0 | |
| seconds: "{{ var_repeat_delay | float }}" | |
| milliseconds: 0 | |
| - alias: "For Increase Brightness button press and hold, run custom action" | |
| conditions: | |
| - alias: "Check if correct action choice is selected" | |
| condition: template | |
| value_template: "{{ var_event_buttons_brightness == 'Custom action' }}" | |
| sequence: !input action_button_press_raise_hold | |
| - alias: "Button: Decrease Brightness, Press" | |
| conditions: | |
| - alias: "Check if triggered by Brightness Decrease button press" | |
| condition: trigger | |
| id: | |
| - trigger_lower_single_press_zha | |
| - trigger_lower_single_press_mqtt | |
| sequence: | |
| - alias: "Determine event action to trigger" | |
| choose: | |
| - alias: "For Decrease Brightness button press, manage light on/off state" | |
| conditions: | |
| - alias: "Check if correct action choice is selected" | |
| condition: and | |
| conditions: | |
| - alias: "Check if should adjust brightness" | |
| condition: template | |
| value_template: "{{ var_event_buttons_brightness == 'Adjust brightness' }}" | |
| - alias: "Check if light(s) to be controlled are set" | |
| condition: template | |
| value_template: "{{ var_all_lights_on | length > 0 }}" | |
| sequence: | |
| - alias: "Decrease brightness for light(s) that are on" | |
| action: light.turn_on | |
| target: | |
| entity_id: "{{ var_all_lights_on }}" | |
| data: | |
| brightness_step_pct: "{{ var_brightness_step * -1 | int }}" | |
| - alias: "For Decrease Brightness button press, run custom action" | |
| conditions: | |
| - alias: "Check if correct action choice is selected" | |
| condition: template | |
| value_template: "{{ var_event_buttons_brightness == 'Custom action' }}" | |
| sequence: !input action_button_press_lower_single | |
| - alias: "Button: Decrease Brightness, Press and Hold" | |
| conditions: | |
| - alias: "Check if triggered by Brightness Decrease button press and hold" | |
| condition: trigger | |
| id: | |
| - trigger_lower_hold_press_zha | |
| - trigger_lower_hold_press_mqtt | |
| sequence: | |
| - alias: "Determine event action to trigger" | |
| choose: | |
| - alias: "For Decrease Brightness button press, manage light on/off state" | |
| conditions: | |
| - alias: "Check if correct action choice is selected" | |
| condition: and | |
| conditions: | |
| - alias: "Check if should adjust brightness" | |
| condition: template | |
| value_template: "{{ var_event_buttons_brightness == 'Adjust brightness' }}" | |
| - alias: "Check if light(s) to be controlled are set" | |
| condition: template | |
| value_template: "{{ var_all_lights_on | length > 0 }}" | |
| sequence: | |
| - alias: "Repeat brightness decrease for the light(s) that are on" | |
| repeat: | |
| until: | |
| - alias: "Check if triggered by button press" | |
| condition: trigger | |
| id: | |
| - trigger_lower_release_zha | |
| - trigger_lower_release_mqtt | |
| - alias: "Check if the maximum repeat count reached" | |
| condition: template | |
| value_template: "{{ repeat.index > var_repeat_max_count | int }}" | |
| - alias: "Wait for button to be released" | |
| condition: template | |
| value_template: "{{ wait.trigger is not none }}" | |
| sequence: | |
| - alias: "Decrease brightness for light(s) that are on" | |
| action: light.turn_on | |
| target: | |
| entity_id: "{{ var_all_lights_on }}" | |
| data: | |
| brightness_step_pct: "{{ var_brightness_step * -1 | int }}" | |
| - alias: "Delay between brightness decrease steps" | |
| delay: | |
| hours: 0 | |
| minutes: 0 | |
| seconds: "{{ var_repeat_delay | float }}" | |
| milliseconds: 0 | |
| - alias: "For Decrease Brightness button press and hold, run custom action" | |
| conditions: | |
| - alias: "Check if correct action choice is selected" | |
| condition: template | |
| value_template: "{{ var_event_buttons_brightness == 'Custom action' }}" | |
| sequence: !input action_button_press_lower_hold | |
| - alias: "Button: Left Arrow, Press" | |
| conditions: | |
| - alias: "Check if triggered by Left Arrow button press" | |
| condition: trigger | |
| id: | |
| - trigger_left_single_press_zha | |
| - trigger_left_single_press_mqtt | |
| sequence: | |
| - alias: "Determine event action to trigger" | |
| choose: | |
| - alias: "For Left Arrow press, manage light saturation setting" | |
| conditions: | |
| - alias: "Confirm all conditions are met to proceed" | |
| condition: and | |
| conditions: | |
| - alias: "Check if correct action choice is selected" | |
| condition: or | |
| conditions: | |
| - alias: "Check if should adjust light color temperature" | |
| condition: template | |
| value_template: "{{ var_event_buttons_arrows == 'Adjust color temperature' }}" | |
| - alias: "Check if should adjust light hue and saturation" | |
| condition: template | |
| value_template: "{{ var_event_buttons_arrows == 'Adjust light hue and saturation' }}" | |
| - alias: "Check if light(s) to be controlled are set" | |
| condition: template | |
| value_template: "{{ var_all_lights_on | length > 0 }}" | |
| sequence: | |
| - alias: "Repeat for each light" | |
| repeat: | |
| for_each: "{{ var_all_lights_on }}" | |
| sequence: | |
| - alias: "Adjust individual light" | |
| action: light.turn_on | |
| target: | |
| entity_id: "{{ repeat.item }}" | |
| data: >- | |
| {%- if var_sync_lights == 'false' -%} | |
| {%- set current_light = repeat.item -%} | |
| {%- else -%} | |
| {%- set current_light = var_first_light_on -%} | |
| {%- endif -%} | |
| {%- if event_buttons_arrows == "Adjust light hue and saturation" -%} | |
| {%- set hue_sat_values = state_attr( current_light, 'hs_color' ) | list -%} | |
| {%- set current_hue = hue_sat_values[0] -%} | |
| {%- set current_sat = hue_sat_values[1] -%} | |
| {%- set min_sat = var_saturation_min | float -%} | |
| {%- set max_sat = var_saturation_max | float -%} | |
| {%- set target_sat = ( current_sat + var_saturation_step ) | float -%} | |
| {%- set updated_sat = min_sat if target_sat < min_sat else ( max_sat if target_sat > max_sat else target_sat ) -%} | |
| {{ dict( **{ 'hs_color' : [ current_hue, updated_sat ] } ) }} | |
| {%- elif event_buttons_arrows == "Adjust color temperature" -%} | |
| {%- set current_temp = state_attr( current_light, 'color_temp_kelvin' ) | int -%} | |
| {%- set min_temp = var_kelvin_temp_min | float -%} | |
| {%- set max_temp = var_kelvin_temp_max | float -%} | |
| {%- set target_temp = ( current_temp - var_kelvin_step ) | float -%} | |
| {%- set updated_temp = min_temp if target_temp < min_temp else ( max_temp if target_temp > max_temp else target_temp ) -%} | |
| {{ dict( **{ 'color_temp_kelvin' : updated_temp } ) }} | |
| {%- endif -%} | |
| - alias: "For Left Arrow press, trigger custom events" | |
| conditions: | |
| - alias: "Check if button press should trigger custom events" | |
| condition: template | |
| value_template: "{{ var_event_buttons_arrows == 'Custom action' }}" | |
| sequence: !input action_button_press_left_single | |
| - alias: "Button: Left Arrow, Press and Hold" | |
| conditions: | |
| - alias: "Check if triggered by Left Arrow button press and hold" | |
| condition: trigger | |
| id: | |
| - trigger_left_hold_press_zha | |
| - trigger_left_hold_press_mqtt | |
| sequence: | |
| - alias: "Determine event action to trigger" | |
| choose: | |
| - alias: "For Left Arrow press and hold, manage light saturation setting" | |
| conditions: | |
| - alias: "Confirm all conditions are met to proceed" | |
| condition: and | |
| conditions: | |
| - alias: "Check if correct action choice is selected" | |
| condition: or | |
| conditions: | |
| - alias: "Check if should adjust light color temperature" | |
| condition: template | |
| value_template: "{{ var_event_buttons_arrows == 'Adjust color temperature' }}" | |
| - alias: "Check if should adjust light hue and saturation" | |
| condition: template | |
| value_template: "{{ var_event_buttons_arrows == 'Adjust light hue and saturation' }}" | |
| - alias: "Check if light(s) to be controlled are set" | |
| condition: template | |
| value_template: "{{ var_all_lights_on | length > 0 }}" | |
| sequence: | |
| - alias: "Repeated key press for the light(s) that are on" | |
| repeat: | |
| until: | |
| - alias: "Check if triggered by button press" | |
| condition: trigger | |
| id: | |
| - trigger_left_release_zha | |
| - trigger_left_release_mqtt | |
| - alias: "Check if the maximum repeat count reached" | |
| condition: template | |
| value_template: "{{ repeat.index > var_repeat_max_count | int }}" | |
| - alias: "Wait for button to be released" | |
| condition: template | |
| value_template: "{{ wait.trigger is not none }}" | |
| sequence: | |
| - alias: "Repeat for each light" | |
| repeat: | |
| for_each: "{{ var_all_lights_on }}" | |
| sequence: | |
| - alias: "Adjust individual light" | |
| action: light.turn_on | |
| target: | |
| entity_id: "{{ repeat.item }}" | |
| data: >- | |
| {%- if var_sync_lights == 'false' -%} | |
| {%- set current_light = repeat.item -%} | |
| {%- else -%} | |
| {%- set current_light = var_first_light_on -%} | |
| {%- endif -%} | |
| {%- if event_buttons_arrows == "Adjust light hue and saturation" -%} | |
| {%- set hue_sat_values = state_attr( current_light, 'hs_color' ) | list -%} | |
| {%- set current_hue = hue_sat_values[0] -%} | |
| {%- set current_sat = hue_sat_values[1] -%} | |
| {%- set min_sat = var_saturation_min | float -%} | |
| {%- set max_sat = var_saturation_max | float -%} | |
| {%- set target_sat = ( current_sat + var_saturation_step ) | float -%} | |
| {%- set updated_sat = min_sat if target_sat < min_sat else ( max_sat if target_sat > max_sat else target_sat ) -%} | |
| {{ dict( **{ 'hs_color' : [ current_hue, updated_sat ] } ) }} | |
| {%- elif event_buttons_arrows == "Adjust color temperature" -%} | |
| {%- set current_temp = state_attr( current_light, 'color_temp_kelvin' ) | int -%} | |
| {%- set min_temp = var_kelvin_temp_min | float -%} | |
| {%- set max_temp = var_kelvin_temp_max | float -%} | |
| {%- set target_temp = ( current_temp - var_kelvin_step ) | float -%} | |
| {%- set updated_temp = min_temp if target_temp < min_temp else ( max_temp if target_temp > max_temp else target_temp ) -%} | |
| {{ dict( **{ 'color_temp_kelvin' : updated_temp } ) }} | |
| {%- endif -%} | |
| - alias: "Delay between right arrow adjust hue steps" | |
| delay: | |
| hours: 0 | |
| minutes: 0 | |
| seconds: 0 | |
| milliseconds: 500 | |
| - alias: "For Left Arrow press and hold, run custom action" | |
| conditions: | |
| - alias: "Check if correct action choice is selected" | |
| condition: template | |
| value_template: "{{ var_event_buttons_arrows == 'Custom action' }}" | |
| sequence: !input action_button_press_left_hold | |
| - alias: "Button: Right Arrow, Press" | |
| conditions: | |
| - alias: "Check if triggered by Right Arrow button press" | |
| condition: trigger | |
| id: | |
| - trigger_right_single_press_zha | |
| - trigger_right_single_press_mqtt | |
| sequence: | |
| - alias: "Determine event action to trigger" | |
| choose: | |
| - alias: "For Right Arrow press, manage light saturation setting" | |
| conditions: | |
| - alias: "Confirm all conditions are met to proceed" | |
| condition: and | |
| conditions: | |
| - alias: "Check if correct action choice is selected" | |
| condition: or | |
| conditions: | |
| - alias: "Check if should adjust light color temperature" | |
| condition: template | |
| value_template: "{{ var_event_buttons_arrows == 'Adjust color temperature' }}" | |
| - alias: "Check if should adjust light hue and saturation" | |
| condition: template | |
| value_template: "{{ var_event_buttons_arrows == 'Adjust light hue and saturation' }}" | |
| - alias: "Check if light(s) to be controlled are set" | |
| condition: template | |
| value_template: "{{ var_all_lights_on | length > 0 }}" | |
| sequence: | |
| - alias: "Repeat for each light" | |
| repeat: | |
| for_each: "{{ var_all_lights_on }}" | |
| sequence: | |
| - alias: "Adjust individual light" | |
| action: light.turn_on | |
| target: | |
| entity_id: "{{ repeat.item }}" | |
| data: >- | |
| {%- if var_sync_lights == 'false' -%} | |
| {%- set current_light = repeat.item -%} | |
| {%- else -%} | |
| {%- set current_light = var_first_light_on -%} | |
| {%- endif -%} | |
| {%- if event_buttons_arrows == "Adjust light hue and saturation" -%} | |
| {%- set hue_sat_values = state_attr( current_light, 'hs_color' ) | list -%} | |
| {%- set current_hue = hue_sat_values[0] -%} | |
| {%- set current_sat = hue_sat_values[1] -%} | |
| {%- set max_hue = var_hue_max | float -%} | |
| {%- set target_hue = ( current_hue + var_hue_step ) | float -%} | |
| {%- set updated_hue = ( target_hue - max_hue ) if target_hue > max_hue else target_hue -%} | |
| {{ dict( **{ 'hs_color' : [ updated_hue, current_sat ] } ) }} | |
| {%- elif event_buttons_arrows == "Adjust color temperature" -%} | |
| {%- set current_temp = state_attr( current_light, 'color_temp_kelvin' ) | int -%} | |
| {%- set min_temp = var_kelvin_temp_min | float -%} | |
| {%- set max_temp = var_kelvin_temp_max | float -%} | |
| {%- set target_temp = ( current_temp + var_kelvin_step ) | float -%} | |
| {%- set updated_temp = min_temp if target_temp < min_temp else ( max_temp if target_temp > max_temp else target_temp ) -%} | |
| {{ dict( **{ 'color_temp_kelvin' : updated_temp } ) }} | |
| {%- endif -%} | |
| - alias: "For Right Arrow press, trigger custom events" | |
| conditions: | |
| - alias: "Check if button press should trigger custom events" | |
| condition: template | |
| value_template: "{{ var_event_buttons_arrows == 'Custom action' }}" | |
| sequence: !input action_button_press_right_single | |
| - alias: "Button: Right Arrow, Press and Hold" | |
| conditions: | |
| - alias: "Check if triggered by Right Arrow button press and hold" | |
| condition: trigger | |
| id: | |
| - trigger_right_hold_press_zha | |
| - trigger_right_hold_press_mqtt | |
| sequence: | |
| - alias: "Determine event action to trigger" | |
| choose: | |
| - alias: "For Right Arrow press and hold, manage light saturation setting" | |
| conditions: | |
| - alias: "Confirm all conditions are met to proceed" | |
| condition: and | |
| conditions: | |
| - alias: "Check if correct action choice is selected" | |
| condition: or | |
| conditions: | |
| - alias: "Check if should adjust light color temperature" | |
| condition: template | |
| value_template: "{{ var_event_buttons_arrows == 'Adjust color temperature' }}" | |
| - alias: "Check if should adjust light hue and saturation" | |
| condition: template | |
| value_template: "{{ var_event_buttons_arrows == 'Adjust light hue and saturation' }}" | |
| - alias: "Check if light(s) to be controlled are set" | |
| condition: template | |
| value_template: "{{ var_all_lights_on | length > 0 }}" | |
| sequence: | |
| - alias: "Repeated key press for the light(s) that are on" | |
| repeat: | |
| until: | |
| - alias: "Check if triggered by button press" | |
| condition: trigger | |
| id: | |
| - trigger_right_release_zha | |
| - trigger_right_release_mqtt | |
| - alias: "Check if the maximum repeat count reached" | |
| condition: template | |
| value_template: "{{ repeat.index > var_repeat_max_count | int }}" | |
| - alias: "Wait for button to be released" | |
| condition: template | |
| value_template: "{{ wait.trigger is not none }}" | |
| sequence: | |
| - alias: "Repeat for each light" | |
| repeat: | |
| for_each: "{{ var_all_lights_on }}" | |
| sequence: | |
| - alias: "Adjust individual light" | |
| action: light.turn_on | |
| target: | |
| entity_id: "{{ repeat.item }}" | |
| data: >- | |
| {%- if var_sync_lights == 'false' -%} | |
| {%- set current_light = repeat.item -%} | |
| {%- else -%} | |
| {%- set current_light = var_first_light_on -%} | |
| {%- endif -%} | |
| {%- if event_buttons_arrows == "Adjust light hue and saturation" -%} | |
| {%- set hue_sat_values = state_attr( current_light, 'hs_color' ) | list -%} | |
| {%- set current_hue = hue_sat_values[0] -%} | |
| {%- set current_sat = hue_sat_values[1] -%} | |
| {%- set max_hue = var_hue_max | float -%} | |
| {%- set target_hue = ( current_hue + var_hue_step ) | float -%} | |
| {%- set updated_hue = ( target_hue - max_hue ) if target_hue > max_hue else target_hue -%} | |
| {{ dict( **{ 'hs_color' : [ updated_hue, current_sat ] } ) }} | |
| {%- elif event_buttons_arrows == "Adjust color temperature" -%} | |
| {%- set current_temp = state_attr( current_light, 'color_temp_kelvin' ) | int -%} | |
| {%- set min_temp = var_kelvin_temp_min | float -%} | |
| {%- set max_temp = var_kelvin_temp_max | float -%} | |
| {%- set target_temp = ( current_temp + var_kelvin_step ) | float -%} | |
| {%- set updated_temp = min_temp if target_temp < min_temp else ( max_temp if target_temp > max_temp else target_temp ) -%} | |
| {{ dict( **{ 'color_temp_kelvin' : updated_temp } ) }} | |
| {%- endif -%} | |
| - alias: "Delay between right arrow adjust hue steps" | |
| delay: | |
| hours: 0 | |
| minutes: 0 | |
| seconds: 0 | |
| milliseconds: 500 | |
| - alias: "For Right Arrow press and hold, run custom action" | |
| conditions: | |
| - alias: "Check if correct action choice is selected" | |
| condition: template | |
| value_template: "{{ var_event_buttons_arrows == 'Custom action' }}" | |
| sequence: !input action_button_press_right_hold |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment