I need help mirroring a rgbw tuya bulb to a virtual rgbw bulb

I am using Actiontiles on an iPad and one of my colored bulbs is a tuya bulb. I created a virtual rgbw light switch in SmartThings that I want to mirror the state of the bulb in Home Assistant and vice versa. I edited my automation.yaml file and can get the switches to turn on and off together but I can’t seem to figure out how to pass the color attributes between the two. This is the post I used as reference:

This is my automation.yaml file:

- alias: Mirror Master Light Color 1
  initial_state: 'on'
  trigger:
    platform: state
    entity_id: light.masterlight
  condition:
    condition: template
    value_template: "{{ trigger.to_state.state != 'off' }}"
  action:
    service_template: light.turn_on
    entity_id: light.master_light
    data_template:
      brightness: '{{states.light.masterlight.attributes.brightness |int}}'
      xy_color: [
        '{{states.light.masterlight.attributes.xy_color[0] |float}}',
        '{{states.light.masterlight.attributes.xy_color[1] |float}}'
      ]
      hs_color: [
        '{{states.light.masterlight.attributes.hs_color[0] |float}}',
        '{{states.light.masterlight.attributes.hs_color[1] |float}}'
      ]
      rgb_color: [
        '{{states.light.masterlight.attributes.rgb_color[0] |int}}',
        '{{states.light.masterlight.attributes.rgb_color[1] |int}}',
        '{{states.light.masterlight.attributes.rgb_color[2] |int}}'
      ]

- alias: Mirror Master Light Color 2
  initial_state: 'on'
  trigger:
    platform: state
    entity_id: light.master_light
  condition:
    condition: template
    value_template: "{{ trigger.to_state.state != 'off' }}"
  action:
    service_template: light.turn_on
    entity_id: light.masterlight
    data_template:
      brightness: '{{states.light.master_light.attributes.brightness |int}}'
      xy_color: [
        '{{states.light.master_light.attributes.xy_color[0] |float}}',
        '{{states.light.master_light.attributes.xy_color[1] |float}}'
      ]
      hs_color: [
        '{{states.light.master_light.attributes.hs_color[0] |float}}',
        '{{states.light.master_light.attributes.hs_color[1] |float}}'
      ]
      rgb_color: [
        '{{states.light.master_light.attributes.rgb_color[0] |int}}',
        '{{states.light.master_light.attributes.rgb_color[1] |int}}',
        '{{states.light.master_light.attributes.rgb_color[2] |int}}'
      ]
      
- alias: Mirror Master Light On 1
  initial_state: 'on'
  trigger:
    platform: state
    entity_id: light.masterlight
    to: "off"
  action:
    service: light.turn_off
    entity_id: light.master_light

- alias: Mirror Master Light On 2
  initial_state: 'on'
  trigger:
    platform: state
    entity_id: light.master_light
    to: "off"
  action:
    service: light.turn_off
    entity_id: light.masterlight

- alias: Mirror Master Light Off 1
  initial_state: 'on'
  trigger:
    platform: state
    entity_id: light.masterlight
    to: "on"
  action:
    service: light.turn_on
    entity_id: light.master_light
    
- alias: Mirror Master Light Off 2
  initial_state: 'on'
  trigger:
    platform: state
    entity_id: light.master_light
    to: "on"
  action:
    service: light.turn_on
    entity_id: light.masterlight

Please help! Thank you

1 Like