Passing Entity and RGB Data to Call Service node

Long story short, I’ve got a colour loop subflow that looks like so

var i = flow.get("i");
var red   = Math.round(Math.sin(0.3*i + 0) * 127 + 128);
var green = Math.round(Math.sin(0.3*i + 2) * 127 + 128);
var blue  = Math.round(Math.sin(0.3*i + 4) * 127 + 128);

i++;
if (i>=32) {
    i = 0;
}

flow.set("i", i);

msg.payload = {
    domain: 'light',
    service: 'turn_on',
    entity_id: env.get('entity'), 
    data: {
        rgb_color: [red, green, blue],
        transition: 2  
    }
};

return msg;

I’m then passing this to a call service node like so.

It works fine via yaml

service: light.turn_on
target:
  entity_id: light.shelf
data:
  rgb_color:
    - 22
    - 22
    - 255

I’m not getting any errors but it’s not cycling the colours on the light. Any ideas? I can see it logging the payload out as

{"domain":"light","service":"turn_on","entity_id":"light.shelf","data":{"rgb_color":[17,117,247],"transition":2}}

move entity_id inside data

1 Like

Ah bloody hell. Thanks :smiley: