I have 17 outdoor lights along my house, and im thinking of making something fancy that fades them in one by one, but im not sure what the best way of doing this is.
The “bad” solution ( in my head ) would just to make a sequence, with delays in between all light_on, but then i need to copy/paste delay+light_on 17 times, which seems … unnecessary. ( and the same for light off )
So, i thought since the lights are named: light.outdoor_front_1, light.outdoor_front_2…
Maybe you could make something dynamic? Or if they are in the same light group? But How?
An example would very much be appreciated.
@Terp
Here’s a very basic python_script that iterates through a group of lights and turns on each one in sequence with a delay of 15 seconds between each activation. Modify it to suit your needs:
sequence.py
items = hass.states.get('group.my_lights').attributes['entity_id']
for item in items:
service_data = {'entity_id':'{}'.format(item)}
hass.services.call('light', 'turn_on', service_data, False)
time.sleep(15)
The order the lights are activated is based on the order they are listed within the group.
EDIT
The advantage of using this python_script, as opposed to copy-pasting code 17 times in a script, is less maintenance. If you ever add more lights to the group they will be automatically handled by the python_script.
I’ve said it before and I’ll likely say it again, compact configuration does not necessarily equate to easily understandable and maintainable configuration and probably has little effect on execution efficiency (zero facts available to back that last bit up). I do understand the fascination with simplicty compaction though.
I love this table.
e.g.
Q: How often do I switch lights on and off?
A: Between 50 and 5 times a day.
Q: how much time would I save by automating it?
A: 1 Second.
Therefore I should spend no more than 2 hours to 1 day attempting to automate it to save time over 5 years.
“I would have to agree Captain Kirk” says Mr Spock
But… Some people have built the most beautiful objects, because they can, they take pride in it, they take pleasure from knowing that behind this cover plate (that no-one will take off in the next 20years) is an (insert object here) that has been crafted to meet and often exceed its requirement.
Also, people like to do puzzles, people have hobbies and sometimes they intersect. Should I insert a Venn diagram here ??? ; - )))
That is quite an elegant solution @123. Just out of interest, is it possible to do it anywhere as elegantly in jinja (I do not require proof just y/n if you have the time)?
Reminds me of my French friend who said she prefers thinking in English as it is “free-er”.