Skip to content

Instantly share code, notes, and snippets.

@jetpacktuxedo
Created April 22, 2024 16:15
Show Gist options
  • Save jetpacktuxedo/17e7b46df59dff739f8aa58daf8a1fa2 to your computer and use it in GitHub Desktop.
Save jetpacktuxedo/17e7b46df59dff739f8aa58daf8a1fa2 to your computer and use it in GitHub Desktop.
HomeAssistant script to copy light brightness and color from one light to another
alias: Copy Light
sequence:
- choose:
- conditions:
- condition: template
value_template: "{{ state_attr(source, \"color_mode\") == \"color_temp\"}}"
sequence:
- service: light.turn_on
data_template:
entity_id: "{{ destination }}"
color_temp: "{{ state_attr(source, \"color_temp\") }}"
alias: If source color mode is color_temp copy to dest
- conditions:
- condition: template
value_template: "{{ state_attr(source, \"color_mode\") == \"rgb\"}}"
sequence:
- service: light.turn_on
data_template:
entity_id: "{{ destination }}"
rgb_color:
- "{{ state_attr(source, \"rgb_color\")[0] }}"
- "{{ state_attr(source, \"rgb_color\")[1] }}"
- "{{ state_attr(source, \"rgb_color\")[2] }}"
alias: If source color mode is rgb copy to dest
- service: light.turn_on
data_template:
entity_id: "{{ destination }}"
brightness: "{{ state_attr(source, \"brightness\") }}"
mode: single
icon: mdi:lamps
fields:
source:
selector:
entity:
filter:
- domain: light
name: Source
description: Light from which to copy state
required: true
destination:
selector:
entity:
filter:
- domain: light
name: Destination
description: Light to which the state will be copied
required: true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment