Is it possible to set the LIFX bulbs to a random color? I looked the Lifx combinations and just see color loop, not random. Anyone have an example?
Thanks
Is it possible to set the LIFX bulbs to a random color? I looked the Lifx combinations and just see color loop, not random. Anyone have an example?
Thanks
Try thisL
- service: light.lifx_set_state
data_template:
entity_id: light.light_name
brightness: 255
rgb_color: [{{range(0, 255)|random}},{{range(0, 255)|random}},{{range(0, 255)|random}}]
FYI, the second value for range should be 256, not 255. (The last value produced by range must be less than the second parameter. So, to get values up to 255, the second parameter should be 256.) In fact, you can just use range(256), because the default start value is zero.
Thanks for pointing this out. Doubt it will make any difference in the end result for this specific case, but I like to be corrected
Thanks - but something still isnât quite right. Iâm trying to convert this into an automation from Smartthings webcore for a Lutron pico. Iâm using a different pico example I found here.
Here is what I have:
This is giving me this error:
ERROR:homeassistant.util.yaml:invalid key: âOrderedDict([(ârange(0â, None), (â255)|randomâ, None)])â
in â/config/automations.yamlâ, line 41, column 0
Failed config
General Errors:
- Error loading /config/configuration.yaml: invalid key: âOrderedDict([(ârange(0â, None), (â255)|randomâ, None)])â
in â/config/automations.yamlâ, line 41, column 0
Successful config (partial)
Needed quotes are missing:
rgb_color: ["{{range(256)|random}}","{{range(256)|random}}","{{range(256)|random}}"]
When do you need quotes for RGB parameters and when do you not? I have a few LED strips that I defined as JSON MQTT lights and I donât need the quotesâŚ
Itâs not whether you need them for RGB, but whether you need them for templates, which is just about always (at least if you donât use multi-line, which you really canât in this situation.) If you donât use the quotes the YAML parser will see the curly braces and think they are the start of a dictionary.