Dear all, I have a lamp hanging over my dining table with four ikea trädfri bulps (for dimming purposes) and I also have a shelly switch in the wall behind the haptic switch. To get both bulbs and switch working togehter I have configured a template light. This ensures the switch is turned on if necessary together with the bulbs and only turns of the bulbs if the switch is pressed again. This works really like a charm, also diming the lights is possible via the appropriate cards in the frontend.
What however not works is setting the template light to a certain light level / brigthness when using scenes. Neither when using scene.apply within an automation nor when manually activating a scene. Is this a known problem? How can I tackle this??
Please see below my code snippets:
Template Light
- platform: template
lights:
diningroom_lamp:
friendly_name: "Esszimmerlampe (unified)"
level_template: "{{ state_attr('light.bulbs_diningroom', 'brightness')|int }}"
value_template: "{{ is_state('switch.light_diningroom', 'on') and is_state('light.bulbs_diningroom', 'on')}}"
color_template: "{{ state_attr('light.bulbs_diningroom', 'rgb_color') | float}}"
turn_on:
- service: homeassistant.turn_on
target:
entity_id: switch.light_diningroom
- service: light.turn_on
target:
entity_id: light.bulbs_diningroom
data:
transition: 1
turn_off:
service: light.turn_off
target:
entity_id: light.bulbs_diningroom
data:
transition: 1
set_level:
- service: homeassistant.turn_on
target:
entity_id: switch.light_diningroom
- service: light.turn_on
target:
entity_id: light.bulbs_diningroom
data_template:
brightness: "{{ brightness }}"
set_temperature:
service: light.turn_on
target:
entity_id: light.bulbs_diningroom
data_template:
color_temp: "{{ color_temp }}"
Scene:
- id: livingroom_lunch
name: Essen
icon: mdi:silverware
entities:
light.diningroom_lamp:
state: 'on'
brightness_pct: 50
color_temp: 300
light.led_tv_panel: 'off'
light.livingroom_corner:
state: 'on'
brightness_pct: 1
light.stonewall_livingroom: 'off'
light.livingroom_spots:
state: 'on'
brightness_pct: 20
color_temp: 500
media_player.samsung_qled: 'off'
Code behind my button in the lovelace UI to activate the scene
- type: button
entity: scene.livingroom_eat
show_name: false
tap_action:
action: call-service
service: scene.turn_on
service_data:
transition: 2
entity_id: scene.livingroom_eat
target: {}
hold_action:
action: none