I’m trying to create a template light for my hue bulbs.
The situation is the following:
I got a controllable switch (switch.schlafzimmer_bett_links) that can power of the outlet which the hue bulb (light.schlafzimmer_nachttisch_links) is connected to.
To turn on the Hue bulb i need to turn on the switch and then turn on the hue bulb (with the parameters i want to have like brightness, color etc.)
At the moment i have the following configuration:
- platform: template
lights:
schlafzimmer_nachttisch_links_kombiniert:
friendly_name: "Schlafzimmer.Nachttisch (links)"
level_template: "{{ state_attr('light.schlafzimmer_nachttisch_links', 'brightness')|int(100) }}"
temperature_template: "{{ state_attr('light.schlafzimmer_nachttisch_links', 'kelvin')|int(6500) }}"
color_template: "{{ state_attr('light.schlafzimmer_nachttisch_links', 'hs_color') | float([28.327,64.71])}}"
value_template: >-
{% if is_state('switch.schlafzimmer_bett_links', 'on') %}
{% if is_state('light.schlafzimmer_nachttisch_links', 'on') %}
on
{% else %}
off
{% endif %}
{% else %}
off
{% endif %}
icon_template: >-
{% if is_state('switch.schlafzimmer_bett_links', 'on') %}
{% if is_state('light.schlafzimmer_nachttisch_links', 'on') %}
mdi:lightbulb-on
{% else %}
mdi:lightbulb-off
{% endif %}
{% else %}
mdi:lightbulb-off
{% endif %}
turn_on:
- service: switch.turn_on
target:
entity_id: switch.schlafzimmer_bett_links
- delay:
hours: 0
minutes: 0
seconds: 0
milliseconds: 2500
- service: light.turn_on
target:
entity_id: light.schlafzimmer_nachttisch_links
turn_off:
service: switch.turn_off
target:
entity_id: switch.schlafzimmer_bett_links
set_level:
service: light.turn_on
data:
entity_id: light.schlafzimmer_nachttisch_links
brightness: "{{ brightness }}"
set_temperature:
service: light.turn_on
data:
entity_id: light.schlafzimmer_nachttisch_links
color_temp: "{{ color_temp }}"
set_color:
service: light.turn_on
data:
entity_id: light.schlafzimmer_nachttisch_links
hs_color:
- "{{ h }}"
- "{{ s }}"
My problem is the following:
Turning the template light on with the created entity, the turn_on block is working like expected.
But when i go to developer tools → services and try to turn the light on the way, i can only turn it on when i do not have any data like brightness set.
This works:
service: light.turn_on
target:
entity_id: light.schlafzimmer_nachttisch_links_kombiniert
While this does not even turn the switch on, nothing happens.
service: light.turn_on
target:
entity_id: light.schlafzimmer_nachttisch_links_kombiniert
data:
brightness: 100
Once the hue-light is turned on, i can set parameters through developer tools → services.
I tried any possible solution i can imagine but i have no clue why its not working.
Help is really appreciated