Use something like rgb_color: ['{{ (range(0, 255)|random) }}','{{ (range(0, 255)|random) }}','{{ (range(0, 255)|random) }}']. You can see a few examples here.
I’m not sure how all of this works with scenes as opposed to scripts, but I’m quite confident it would work with a script!
I would use your second example, where you format it as an int. Not sure if it’s necessary, but it just makes sense to me.
You can evaluate if the template itself is rending how you expect by testing it out under “Templates” under Developer Tools on the bottom left of the front end. This really opened up templating for me!
2017-11-21 14:40:23 ERROR (MainThread) [homeassistant.core] Invalid service data for light.turn_on: expected int for dictionary value @ data[‘rgb_color’]. Got [’{{ (range(0, 255)|random) }}’, ‘{{ (range(0, 255)|random) }}’, ‘{{ (range(0, 255)|random) }}’]
nope effect: random is not working with limitlessLED bulbs. color_loop is also buggy. But i got it working.
I made an automation, with scenes it seems not to work at all:
Just to say this was exactly what I needed and has worked for me using my aqara switches, changing colours, using the aqara both clicks, on both kids milight gateways and aqara gateways. If it helps anyone else here are my yaml files.
I use this automation right now and it’s works nicely BUT, almost never coming “clear” colours , can I change this automation somehow or I must maid brand new automation for that ? something like that – every some minute coming specific colour ( green, red, blue, yellow, purple - etc.)
alias: I korrus esik Disco
trigger:
platform: time
seconds: ‘/30’
action:
service: light.turn_on
entity_id:
@anon43302295 my device is tasmotad Magic Home LED controller in ARilux LC01 Mode and seems that not supported “effect:” command - when I wrote to automatsion
- alias: Police
trigger:
- platform: state
entity_id: alarm_control_panel.house
to: 'triggered'
action:
service: light.turn_on
entity_id: group.all_lights
data_template:
brightness: 250
color_name: >
{% set colors = [‘red’, ‘yellow’, ‘blue’, ‘green’, ‘purple’] %}
{{ colors|random }}
Error loading /config/configuration.yaml: while scanning for the next token found character '%' that cannot start any token in "/config/automations/test.yaml", line 12, column 10
He mf, thanks for the reply, now it says there’s a coloring issue?
I am using a magichome RGB LED strips flashed with tasmota.
Best thing is to just set an effect on a light in an automation, but i cant figure out how to.
Invalid config for [automation]: invalid template (TemplateSyntaxError: unexpected char '‘' at 17) for dictionary value @ data['action'][0]['data_template']['color_name']. Got None. (See /config/configuration.yaml, line 169). Please check the docs at https://home-assistant.io/components/automation/