I studied IT in the past and always enjoyed programming, but I do something completely different now. Occasionally writing blueprints or scripts keeps my mind trained in thinking through logic and itās just satisfying to see an idea come to life.
Spot on, working a treat. My use case:
ceiling lamps x 3 in a group
table lamps x 3 in a groupAdd the actual bulbs (not groups) as the devices. Add a scene of all white for the closing effect, and a 2 second delay.
Working just as I had hoped. Great work, thanks for coming back to finish the job
Great to see it works well for you!
Is it possible to have less than 1 second for the lights to switch colors?
1 second is a bit too much i would prefer half a second for more BPM tracks
There are power on defaults for some bulbs - but some donāt let you pick default colors etc. Thatās a loss of power/restored scenario.
In my case, the lights are already powered on, but software turned off. I think for the āreturn to previous stateā you have to first send a command of āonā to each bulb in the list. Then proceed with color changes. That should keep the temperature and settings that they were originally in. Not sure how hard itās to implement that.
In my case, the lights are already powered on, but software turned off.
What is their state in Home Assistant in this case? On or off?
Essentially what the Blueprint does is make a snapshot the state of the lights before looping through the colors and then restoring that snapshot. So if your lights are off, they will return to off.
If you want them to return to a specific setting, then you can create a scene yourself and let the Blueprint activate that when the party mode is turned off.
Is it possible to have less than 1 second for the lights to switch colors?
1 second is a bit too much i would prefer half a second for more BPM tracks
Shouldnāt be very hard, Iāll add that in the next release.
Do take into account that you may run into buffering issues quite quickly (see some earlier comments).
This feature has now been added.
Hi @AntonH ,
do you mean my transition request was implemented? do i need to pull the blueprint again? Im pretty new to HA, sorry for my dumb questions.
Yes if the Blueprint is updated you need to redownload into HA to get the new features.
You can do this in Settings > Automatons & Scenes > Blueprints and then using the three-dots/overflow menu against the blueprint you want to update.
First I want to say thank you so much @AntonH for this blueprint! It was exactly what Iāve been trying to do myself for awhile but could never get working right. I did want to have a bit more control of the color options and performing other actions before and after the loop so I ātook overā the blueprint so I could edit the base YAML for my changes and itās all working great except for 1 thing and Iām not sure what Iām doing wrong. Iām trying to have a attribute of an entity (the ādescriptionā attribute of the entity ācalendar.ttrpg_gamesā) define the ācolor_modeā variable but everytime I save the updated YAML it ignores the attribute I defined and reverts to the previous saved value of ārandomā. Basically what Iām trying to do is have the current selected color mode set based off the description I have in my calendar event that is triggering it. Any help or tips would be greatly appreciated, here is a copy of the entire current automation so far.
alias: Lighting_DnD_Random
description: Magic lights mode for DnD campaigns
trigger:
- platform: state
entity_id:
- calendar.ttrpg_games
to: "on"
enabled: true
condition: []
action:
- action: scene.create
metadata: {}
data:
scene_id: lighting_dndmode_priorstate
snapshot_entities: "{{ target_lights }}"
- action: automation.turn_off
metadata: {}
data:
stop_actions: true
target:
entity_id:
- automation.office_lightstoggle_motion_01
- automation.hallway_lightsoff_relay_01
- action: switch.turn_off
metadata: {}
data: {}
target:
entity_id:
- switch.adaptive_lighting_office_ledstrip_01
- switch.adaptive_lighting_office_main_01
- switch.adaptive_lighting_hallway_room_01
- repeat:
sequence:
- repeat:
for_each: "{{ target_lights }}"
sequence:
- variables:
brightness_value: |
{% if brightness_mode == "random" %}
{{ range(min_brightness_pct, max_brightness_pct) | random }}
{% else %}
{{ fixed_brightness_pct }}
{% endif %}
rgb_value: |
{% if color_mode == "random" %}
{{ range(5,255) | random, range(5,255) | random, range(5,255) | random }}
{% elif color_mode == "red" %}
{{ range(5,255) | random, 0, 0 }}
{% elif color_mode == "green" %}
{{ 0, range(5,255) | random, 0 }}
{% elif color_mode == "blue" %}
{{ 0, 0, range(5,255) | random }}
{% elif color_mode == "teal" %}
{{ range(5,255) | random, 255, 255 }}
{% elif color_mode == "pink" %}
{{ 255, range(5,255) | random, 255 }}
{% elif color_mode == "yellow" %}
{{ 255, 255, range(5,255) | random }}
{% elif color_mode == "dark" %}
{{ range(150,255) | random, range(5,30) | random, 0 }}
{% else %}
{{ 255, 255, 255 }}
{% endif %}
- data: |
{% if color_mode == "no_color_change" %}
{{ { "transition": transition_time, "brightness_pct": brightness_value, "effect": light_effect } }}
{% else %}
{{ { "transition": transition_time, "brightness_pct": brightness_value, "rgb_color": rgb_value, "effect": light_effect } }}
{% endif %}
target:
entity_id: "{{ repeat.item }}"
action: light.turn_on
- delay:
hours: 0
minutes: 0
seconds: 1
until:
- condition: state
entity_id: calendar.ttrpg_games
state: "off"
- metadata: {}
target:
entity_id: scene.lighting_dndmode_priorstate
action: scene.turn_on
- action: automation.turn_on
target:
entity_id:
- automation.office_lightstoggle_motion_01
- automation.hallway_lightsoff_relay_01
data: {}
- action: switch.turn_on
target:
entity_id:
- switch.adaptive_lighting_office_ledstrip_01
- switch.adaptive_lighting_office_main_01
- switch.adaptive_lighting_hallway_room_01
data: {}
mode: restart
variables:
party_mode_trigger: input_boolean.lighting_dndmode
target_lights:
- light.office_ledstrip_desktop_01
- light.office_lightbulb_fanlight_01
- light.office_lightbulb_fanlight_02
- light.office_lightbulb_fanlight_03
- light.office_lightbulb_lamp_01
- light.office_lightbulb_lamp_02
- light.office_lightbulb_lamp_03
- light.office_lightbulb_lamp_04
- light.hallway_lightbulb_ceiling_01
- light.hallway_lightbulb_ceiling_02
transition_time: 1
color_mode: {{ state_attr("calendar.ttrpg_games", "description") }}
brightness_mode: random
min_brightness_pct: 10
max_brightness_pct: 100
fixed_brightness_pct: 100
light_effect: ""
UPDATE: Big thanks to @karwosts on the discord for helping me figure out what I was messing up. Solution below:
Change
color_mode: {{ state_attr("calendar.ttrpg_games", "description") }}
to this
color_mode: '{{ state_attr("calendar.ttrpg_games", "description") }}'
Looks great!
Are you changing the colors on the fly during the game with this or whatās the reason you want to set it through the calendar?
NEW RELEASE
16/09/2024 - Version 2.3
- Added support for shorter delays by adding a millisecond option to the ātime between changesā.
WARNING: this might cause a buffering issue to occur because of the frequent changes. - Modified some explanations to improve user friendliness.
This has been added in version 2.3
Is it just me or import currently doesnāt work?
I get an error āInvalid blueprint: extra keys not allowed @ data[āblueprintā][āinputā][ātime_between_changesā][āselectorā][āenable_millisecondā]. Got Noneā
Thanks
Have you upgraded to the latest version of HA?
The support for this has been added only recently.
Thank you, this might be the issue. Iāll re-check, although Iām currently running Core version 2024.7.4.
Thanks
I believe it was added in 2024.8
Hello everyone.
Love this Blueprint. Works very well with my Philips Hue Iris.
I seem to have issues with my Tradfri bulbs from Ikea. Some colours on the random mode just stay white on those but work well on my Iris.
I feel like this is a limitation on the Tradri bulbs.
Anyone has a workaround or advice to prevent just the white colours?
Thanks,
I have added HUE COLOR MODE, which cycles between random fully saturated colors (using hs_color
).
@AntonH Feel free to copy/adjust this and integrate it in your version.
@misterd4n This seems to partially address your issue, this color mode prevents white colors.
Thank you! I will test it!