# Current State entity\_id override

**URL:** <https://discourse.nodered.org/t/current-state-entity-id-override/17191>\
**Category:** General\
**Created:** [27 October 2019 11:48 UTC](https://discourse.nodered.org/t/current-state-entity-id-override/17191 "2019-10-27T11:48:00Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![M-a-r-k](https://avatars.discourse-cdn.com/v4/letter/m/9e8a1a/32.png) [@M-a-r-k](https://discourse.nodered.org/u/M-a-r-k)\
**Post date:** [27 October 2019 11:48 UTC](https://discourse.nodered.org/t/current-state-entity-id-override/17191/1 "2019-10-27T11:48:01Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [27 October 2019 12:11 UTC](https://discourse.nodered.org/t/current-state-entity-id-override/17191/2 "2019-10-27T12:11:56Z")

</div>

> [@M-a-r-k](#):
>
> by the information of the node this is what i should do

Where is the information that you can change the entity\_id?

---

<div class="post-metadata">

**Author:** ![M-a-r-k](https://avatars.discourse-cdn.com/v4/letter/m/9e8a1a/32.png) [@M-a-r-k](https://discourse.nodered.org/u/M-a-r-k)\
**Post date:** [27 October 2019 12:29 UTC](https://discourse.nodered.org/t/current-state-entity-id-override/17191/3 "2019-10-27T12:29:05Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [27 October 2019 12:42 UTC](https://discourse.nodered.org/t/current-state-entity-id-override/17191/4 "2019-10-27T12:42:37Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![M-a-r-k](https://avatars.discourse-cdn.com/v4/letter/m/9e8a1a/32.png) [@M-a-r-k](https://discourse.nodered.org/u/M-a-r-k)\
**Post date:** [27 October 2019 13:35 UTC](https://discourse.nodered.org/t/current-state-entity-id-override/17191/5 "2019-10-27T13:35:46Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![M-a-r-k](https://avatars.discourse-cdn.com/v4/letter/m/9e8a1a/32.png) [@M-a-r-k](https://discourse.nodered.org/u/M-a-r-k)\
**Post date:** [27 October 2019 13:41 UTC](https://discourse.nodered.org/t/current-state-entity-id-override/17191/6 "2019-10-27T13:41:26Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [27 October 2019 15:48 UTC](https://discourse.nodered.org/t/current-state-entity-id-override/17191/7 "2019-10-27T15:48:31Z")

</div>

> [@M-a-r-k](#):
>
> 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;

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 ={}`

---

<div class="post-metadata">

**Author:** ![M-a-r-k](https://avatars.discourse-cdn.com/v4/letter/m/9e8a1a/32.png) [@M-a-r-k](https://discourse.nodered.org/u/M-a-r-k)\
**Post date:** [28 October 2019 22:27 UTC](https://discourse.nodered.org/t/current-state-entity-id-override/17191/8 "2019-10-28T22:27:38Z")

</div>

Thanks that works, thanks so much ukmoose
