"Copy" values to another Entity

(Sorry for my bad English)

I’ve intergrated a Milight remote in Home Assistant as a light.

Now i want that the values of this light of the remote are copied to my other lights in home assistant, eg. light.birnen. I don’t know how to do this.

Thank you!

Did you ever figure this out? If not, share some details about your Milight remote. E.g., what is the entity_id? What does its state and attributes look like?

I’ve installed the Milight remote as a normal light:
light.milight_remote

Then I have a light group with the bulbs I want to control:
light.birnen

My milight remote sends an HUE value to the mqtt broker. Home Assistant converts it into rgb_color…

Now I’ve created an sensor with the rgb value of my milight remote. Now I want that these sensor values are copied to the bulbs. Is this the right way or am I totally wrong?

I have installed tasmota on my bulbs

So when the milight remote sends a hue value, does that value appear in the rgb_color attribute of light.milight_remote? And, if so, why do you also have another sensor with the same value?

If not, and the rgb value is only accessible in HA via the sensor, what is the entity_id of that sensor, and how is the rgb value represented by it? In its state, and if so, what does it look like? In an attribute, and if so, what’s its name and how is the value represented?

Basically it sounds like you want an automation that is triggered when the rgb value changes and then to use that value to change the color of light.birnen. But I need more details about how the rgb value is made available before I can provide any concrete example of how to do this.

I also tried to set the values with an automation an MQTT

- alias: Milight2Hueall
  initial_state: True
  trigger:
    - platform: mqtt
      topic: 'milight/state/0x46D7/fut089/1'
#  condition: 
#    condition: template
#    value_template: '{{ "brightness" in trigger.payload }}'  
  action:
    - service: light.turn_on
      data_template:
        entity_id: light.birne_1
        brightness: '{{ trigger.payload_json.brightness }}'
        color_rgb: '{{ trigger.payload_json.color }}'

This is my sensor in my config

Do you need more details?

Thank you!

Sorry I only can put one photo in one post

This is my sensor in Home Assistant
sensor

This is my milight remote in my config

This is my light group (of the bulbs) in the config

Thank you!

Ok, so it looks like the rgb_color attribute of light.milight_remote contains the value you want to set light.birnen to, is that correct? FYI, the hs_color (hue & saturation) attribute is really the “main” color attribute. If you look at how the light component works, that is what is stored, and rgb_color & xy_color are simply calculated from hs_color. So, typically hs_color is the attribute you’d want to use.

So you could try this as a starting point:

- trigger:
  - platform: state
    entity_id: light.milight_remote
  action:
  - service: light.turn_on
    entity_id: light.birnen
    data_template:
      hs_color:
        - "{{ trigger.to_state.attributes.hs_color[0] }}"
        - "{{ trigger.to_state.attributes.hs_color[1] }}"

You could also add brightness if you want.

Let me know how that works. If you need something changed, let me know.

1 Like

Home Assistant returns an error…

I don’t know why?

Is the formatting wrong?

I know what I’ve done wrong

1 Like

It always helps to actually share the error rather than just say “an error.”

There just was written:
There was an error in your config

Anyways

It works pretty nice!

Thank you!

Another question:

When the rgb value of the milight is:
rgb_color: 255,255,255
can I set it up that the white value is set to 255?

- trigger:
  - platform: state
    entity_id: light.milight_remote
  action:
  - service: light.turn_on
    entity_id: light.birnen
    data_template:
      hs_color:
        - "{{ trigger.to_state.attributes.hs_color[0] }}"
        - "{{ trigger.to_state.attributes.hs_color[1] }}"
  - condition: template
    value_template: >
      {{ trigger.to_state.attributes.rgb_color == (255, 255, 255) }}
  - service: light.turn_on
    entity_id: light.birnen
    data:
      white_value: 255
1 Like

good day! Sorry for my English. I’m trying to get that automation to work but it’s not working for me. I have a Tasmota RGB and I want to copy the colors to other plates. Will it not work for me because I am with the HA 116.2 versions? Can you help me?

could you make a blueprint of this ? :slight_smile:
thx a lot

I would like to have a value/state copy as well. Both entities are time helpers.

But unfortunately

service: input_datetime.set_datetime
target:
  entity_id: input_datetime.weckzeit_gastezimmer
data:
  datetime: >-
    {{ states.input_datetime.weckzeit_schlafzimmer.state }}

is not working to coy state to state. How to get this working?

And secondly, if I have boolean helpers, how to get this state to state copy there, as I do not finde a kind of input_boolean.set_boolean and therfor currently do this via condition.

That’s probably because input_datetime.weckzeit_schlafzimmer does not have both date & time. Which does it have?

Regarding boolean helpers, you could do it something like this:

trigger:
  - platform: state
    entity_id: input_boolean.A
action:
  - service: "input_boolean.turn_{{ trigger.to_state.state }}"
    entity_id: input_boolean.B

But then, one has to ask, if boolean B is always the same as boolean A, why have both?

1 Like

Both have only time and are defined the same way.
image
And I thought if the type is equal that I can assign 1:1 with every attribute. But o.k. solved as both are only time now with

data:
  time: '{{ states.input_datetime.weckzeit_schlafzimmer.state }}'

Good question of course. Because here I want to change B if I change A, but can still ovverride B when editing B. Both are alarm times and most of the time they are queal and can then set together when editing A.

BTW The trigger.idea is fine, What is happening here if I have more triggers for this automation? Then this sin’t working, is it? And I have to get the state directly from the device.

If you have more triggers then any of them will cause B to be set the same as A
You may want this but if you don’t you will need to creat a seperate automation.
Note : This can just set A as you already have the automation that copies it across (That wheel you already invented)