Super simple dumb question about changing light colors YAML/ESPhome

It’s been a newb journey but i am finally successfully turning lights on and off with buttons i set up on a CYD. But why isn’t this code working to change a bulb’s color? Any help appreciated, hazing authorized. Thanks!

then:
  - logger.log: Change to red!
  - homeassistant.action:
      service: light.toggle
      data:
        entity_id: light.merkury_bw904_smart_bulb_2
        rgb_color: [255, 0, 0]

Here’s the error returned when I try to install:

then: 
  - logger.log: Change to red!
  - homeassistant.action: 
      service: light.toggle
      data: 
        entity_id: light.merkury_bw904_smart_bulb_2
        
        Must be string, got <class 'esphome.helpers.EList'>. did you forget putting quotes around the value?.

You can’t send structured data, like a list, to home assistant. There’s an example in the esphome docs that cover exactly what you’re trying to do. You’ll need to create a script in HA and call that from your ESPHome device.

https://esphome.io/components/api/#homeassistantaction-action

Thank you so much! I broke through to a finished product with this point in the right direction.

1 Like