Hello, I have a tradfri RBG bulb running on zigbee2mqtt and I am trying to get it to come on nightly with a random color. Note, these bulbs only use xy_color (no rgb_color I think). After searching a bit, I am first sandboxing with a simple call service to test. The call service data I tried returns the following error: “expected float for dictionary value @ data[‘xy_color’]”. Weird, bc I thought my code would produce float. My data is:
Just in case anyone is interested in this topic and was running into the same issue, I have figured out a working solution. Albeit there are likely easier solutions out there. I wrote a quick python script, Python Script and linked my automations to the script in order to get the Ikea light bulb to randomly change color when turned on.
entity_id = data.get("entity_id")
xy_color = [random.uniform(0, 1), random.uniform(0, 1)]
if entity_id is not None:
service_data = {"entity_id": entity_id, "xy_color": xy_color}
hass.services.call("light", "turn_on", service_data, False)