Hue Party lights!

For anyone interested, had a bit of a struggle with the Hue lights, found an earlier automation, and adapted somewhat.

working smoothly now (as long as you don’t have anything else checking the state of the lights on the Hub, that is why i’ve automated disabling my automation.sense_lights_change while in party mode…) If you’re not bothered by that, you can further shrink these automations and scripts, but in my setting it needs to be split up.

still trying to randomize the timing trigger, but that won’t go just yet, and of course an input_boolean.home_mode_party is needed

##########################################################################################
# Party_mode for Hue lights
##########################################################################################
homeassistant:
  customize:
    input_boolean.home_mode_party:
      templates:
        icon: >
          if (state === 'on') return 'mdi:cake-layered';
          return 'mdi:hotel';
        icon_color: >
          if (state === 'on') return 'rgb(251, 210, 41)';
          return 'rgb(54, 95, 140)';

input_boolean:
  home_mode_party:
    name: Party

##########################################################################################
# Automations
##########################################################################################

automation:
  - alias: 'Lights partying'
    id: 'Lights partying'
#    initial_state: 'on'
    trigger:
      platform: time
      seconds: '/4'   # '{{ "/" ~ ((range(2, 5) | random) | int) }}'
    condition:
    action: 
      service: script.lights_partying_on

  - alias: 'Lights Party Mode'
    id: 'Lights Party Mode'
    initial_state: 'on'
    trigger:
      platform: state
      entity_id: input_boolean.home_mode_party
    action:
      service_template: >
        script.lights_mode_party_{{ states('input_boolean.home_mode_party') }}

##########################################################################################
# Scripts
##########################################################################################

script:
  lights_mode_party_on:
    alias: Party on
    sequence:
      - service: homeassistant.turn_off
        entity_id: automation.sense_lights_change
      - service: homeassistant.turn_on
        entity_id: automation.lights_partying

  lights_mode_party_off:
    alias: Party off
    sequence:
      - service: homeassistant.turn_off
        entity_id: automation.lights_partying
      - delay: 00:00:02
      - service: script.lights_partying_reset
      - delay: 00:00:01
      - service: script.lights_partying_off
#      - delay: 00:00:10
#      - service: homeassistant.turn_on
#        entity_id: automation.sense_lights_change

  lights_partying_on:
    alias: Lights partying on
    sequence:
      - service: light.turn_on
        data_template:
          entity_id: light.{{['1','2','3','4']|random}}
          rgb_color: ['{{ (range(0, 255)|random) }}', '{{ (range(0, 255)|random) }}', '{{ (range(0, 255)|random) }}']
          brightness: '{{ (range(50, 250)|random) }}'
          transition: '{{ (range(1, 3)|random) }}'

  lights_partying_off:
    alias: Lights partying off
    sequence:
      - service: light.turn_off
        entity_id: 
          - light.1
          - light.2
          - light.3
          - light.4

  lights_partying_reset:
    alias: Lights partying reset
    sequence:
      - service: light.turn_on
        data:
          entity_id:
            - light.1
            - light.2
            - light.3
            - light.4
          profile: relax

have fun!

1 Like

sure, got that.

but to make [light.bathroom, light.dining, light.hall] Id need something else than the range (), dont know what though…

nothing like that is possible unless you made a map. Even then, you’d have to declare your map everywhere and it wouldn’t really save time.

{% set mapper = [‘bathroom’,‘dining’,‘hall’] %}
{% for n in mapper %}light.{{n}},{% endfor %}

1 Like

I tried your automation but it is not working, it is just shutting down my lights

you should post what your config is/automation looks like, this is a 2 year old thread, a lot has changed since then…