Thanks but what about pairing the remote only to bulbs? Not adding it in ZHA. Are you saying that the BULBS cannot be controlled both by ZHA and the remote?
If you pair both the remote and and the bulb with ZHA them Home Assistant can listen for the remote and control the bulb
Sorry for being unclear. My intention is:
Pair bulbs with ZHA
NOT pair remote with ZHA
Pair remote only with bulbs
Hopefully possible?
No it’s not possible, as said before
A device, any ZigBee device, can only be paired with one controller
So the BULBS can only be paired EITHER to ZHA or the physical STYRBAR? Because I am not intending to pair the rmote (STYRBAR) to ZHA.
ZHA <------ Bulbs -------> STYRBAR
The goal is to be able to use STYRBAR as usual without pairing it to ZHA (you pair it physically standing close to the bulbs). While we can control the bulbs through the paired STYRBAR or from home assistant.
Seriously??
Are you joking or something not connected?
No it will not work!
It doesn’t matter how many times you ask, the answer will be the same.
I mean look at every reply you have written to the question, you’re writing about pairing the remote to ZHA which is the opposite of my intention and the question in mind. Maybe a clear answer would be:
“No you cant pair BULBS to BOTH ZHA and a physical remote (STYRBAR)”
I assume that’s the answer, so I’d have to pick between controlling my bulbs through the remote or through HA. Thanks anyhow for your answers.
I’ll explore this blueprint route and learn about it so that we can pair the STYRBAR but still have dimmable capability, something I missed last I tried.
Hey there, you can just pair both devices via ZHA and use this blueprint. Even dimming is possible with this one (though not as smooth as when pairing the remote and bulbs directly). Give it a shot and I’m happy to assist if you have any questions.
Seems pretty clear to me…
Great, thanks Malte!
Thank you @Malte for this blueprint! I found it when trying to automate my STYRBAR and IKEA lights. I wanted the left and right buttons to support rotating through a user-selectable choice of color temperature, color name, or RGB-code colors.
I’m new to blueprints (and the home-assistant community) and couldn’t see a way to add this feature using the provided Left button/Right button action blocks (there may be a way but I don’t know it yet). So, I modified the blueprint to rely on a helper and took over the left-button and right-button short presses.
Here’s the blueprint. I’d welcome feedback on it.
---
# This blueprint controls lights through an IKEA STYRBAR remote connected via ZHA.
blueprint:
name: ZHA - IKEA STYRBAR control for IKEA TRADFRI color bulbs
description: 'Control lights with an IKEA STYRBAR four button remote (the square ones),
for use with [ZHA](https://www.home-assistant.io/integrations/zha/).
It adds color selection and extends [Malte](https://community.home-assistant.io/u/Malte)''s [blueprint](https://community.home-assistant.io/t/zha-ikea-four-button-remote-styrbar-for-lights-e2001-e2002/384482).
That, in turn, is based on [SwerveShot](https://community.home-assistant.io/u/SwerveShot)''s [version](https://community.home-assistant.io/t/zha-ikea-four-button-remote-for-lights/347657)
which is based on the work of [frenck](https://community.home-assistant.io/u/frenck).
Pressing the up button will turn on the lights at the last set brightness and color (unless
the force brightness is toggled on in the blueprint). Pressing the down button will turn the lights off again.
Pressing and holding the up/down buttons will change the brightness smoothly and
can be pressed and hold until the brightness is satisfactory.
Short presses of the "left" and "right" buttons rotate through the colours in the associated helper.
Valid values are: <integer> color temperature in Kelvin (e.g. 2700), <#RGBCODE> RGB color code (e.g. #FFFAFA), or <ColorName> color name (e.g. lightskyblue) listed in [homeassistant source](https://github.com/home-assistant/core/blob/d68ee8dceae7acd2fbdc2be0724847ac0827dcde/homeassistant/util/color.py) which is based on [CSS3 color names](https://www.w3.org/TR/css-color-3/#svg-color).
If the entry isn''t a number, and doesn''t start with a "\#", then it is treated as a colorname.
An initial useful set of values for the helper could be 4000, 2700, 2200, 1780, gold, darksalmon, pink, mediumpurple, mediumblue.
The "left" and "right" buttons can be assigned to a long button press
action. This allows you to assign, e.g., a scene or anything else. Use the left
and right button events with care, as before the long press event is sent, the
"on" event gets triggered.
'
domain: automation
input:
remote:
name: Remote
description: IKEA remote to use
selector:
device:
integration: zha
manufacturer: IKEA of Sweden
model: Remote Control N2
multiple: false
light:
name: Light(s)
description: The light(s) to control
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.0
max: 100.0
mode: slider
step: 1.0
unit_of_measurement: '%'
hold_time:
name: Hold Time
description: Time between the execution of the brighter/darker actions when
holding the brighter/darker button.
default: 0.2
selector:
number:
min: 0.1
max: 2.0
step: 0.1
unit_of_measurement: seconds
mode: slider
color_set:
name: Color and Temperature List
description: Select (or create) a helper listing the colors to use with left and right button presses.
Accepts color names, RGB hex color codes, or integer numeric values for temperature in Kelvin.
default: []
selector:
entity:
filter:
- domain:
- input_select
multiple: false
button_left_long:
name: Left button - long press
description: Action to run on long left button press. Use with care, as before
the long press event is sent, the "on" event gets triggered.
default: []
selector:
action: {}
button_right_long:
name: Right button - long press
description: Action to run on long right button press. Use with care, as before
the long press event is sent, the "on" event gets triggered.
default: []
selector:
action: {}
source_url: https://github.com/kedmison/homeassistant-config/blob/6306fdfd9a710a9edba37b50d79cf89cba426745/blueprints/automation/kedmison/zha-ikea-styrbar-4button-for-color-lights.yaml
mode: restart
max_exceeded: silent
variables:
force_brightness: !input force_brightness
color_set: !input color_set
trigger:
- platform: event
event_type: zha_event
event_data:
device_id: !input remote
action:
- variables:
command: '{{ trigger.event.data.command }}'
cluster_id: '{{ trigger.event.data.cluster_id }}'
endpoint_id: '{{ trigger.event.data.endpoint_id }}'
args: '{{ trigger.event.data.args }}'
- choose:
- conditions: # Up button, short press
- '{{ command == ''on'' }}'
- '{{ cluster_id == 6 }}'
- '{{ endpoint_id == 1 }}'
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: # Down button, short press
- '{{ command == ''off'' }}'
- '{{ cluster_id == 6 }}'
- '{{ endpoint_id == 1 }}'
sequence:
- service: light.turn_off
target: !input light
data:
transition: 1
- conditions: # Up button, long press
- '{{ command == ''move_with_on_off'' }}'
- '{{ cluster_id == 8 }}'
- '{{ endpoint_id == 1 }}'
sequence:
- repeat:
count: 10
sequence:
- service: light.turn_on
target: !input light
data:
brightness_step_pct: 10
transition: !input hold_time
- delay: !input hold_time
- conditions: # Down button, long press
- '{{ command == ''move'' }}'
- '{{ cluster_id == 8 }}'
- '{{ endpoint_id == 1 }}'
sequence:
- repeat:
count: 10
sequence:
- service: light.turn_on
target: !input light
data:
brightness_step_pct: -10
transition: !input hold_time
- delay: !input hold_time
- conditions: # Left button, short press
- '{{ command == ''press'' }}'
- '{{ cluster_id == 5 }}'
- '{{ endpoint_id == 1 }}'
- '{{ args == [257, 13, 0] }}'
sequence:
- service: input_select.select_previous
data:
entity_id: !input color_set
- service: light.turn_on
target: !input light
data: >
{%- set inputval = states(color_set) %}
{%- set color_attrs = dict() %}
{%- if inputval|int(-1) != -1 %}
{%- set color_attrs = dict(color_attrs, color_temp_kelvin=inputval) %}
{%- elif inputval | first == '#' %}
{%- set color_attrs = dict(color_attrs,
rgb_color=(inputval[1:3]|int(base=16),
inputval[3:5]|int(base=16),
inputval[5:7]|int(base=16)) | list ) %}
{%- else %}
{%- set color_attrs = dict(color_attrs, color_name=inputval ) %}
{%- endif %}
{%- set color_attrs = dict(color_attrs, transition=1) %}
{{ color_attrs }}
- conditions: # Left button, long press
- '{{ command == ''hold'' }}'
- '{{ cluster_id == 5 }}'
- '{{ endpoint_id == 1 }}'
- '{{ args == [3329, 0] }}'
sequence: !input button_left_long
- conditions: # Right button, short press
- '{{ command == ''press'' }}'
- '{{ cluster_id == 5 }}'
- '{{ endpoint_id == 1 }}'
- '{{ args == [256, 13, 0] }}'
sequence:
- service: input_select.select_next
data:
entity_id: !input color_set
- service: light.turn_on
target: !input light
data: >
{%- set inputval = states(color_set) %}
{%- set color_attrs = dict() %}
{%- if inputval|int(-1) != -1 %}
{%- set color_attrs = dict(color_attrs, color_temp_kelvin=inputval) %}
{%- elif inputval | first == '#' %}
{%- set color_attrs = dict(color_attrs,
rgb_color=(inputval[1:3]|int(base=16),
inputval[3:5]|int(base=16),
inputval[5:7]|int(base=16)) | list ) %}
{%- else %}
{%- set color_attrs = dict(color_attrs, color_name=inputval ) %}
{%- endif %}
{%- set color_attrs = dict(color_attrs, transition=1) %}
{{ color_attrs }}
- conditions: # Right button, long press
- '{{ command == ''hold'' }}'
- '{{ cluster_id == 5 }}'
- '{{ endpoint_id == 1 }}'
- '{{ args == [3328, 0] }}'
sequence: !input button_right_long
You could have made it easier with the RBG part.
Instead of using a input select then you could have used the hue value, {{ (current hue +30) % 360 }}
.
That would make it loop the colors with each button press and you wouldn’t need the input select. unless your selected colors are very specific.
You could have made it easier with the RBG part.
Instead of using a input select then you could have used the hue value,{{ (current hue +30) % 360 }}
.
I admit I’m not very literate in the different ways of specifying colours with the light.turn_on action, don’t quite understand how the values for hs_color work, and I didn’t look into it too deeply. but does the hs_color attribute not already need a pair of values (hue/saturation)?
My intent with the helper was to be able to replicate by default the combination of colors and color temperatures that the TRADFRI bulbs offer by default, so the left and right buttons could be used to exactly mirror the experience of linking the STYRBAR remote with the bulbs directly.
The hue value is a value from 0 to 360 and each number represents a color.
The saturation is a number from 0 to 100, where 0 is white color and 100 is full color of what the hue number is.
0/360 is at the top, meaning red.
So using the hue wheel means you can just add for example 30 degrees to get orange, then yellowish and so on.
I have no clue what the remote does when you pair it with a bulb directly but most color fading use the hue wheel, see if the color pattern doesn’t match what spinning clockwise on the hue wheel does.
The remote goes through some color temperatures and then a selected set of colors. it might be possible to replicate the color temperatures with hue/saturation values, but I was thinking it was easier/more friendly for end users to be able to specify the color temperature directly. I could add the ability to detect a pair of numbers (separated by a comma, for example) and then use it as the hs_color
attribute. Is that something that would be useful and/or interesting?