Forked from klaasnicolaas/z2m_ikea_styrbar_remote.yaml
Last active
July 17, 2025 13:40
-
-
Save jbouwh/fd7c2494bda68360a7fbc4c83fd71485 to your computer and use it in GitHub Desktop.
Home Assistant - Blueprint - Zigbee2MQTT - IKEA STYRBAR - 4 Button/Tradfri On/Off Remote
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
| --- | |
| blueprint: | |
| name: Z2M - IKEA styrbar (4 button)/Tradfi (On/Off) remote for lights | |
| description: | | |
| Control lights with a: | |
| - IKEA styrbar (4 button) remote [E2001/E2002](https://www.zigbee2mqtt.io/devices/E2001_E2002.html#ikea-e2001%252Fe2002). | |
| - TRADFRI on/off switch [E1743](https://www.zigbee2mqtt.io/devices/E1743.html#ikea-e1743). | |
| There are 3 different features: | |
| - Turn the light group on or off | |
| - Increase or decrease the brightness | |
| - Control the color temperature (E2001/E2002 only) | |
| domain: automation | |
| input: | |
| remote: | |
| name: IKEA 2 or 4 button remote action sensor | |
| description: > | |
| This must be an "action" sensor provided by zigbee2mqtt. For example "sensors.living_dimmer_action" | |
| selector: | |
| entity: | |
| integration: mqtt | |
| domain: sensor | |
| light: | |
| name: Light | |
| description: > | |
| The light(s group) entity you want to control. This must be a single entity, not a device or zone, to allow the color mode controls to work correctly. | |
| selector: | |
| target: | |
| entity: | |
| domain: light | |
| force_brightness: | |
| name: Force turn on brightness | |
| description: > | |
| Force the brightness to the set level below, when the "on" button on | |
| the remote is pushed and lights turn on. | |
| default: false | |
| selector: | |
| boolean: | |
| brightness: | |
| name: Brightness | |
| description: Brightness of the light(s) when turning on | |
| default: 50 | |
| selector: | |
| number: | |
| min: 0 | |
| max: 100 | |
| mode: slider | |
| step: 1 | |
| unit_of_measurement: "%" | |
| mode: restart | |
| max_exceeded: silent | |
| variables: | |
| force_brightness: !input force_brightness | |
| light_target: !input light | |
| trigger: | |
| - platform: state | |
| entity_id: !input remote | |
| # Prefent double automation triggers in restart mode | |
| not_to: "" | |
| action: | |
| - variables: | |
| command: "{{ trigger.to_state.state }}" | |
| - choose: | |
| # ---------------------------- TURN ON OR OFF ---------------------------- # | |
| - conditions: "{{ command == 'on' }}" | |
| sequence: | |
| - choose: | |
| - conditions: "{{ force_brightness }}" | |
| sequence: | |
| - service: light.turn_on | |
| target: !input light | |
| data: | |
| transition: 1 | |
| brightness_pct: !input brightness | |
| default: | |
| - service: light.turn_on | |
| target: !input light | |
| data: | |
| transition: 1 | |
| - conditions: "{{ command == 'off' }}" | |
| sequence: | |
| - service: light.turn_off | |
| target: !input light | |
| data: | |
| transition: 1 | |
| # ------------------- INCREASE OR DECREASE BRIGHTNESS -------------------- # | |
| # High - Click and hold | |
| - conditions: "{{ command == 'brightness_move_up' }}" | |
| sequence: | |
| - repeat: | |
| until: | |
| - condition: state | |
| entity_id: !input remote | |
| state: brightness_stop | |
| attribute: action | |
| sequence: | |
| - service: light.turn_on | |
| data: | |
| brightness_step_pct: 2 | |
| transition: 0.1 | |
| target: !input light | |
| - delay: 0.1 | |
| # Low - Click and hold | |
| - conditions: "{{ command == 'brightness_move_down' }}" | |
| sequence: | |
| - repeat: | |
| until: | |
| - condition: state | |
| entity_id: !input remote | |
| state: brightness_stop | |
| attribute: action | |
| sequence: | |
| - service: light.turn_on | |
| data: | |
| brightness_step_pct: -2 | |
| transition: 0.1 | |
| target: !input light | |
| - delay: 0.1 | |
| # # ------------------------ Color temp ------------------------ # | |
| # Warmer - Click left and hold | |
| - conditions: | |
| - condition: template | |
| value_template: "{{ command == 'arrow_left_hold' }}" | |
| sequence: | |
| - repeat: | |
| until: | |
| - condition: state | |
| entity_id: !input remote | |
| state: arrow_left_release | |
| attribute: action | |
| sequence: | |
| - data: | |
| kelvin: > | |
| {% set min_color_temp = state_attr(light_target.entity_id, | |
| "min_color_temp_kelvin") or 2202 %} | |
| {% set max_color_temp = state_attr(light_target.entity_id, | |
| "max_color_temp_kelvin") or 4000 %} | |
| {% set color_temp = state_attr(light_target.entity_id, | |
| "color_temp_kelvin") or 3100 %} | |
| {{ max(int(color_temp / 1.01), min_color_temp) }} | |
| transition: 0.1 | |
| target: !input light | |
| action: light.turn_on | |
| - delay: 0.1 | |
| # Colder - Click right and hold | |
| - conditions: | |
| - condition: template | |
| value_template: "{{ command == 'arrow_right_hold' }}" | |
| sequence: | |
| - repeat: | |
| until: | |
| - condition: state | |
| entity_id: !input remote | |
| state: arrow_right_release | |
| attribute: action | |
| sequence: | |
| - data: | |
| kelvin: > | |
| {% set min_color_temp = state_attr(light_target.entity_id, | |
| "min_color_temp_kelvin") | int or 2202 %} | |
| {% set max_color_temp = state_attr(light_target.entity_id, | |
| "max_color_temp_kelvin") | int or 4000 %} | |
| {% set color_temp = state_attr(light_target.entity_id, | |
| "color_temp_kelvin") or 3100 %} | |
| {{ min(int(color_temp * 1.01), max_color_temp) }} | |
| transition: 0.1 | |
| target: !input light | |
| action: light.turn_on | |
| - delay: 0.1 | |
| # Warmer - Click left | |
| - conditions: | |
| - condition: template | |
| value_template: "{{ command == 'arrow_left_click' }}" | |
| sequence: | |
| - target: !input light | |
| data: | |
| kelvin: > | |
| {% set min_color_temp = state_attr(light_target.entity_id, | |
| "min_color_temp_kelvin") or 2202 %} | |
| {% set max_color_temp = state_attr(light_target.entity_id, | |
| "max_color_temp_kelvin") or 4000 %} | |
| {% set color_temp = state_attr(light_target.entity_id, | |
| "color_temp_kelvin") or 3100 %} | |
| {{ max(int(color_temp / 1.05), min_color_temp) }} | |
| transition: 0.5 | |
| action: light.turn_on | |
| # Colder - Click right | |
| - conditions: | |
| - condition: template | |
| value_template: "{{ command == 'arrow_right_click' }}" | |
| sequence: | |
| - target: !input light | |
| data: | |
| kelvin: > | |
| {% set min_color_temp = state_attr(light_target.entity_id, | |
| "min_color_temp_kelvin") | int or 2202 %} | |
| {% set max_color_temp = state_attr(light_target.entity_id, | |
| "max_color_temp_kelvin") | int or 4000 %} | |
| {% set color_temp = state_attr(light_target.entity_id, | |
| "color_temp_kelvin") or 3100 %} | |
| {{ min(int(color_temp * 1.05), max_color_temp) }} | |
| transition: 0.5 | |
| action: light.turn_on |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment