Hi,
Since I installed a Zigbee switch and a Hue bulb in many rooms, I had to create custom lights with the help of the template functionality.
These custom lights use the Zigbee switch to turn on/off and the Hue bulb to change brightness, color, etc.
I add this in configuration.yaml
:
light: !include_dir_merge_list configs/light/
And I create a file in configs/light/
for each room.
Here is 2 of them as an example:
cp_light_bedroom.yaml
:
platform: template
lights:
composite_light_bedroom:
friendly_name: "Bedroom light"
level_template: "{{ state_attr('light.bedroom', 'brightness') | int }}"
value_template: "{{ is_state('switch.bedroom', 'on') }}"
temperature_template: "{{ state_attr('light.bedroom', 'color_temp') }}"
color_template: "{{ state_attr('light.bedroom', 'hs_color')}}"
turn_on:
service: switch.turn_on
data_template:
entity_id: switch.bedroom
turn_off:
service: switch.turn_off
data_template:
entity_id: switch.bedroom
set_level:
service: light.turn_on
data_template:
entity_id: light.bedroom
brightness: "{{ brightness }}"
set_temperature:
service: light.turn_on
data_template:
entity_id: light.bedroom
color_temp: "{{ color_temp }}"
set_color:
service: light.turn_on
data_template:
hs_color:
- "{{ h }}"
- "{{ s }}"
entity_id: light.bedroom
cp_light_kitchen.yaml
:
platform: template
lights:
composite_light_kitchen:
friendly_name: "kitchen light"
level_template: "{{ state_attr('light.kitchen', 'brightness') | int }}"
value_template: "{{ is_state('switch.kitchen', 'on') }}"
temperature_template: "{{ state_attr('light.kitchen', 'color_temp') }}"
color_template: "{{ state_attr('light.kitchen', 'hs_color')}}"
turn_on:
service: switch.turn_on
data_template:
entity_id: switch.kitchen
turn_off:
service: switch.turn_off
data_template:
entity_id: switch.kitchen
set_level:
service: light.turn_on
data_template:
entity_id: light.kitchen
brightness: "{{ brightness }}"
set_temperature:
service: light.turn_on
data_template:
entity_id: light.kitchen
color_temp: "{{ color_temp }}"
set_color:
service: light.turn_on
data_template:
hs_color:
- "{{ h }}"
- "{{ s }}"
entity_id: light.kitchen
As we can see, these two custom lights are exactly the same (except the room name of course) and this is the same for almost all my house lights.
I would like to know if I can create a single “custom light template” and then just add as many custom lights I want, all based on this “custom light template”.