Hue scenes random selection with smooth transition

Description:

This post provides a script for Home Assistant that allows you to randomly switch between Philips Hue scenes with smooth transitions. You can use this script in your own automations to control lighting in your home.

Setup Steps:

  1. Create the Input Select Helper:
  • Go to your Home Assistant dashboard.
  • Navigate to “Configuration,” “Devices & Services,” and select “Helpers.”
  • Click the plus (+) icon to add a new helper.
  • Choose “Dropdown” from the available helper types.
  • Enter a name for your dropdown helper, e.g., “scene_entities.”
  • Under “Options,” add a list of the desired Philips Hue scenes, e.g., “scene.hue_relax,” “scene.hue_romantic,” “scene.hue_party,” and so on.
  • Save the settings to create the dropdown input helper.
  1. Use the Script in Your Automations:
  • Copy the script provided below and save it in Home Assistant.
  • You can customize the script and integrate it into your own automation setups to randomly switch Philips Hue scenes.
alias: Szenen Switch random with smooth transition
description: ""
condition: []
action:
  - variables:
      options: "{{ state_attr('input_select.scene_entities', 'options') }}"
      num_options: "{{ options | length }}"
      random_index: "{{ range(num_options) | random }}"
  - service: input_select.select_option
    data:
      option: "{{ options[random_index] }}"
    target:
      entity_id: input_select.scene_entities
  - service: scene.turn_on
    data:
      entity_id: "{{ options[random_index] }}"
      transition: 2
    target:
      entity_id: "{{ options[random_index] }}"
mode: single

With this script, you have the flexibility to adapt and integrate it into yourown automation configurations, allowing them to control your Philips Hue scenes randomly and with smooth transitions. Ensure that the “input_select.” in the script matches the name of the input select helper that you’ve created. Enjoy customizing and utilizing the script!

2 Likes