Hi, I have 2 IKEA LED1836G9 and I need to sync brightness of them. I made an automation, where I can react to brightness change of 1st bulb, but how could I read this value and write this value to 2nd one?
Many thanks for help.
Hi, I have 2 IKEA LED1836G9 and I need to sync brightness of them. I made an automation, where I can react to brightness change of 1st bulb, but how could I read this value and write this value to 2nd one?
Many thanks for help.
Use a State Trigger to monitor the light’s brightness attribute and, in its action, sets the other light’s brightness
attribute to the same value (using the light.turn_on
service)
Alternately, you could use a Light Group which creates a separate (virtual) light entity that controls the two IKEA lights. Set this virtual light entity’s brightness and the other two lights will be automatically set to the same brightness.
I know the theory - but how can I set brightness to 2nd bulb? And how can I set the same brightness (where I can read brightness of 1st one)?
alias: Sync
description: ''
trigger:
- platform: state
entity_id: light.zarovka1
attribute: brightness
condition: []
action:
- condition: state
entity_id: light.zarovka2
attribute: brightness
state: '100'
mode: single
Action on change brightness on Zarovka2 happens, but this brightness set does nothing.
(Light group works and it’s ideal, but question is still the same).
Also, for my light group “Stropni svetlo” this script does nothing:
alias: New Script
sequence:
- condition: state
entity_id: light.stropni_svetlo
attribute: brightness
state: '100'
mode: single
That’s because it’s not “setting” anything. You have put a condition
into the action
which only serves as a filter. It is checking if zarovka’s brightness is 100. If it is or it isn’t won’t make a difference because you have not supplied anything after the condition. You did the same thing in the script so that’s why it doesn’t “do” anything either.
Remove the needless condition and replace it with a service call to light.turn_on
(like I had suggested previously).
It’ll be something like this (sorry but I don’t have time to test it).
alias: Sync
description: ''
trigger:
- platform: state
entity_id: light.zarovka1
attribute: brightness
condition: []
action:
- service: light.turn_on
data:
entity_id: light.zarovka2
brightness: "{{ trigger.to_state.attributes.brightness }}"
mode: single
Now we are going somewhere. That works for static settings. But what if I want to use state of a different entity as variable:
alias: Brightness_sync
sequence:
- service: light.turn_on
data:
brightness: state_attr('light.zarovka1', 'brightness'))
entity_id: light.zarovka2
mode: single
Returns that it expected int.
I haven’t been YAMLing for long but give this a shot, it might work. Dunno what that ‘mode’ thing is, it wasn’t there the last time I coded
alias: Brightness_sync
sequence:
- service: light.turn_on
data_template:
brightness: "{{state_attr('light.zarovka1', 'brightness')|int}}"
entity_id: light.zarovka2
mode: single
That works, thanks, even it’s not needed to reconvert data into int.
It’s good practice to avoid errors :). I’m glad it helped
I don’t think you understand the purpose of the Solution tag. I’ve watched you assign it to several posts as you appear to change your mind about which one solves the original problem.
The latest one you marked as the Solution doesn’t answer the original question, it answers a separate question (for a script implementation vs an automation). That means users reading the original problem are led to a Solution that solves a different one.
Honestly, I don’t know what you mean by a ‘static setting’. The example I posted takes the current brightness of zarovka1 (via the Trigger State Object) and assigns it to zarovka2. That’s what your first post requested:
made an automation, where I can react to brightness change of 1st bulb, how could I read this value and write this value to 2nd one?
The reason why this failed to work for you (in the script) is because it’s not a template:
brightness: state_attr('light.zarovka1', 'brightness'))
Taras: That’s because it SOLVES that problem - it ANSWERS my question.
Static - means that you set a STATIC value, not variable (being readen from another entity).
I think what you may have overlooked is that this service call in the automation:
- service: light.turn_on
data:
entity_id: light.zarovka2
brightness: "{{ trigger.to_state.attributes.brightness }}"
is functionally equivalent to this service call in the script:
- service: light.turn_on
data:
entity_id: light.zarovka2
brightness: "{{ state_attr('light.zarovka1', 'brightness')) }}"
The reason why it’s equivalent is because the automation is triggered by zarovka1’s brightness changes which are represented by the Trigger State Object in the template:
{{ trigger.to_state.attributes.brightness }}
The only real difference between the automation and the script is:
Your first and second posts concerned an automation. In your third post you changed direction and posted a script (which contained an invalid template). Obaldius corrected the invalid template.
Now you have two ways to achieve the goal of synchronizing the lights:
Even more complex solution, many thanks
I have spotlights controlled by a Shelly dimmer and want a zigbee bulb to turn ON/OFF and also follow the brightness off the Shelly.
Struggled a bit and then found this topic. Got it working, I make this reply to say thanks and also hopefully help someone with the below automation example.
alias: Korskoppling brightness, spottar-prydnadslampa
description: ""
trigger:
- platform: state
entity_id:
- light.dimmer_gillestugan
id: Turn OFF
to: "off"
- platform: state
entity_id:
- light.dimmer_gillestugan
attribute: brightness
id: Turn ON or change Brightness
condition: []
action:
- choose:
- conditions:
- condition: trigger
id: Turn ON or change Brightness
sequence:
- service: light.turn_on
data:
brightness: "{{ trigger.to_state.attributes.brightness }}"
target:
entity_id: light.prydnadslampa_gillestugan
alias: Turn on or change brightness to same as spottar
- conditions:
- condition: trigger
id: Turn OFF
sequence:
- service: light.turn_off
data: {}
target:
entity_id: light.prydnadslampa_gillestugan
mode: single
How to add the color temperature synchronization of the light? Or can you write a blueprint format?