From Node Red in Home Assistant
I'm trying to change the entity_id of a current state node, by injecting msg,payload.entity_id="binary_sensor.multisensor_mbr_motion" into the node from a function node, by the information of the node this is what i should do, but it doesn't work, any help much appreciated.
Where is the information that you can change the entity_id?
Click the node, open slider on right, for debug window, its the first icon info, first heading inputs, reads payload.entity_id
Overrides or sets the entity_id for which the current state is being fetched
Do we have the same software and flows running as you ?
Can you give a little more context, we cannot reverse engineer your problem. What does your flow look like, what do the debug nodes output ? What is the content of your function node etc.
I have
Node 1, inject node injecting time stamp.
Node 2, Function node Line 1 msg.payload.entity_id="binary_sensor.multisensor_mbr_motion";
Line 2 return msg;
Node 3, current state node, Serve: home assistant
entity ID: binary_sensor.multisensor_hw_motion
If State: is off
Node 4, Debug node, msg. data
To debug window: true
output
{"entity_id":"binary_sensor.multisensor_hw_motion","state":"off","attributes":{"friendly_name":"Multisensor HW motion","device_class":"motion"},"last_changed":"2019-10-27T13:07:57.224005+00:00","last_updated":"2019-10-27T13:07:57.224005+00:00","context":{"id":"81e17d96c4d74035a2b9012cf021f662","parent_id":null,"user_id":null},"timeSinceChangedMs":1767735}
Expected output for binary_sensor.multisensor_mbr_motion
If you are injecting a timestamp in node1 msg.payload is a number
in node2 you now want msg.payload to be an object.
But it can't be an object because it is a number and it can't be both at the same time.
So you would need to define it as an object first msg.payload ={}
Thanks that works, thanks so much ukmoose