I’m trying to create a light template as a virtual light that acts as a middle-man between Home Assistant and a real light. Later this will handle multiple real lights as well as modifying the inputs to provide some color calibration.
The problem I’m facing now is that the color temperature doesn’t seem to get stored (if that’s the right word) in the virtual light. After setting a color temperature on the virtual light, in Template editor:
state_attr('light.real_light', 'color_temp')
returns the color temperature I just set (in mirek), but
state_attr('light.virtual_light', 'color_temp')
returns None.
Is temperature_template
now what I should be using? How do I store the color temperature in the virtual light?
My code looks like this:
- platform: template
lights:
virtual_light:
friendly_name: "Test Light"
value_template: "{{ is_state('light.real_light', 'on') }}"
level_template: "{{ state_attr('light.real_light', 'brightness') }}"
rgb_template: "{{ state_attr('light.real_light', 'rgb_color') }}"
temperature_template: "{{ state_attr('light.real_light', 'color_temp') }}"
turn_on:
service: light.turn_on
data_template:
entity_id: light.real_light
turn_off:
service: light.turn_off
data_template:
entity_id: light.real_light
set_level:
service: light.turn_on
data_template:
entity_id: light.real_light
brightness: "{{ brightness }}"
set_temperature:
service: light.turn_on
data_template:
entity_id: light.real_light
color_temp:
{{ color_temp }}
set_rgb:
service: light.turn_on
data_template:
entity_id: light.real_light
rgb_color:
({{ r }} , {{ g }} , {{ b }})