Random Christmas light script - help

Hi, I have a Christmas tree with three different strings of lights, every 20 minutes I want to make a random selection of 1 - 3 and use it as an input of my choose statement. I have been trying (and yes reading everything I can about variables and random) to get this to work for a couple weeks, I know how to do the every 20 minutes it’s just getting a random number 1-3 into my choose statement that I need help with, your help is greatly appreciated.

Here is what I am trying to get working, getting an error on my value_template statement “Failed to perform the action script/new_script. extra keys not allowed @ data[‘value_template’]”

alias: New Script
sequence:

  • action: input_number.set_value
    metadata: {}
    data:
    value_template: “{{ range(1, 3) | random }}”
    target:
    entity_id: input_number.christmaslight
  • choose:
    • conditions:
      • condition: numeric_state
        entity_id: input_number.christmaslight
        above: 0
        below: 2
        sequence:
      • action: persistent_notification.create
        metadata: {}
        data:
        message: “1”
    • conditions:
      • condition: numeric_state
        entity_id: input_number.christmaslight
        above: 1
        below: 3
        sequence:
      • action: persistent_notification.create
        metadata: {}
        data:
        message: “2”
    • conditions:
      • condition: numeric_state
        entity_id: input_number.christmaslight
        above: 2
        below: 4
        sequence:
      • action: persistent_notification.create
        metadata: {}
        data:
        message: “3”
        enabled: true
        description: “”

Please format your post correctly in future, see: https://community.home-assistant.io/t/how-to-help-us-help-you-or-how-to-ask-a-good-question/114371#oneone-format-it-properly-16

action: input_number.set_value
metadata: {}
data:
  value_template: "{{ range(1, 3) | random }}"
target:
  entity_id: input_number.christmaslight

value_template should just be value.

https://www.home-assistant.io/integrations/input_number/#actions

There are examples on that page too.

Thank you very much, I really appreciate it!!

1 Like