How to copy device value to the other device (with or without additional calculation)

Hi,

I need a help with setting some automations where I like to copy value from one device to the other. I’m pretty convinced it must be possible, but I can’t find it within available automation actions. I have two cases:

  1. Sycing two dimmers with each other, so when I change dim level for one of them, the other is adjusted to match the first one.

  2. Syncing two devices but with additional calculation in between, like mutiplying the value of the first device by some factor. In the most complex version there are three options here:
    a) If Device A has a value from the range 1-40, then set device B to 0
    b) If Device A has a value from the range 40-50, set device B to defined value (i.e. 15)
    c) If Device A has a value from the range 50-90, set device B to the value = Dev A * defined factor (i.e. 1,2)

Bumping up

Really, that can’t be done using HA?

1 Like

I’m looking for the same functionality.
Did you find a way?

Yes, I did, using the template:

Since I wanted to make the sync working both ways, I made an automation which have four triggers:

  1. Brightness change of light A
  2. Brightness change of light B
  3. Turning on light A
  4. Turning on light B

Each trigger has its own ID, and then the automation is the “Choose between actions” type, with separate option for each trigger.
I wanted to sync the lights only if both are turned on (so i.e. changing the light level of A doesn’t change B if it is not turned on, and if I turn the light B off it wont turn off the B as well)

Therefore for brightness level I have following action (option 1):
Conditions:

  • Triggered by value change of light A
  • Light A is ON
  • Light B is ON
  • Template condition with following code:condition: template value_template: {{ not state_attr('light.B', 'brightness') == state_attr('light.A', 'brightness') }}
    (where light.A and light.B are entity ID’s of both lights)

Then the action is a “call service” type, and you need to change to edit in Yaml, as it is not supported in visual editor.
The code is as follow:

service: light.turn_on entity_id: light.B data_template: brightness: | {{ state_attr('light.A', 'brightness') }}

This sets the brightness level of Light.B to be the same as it is set for Light.A

Then you need to set option 2 the same way but in reverse (triggered by change of light B and adjusting the brightness of light A, etc.)

Option 3 and 4 are for the case when I turn on light B (option 3) or A (option 4) when the other light is turned on. At that point I want the brightness level of the light which I’m turning on to be set as the same as has the one already turned on.

To do that I have different conditions:

  • Triggered by turning on Light B
  • Light A is turned ON

The action is the same as before, respectively to the proper light (so you adjust the brightness of Light.B when you just turned it ON and A is already ON, or adjust the brightness of light A when it is the opposite scenario)