Hey guys,
I created a dummy light via template light, which basically controls and mimics a real light (see code at the bottom). This works well, I can set a brightness or a light temperature or a light color (which seems to be a somewhat new function, as this was not a feature a couple of months ago) via the Home Assistant developer tools, for example:
service: light.turn_on
data:
entity_id: light.living_kitchen_dummy
brightness: 200
service: light.turn_on
data:
entity_id: light.living_kitchen_dummy
kelvin: 2500
service: light.turn_on
data:
entity_id: light.living_kitchen_dummy
color_name: red
All of those change my real light.living_kitchen appropriately. Other commands such as hs_color
or rgb_color
work as well. But changing two attributes at the same time apparently does NOT work, eg:
service: light.turn_on
data:
entity_id: light.living_kitchen_dummy
color_name: red
brightness: 200
The brightness gets changed accordingly, but the color or temperature gets entirely ignored. If you look at my code at the bottom, I created input booleans to investigate, which “service” gets called on the dummy light if I want to change two attributes at the same time. I can confirm, that in this case only the set_level service of the template light gets triggered. I tried to also put an hs_color
template into the set_level service, but I could not get this to work.
So, has anyone an idea how to solve this problem?
A little bit of background: I do this to eventually change the turn_on
service of the dummy light to activate a script. Then I will expose the dummy light to google home and ideally I would be able to change the lights brightness and color via voice commands, but a simple “Hey google, turn kitchen on” would activate the script. Unfortunately, google apparently sends a color AND a brightness when setting a color via voice or app, which leads to the problem.
light:
- platform: template
lights:
living_kitchen_dummy:
friendly_name: "Kitchen Dummy"
level_template: "{{ state_attr('light.living_kitchen', 'brightness') | int }}"
value_template: "{{ is_state('light.living_kitchen', 'on') }}"
temperature_template: "{{ state_attr('light.living_kitchen', 'color_temp') }}"
color_template: "{{ state_attr('light.living_kitchen', 'hs_color') | float}}"
turn_on:
- service: light.turn_on
entity_id: light.living_kitchen
- service: input_boolean.toggle
entity_id: input_boolean.turnon_boolean
turn_off:
service: light.turn_off
entity_id: light.living_kitchen
set_level:
- service: light.turn_on
data_template:
entity_id: light.living_kitchen
brightness: "{{ brightness }}"
- service: input_boolean.toggle
entity_id: input_boolean.bright_boolean
set_temperature:
- service: light.turn_on
data_template:
entity_id: light.living_kitchen
color_temp: "{{ color_temp }}"
- service: input_boolean.toggle
entity_id: input_boolean.temp_boolean
set_color:
- service: light.turn_on
data_template:
hs_color:
- "{{ h }}"
- "{{ s }}"
brightness: "{{ brightness }}"
entity_id: light.living_kitchen
- service: input_boolean.toggle
entity_id: input_boolean.color_boolean