Thank you @phdelodder, it doesn’t appear to have a list populated in dev tools, maybe this is a bug in the new addition. I’ll wait to see if it gets added before the stable release.
ive set up a script with the below config
wledtestrandomeffect:
alias: Wled Random
sequence:
- data:
entity_id: light.ceiling_led
brightness: 150
service: light.turn_on
- data_template:
entity_id: light.ceiling_led
effect: '{{ state_attr("light.ceiling_led", "effect_list") | random }}'
speed: '{{ (range(0, 255)|random) }}'
intensity: '{{ (range(0, 255)|random) }}'
service: wled.effect
im also wanting it to pick a random colour for the strip too as it only seems to stay on the last colour i selected on the colourwheel.
thanks in advance
Could you use the palette attribute? Though you’d have to list the palettes individually within the function and then apply the random function to that.
-or-
would this work?
palette: '{{ (range(0,50) | random) }}'
See PaletteIDs here.
You need to create a list with the paletteIDs and apply the random filter
This might work.
I setup an input select via helpers in the config and made an entry for each pallet and ran this:
{{state_attr("input_select.wled_palettes", "options") | random }
}`
Seems to work.
So adding the line:
palette: {{state_attr("input_select.wled_palettes", "options") | random }}
Should work.
I also noted that there is a “Random Cycle” (The palette changes to a random one every few seconds. Subject to change), so you could also use that I suppose.
wledtestrandomeffect:
alias: Wled Random
sequence:
- data:
entity_id: light.ceiling_led
brightness: 150
service: light.turn_on
- data_template:
entity_id: light.ceiling_led
effect: '{{ state_attr("light.ceiling_led", "effect_list") | random }}'
palette: '{{ (range(0, 50)|random) }}'
speed: '{{ (range(0, 255)|random) }}'
intensity: '{{ (range(0, 255)|random) }}'
service: wled.effect
palette: ‘{{ (range(0, 50)|random) }}’ worked for me
How can use the random effect if I only want to use some of the effects from the list?
I tried this but it doesn´t work.
My log returns an error saying that unable to find service wled.effect.
In wich release was this service introduced?
- service: wled.effect
data:
entity_id: light.stairs
effect: >
{{ [
"saw",
"chase",
"rainbow"
] |random }}
What version of home assistant, and what firmware version are you running on your WLED device?
0.103.6 and wled is 0.11.1 Mirai
The WLED effects service was released in v0.108. You need to upgrade to be able to use it.
You are also running a version susceptible to hacking attacks. See the banner at the top of every page. v2021.1.5. is the minimum recommended version.
Okay thanks.
I know about the updating but I like the States UI look and I know that most of my programming will not work after updating after such a long time. But I know I have to… sooner than later I guess.
I suppose as long as you can do without official support and new features (like WLED effects), and you either don’t expose your home assistant server to the internet or only access remotely via a VPN, then you can stay on any version you want.
I’m trying to figure out how to get the lights to do random effects from the automation UI in home assistant. I clicked on the effect box and added “random” in the field however, the automation still shows the last effect and nothing else. Any ideas?
WLED does not have an effect called ‘random’.
Pre-empting the 2021.12 update:
wled_random:
alias: 'Randomise BAR WLED'
sequence:
- service: light.turn_on ### random effect ###
target:
entity_id: light.led_strip_bar
data:
effect: "{{ state_attr('light.led_strip_bar', 'effect_list') | random }}"
- service: select.select_option ### random colour palette ###
target:
entity_id: select.led_strip_bar_color_palette
data:
option: "{{ state_attr('select.led_strip_bar_color_palette', 'options') | random }}"
- service: number.set_value ### random intensity (25% to 100%) ###
target:
entity_id: number.led_strip_bar_intensity
data:
value: "{{ range(64,255)|random }}"
- service: number.set_value ### random speed (25% to 100%) ###
target:
entity_id: number.led_strip_bar_speed
data:
value: "{{ range(64,255)|random }}"
For anyone that comes across this thread via Google like I did, here’s an extension of the script above that uses a user-selected field instead of hard-coded entities. Create the script and then tinker with calling it via the services tab in Developer Tools. Look for “Script: Randomise WLED” and then choose your entity from the selector below.
alias: Randomise WLED
description: Set completely random parameters to WLED
fields:
wled:
name: WLED Light Entity
description: The name of the WLED entity to use
required: true
example: light.office_corner_nw
selector:
entity:
multiple: false
filter:
- integration: wled
domain: light
sequence:
- service: light.turn_on
target:
entity_id: "{{ wled }}"
data:
effect: "{{ state_attr(wled, 'effect_list') | random }}"
- service: select.select_option
target:
entity_id: "{{ wled | replace('light', 'select') }}_color_palette"
data:
option: >-
{{ state_attr(wled | replace('light', 'select') ~ '_color_palette',
'options') | random }}
- service: number.set_value
target:
entity_id: "{{ wled | replace('light', 'number') }}_intensity"
data:
value: "{{ range(64,255)|random }}"
- service: number.set_value
target:
entity_id: "{{ wled | replace('light', 'number') }}_speed"
data:
value: "{{ range(64,255)|random }}"
Thanks for sharing but it works as long as I press run script inside it in editing mode, then I have to manually choose the entity.
If you want to hard code the entity id see my example: Wled Random effects - #36 by tom_l
Or if you want the entity to be supplied by an automation or other script do this:
alias: Randomise WLED
description: Set completely random parameters to WLED
sequence:
- service: light.turn_on
target:
entity_id: "{{ wled }}"
data:
effect: "{{ state_attr(wled, 'effect_list') | random }}"
- service: select.select_option
target:
entity_id: "{{ wled | replace('light', 'select') }}_color_palette"
data:
option: >-
{{ state_attr(wled | replace('light', 'select') ~ '_color_palette',
'options') | random }}
- service: number.set_value
target:
entity_id: "{{ wled | replace('light', 'number') }}_intensity"
data:
value: "{{ range(64,255)|random }}"
- service: number.set_value
target:
entity_id: "{{ wled | replace('light', 'number') }}_speed"
data:
value: "{{ range(64,255)|random }}"
And to call it:
- service: script.randomise_wled
data:
wled: light.your_wled_light_here
or
- service: script.turn_on
target:
entity_id: script.randomise_wled
data:
variables:
wled: light.your_wled_light_here
Why you may want one or the other: https://www.home-assistant.io/integrations/script/#waiting-for-script-to-complete The first method waits for the script to finish before moving to the next action, the second method does not wait.
I am calling the scrip using the code above which works for one WLED light, but how do I output to two lights without calling the script twice? I would light the same ‘random’ output to go to two different outside wled lights so they look the same.
Regards
James