Setting msg.payload.entity_id

This is driving me nuts. In a function, I’m trying to do this:

msg.payload.entity_id = 'camera1';
return msg;

But the entity_id property isn’t added to msg.

I need to set the entity’s ID to that exact property as opposed to msg.payload.DATA.entity_id because from my understanding it’s how the current_state node wants it:

What should I do?

Looks ok to me except for the entity id. Doesn’t camera1 have a domain?
I don’t use camera platform from docs should be

camera.camera1

You are right. I wrote camera1 as example but in reality it’s image_processing.tensorflow_camera1.

So what else could the problem be?

I would guess that msg.payload is not an object but you’re trying to set a property of it as if it was.

msg.payload = {
  entity_id: "camera1"
}

edit:
Also you’re not going to get the expected results from Entity Location set to msg.payload.data for the exact same reason.