Skip to content

Instantly share code, notes, and snippets.

@MoritzBuetzer
Last active September 17, 2024 13:02
Show Gist options
  • Save MoritzBuetzer/ea7aed590a1271f61fe6d12eb428674e to your computer and use it in GitHub Desktop.
Save MoritzBuetzer/ea7aed590a1271f61fe6d12eb428674e to your computer and use it in GitHub Desktop.
Automation for Home Assistant. Hue Light with random color, every evening 15 Minutes before sunset until 23:45. Source: https://community.home-assistant.io/t/set-a-random-color-on-a-light/73145 and https://community.home-assistant.io/t/automation-to-set-same-random-colour-on-two-hue-lights/151343
- alias: "Turn on light with random color"
id: babc0ffa-622e-450a-a8c4-8dcddbb7e1f3
initial_state: True
trigger:
platform: sun
event: sunset
offset: "-00:15:00"
action:
service: light.turn_on
entity_id: light.hue_color_table_1
data_template:
rgb_color: ['{{ (range(0, 255)|random) }}', '{{ (range(0, 255)|random) }}', '{{ (range(0, 255)|random) }}']
brightness_pct: 100
transition: 1
- alias: "Turn off light"
id: 3849265d-5834-4620-a7d4-4f35306d66df
initial_state: True
trigger:
platform: time
at: '23:45:00'
action:
service: light.turn_off
entity_id: light.hue_color_table_1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment