First off thanks to everyone on the community that is helping, I’ve found lots of really good information and explanations on here so far.
I’m still struggling with the concept of templates though. What I would like to achieve is to be able to control my lights individually with a brightness slider. I’ve done this using input numbers, but I’ve done this the long way by creating one per light. I also want to create an automation where I would like to control the brightness of all the lights in the house (I only have 3 so far) by using yet another input_number to control the all_lights group.
I suspect there is a much more efficient way of doing this, but am struggling a bit on how I can use templates to specify different lights to a single input_number configuration and what the configuration of this setup would be.
Since you already have it working for each individual light, I would recommend adding an additional trigger (for your input_number that controls group.all_lights) to each automation.
automation:
- alias: control_brightness
trigger:
- platform: state
entity_id: input_number.light1_brightness
- platform: state
entity_id: input_number.all_lights_brightness
condition:
...
actions:
...
Thanks for that - can’t believe I hadn’t thought of simply modifying the trigger to the one automation config!
But does that still mean that I need to have multiple input_number configs for each one? If I end up getting more lights of if I want to re-use the already configured input_number slider for something else would I need to have another block of config for it? Am trying to think of the scalability of all my configs.
I know I can control the brightness of a light or a group of lights by clicking on the light (or group) and setting the brightness that way, but I wanted to have a slider straight on the card for the light similar to below as I think it just makes it more “user friendly” and I am lazy
- alias: control brightness
trigger:
- platform: state
entity_id: input_number.lounge_brightness
condition:
- condition: state
entity_id: group.lounge_lights
state: 'on'
action:
service: homeassistant.turn_on
data_template:
entity_id: group.lounge_lights
brightness_pct: "{{ trigger.to_state.state | int }}"
what I was hoping for was a way to re-use the same input number definition for all the automations, but the more I read about them and based on martokk’s comment I’ve come to get a better understanding and realise I don’t think its possible.
If I’ve understood it correctly, the only way to achieve something like:
- alias: control brightness
trigger:
- platform: state
entity_id: input_number.lounge_brightness
- platform: state
entity_id: input_number.lounge_1_brightness
- platform: state
entity_id: input_number.bedroom_brightness
would be to use a script or multiple automations as the conditions for each of those triggers and the actions would be different. Or am I still getting things totally wrong?
If it was me I would name the input_numbers the same as the lights and use one automation that maps the individual sliders to their light, and then use a second automation for the ‘master slider’ that switches off the first automation, sets all the lights, sets all the input_numbers and then turns the first one back on.