In Node-Red, how to configure a HA sensor-entity-node to receive state data from a device

Hello all,
here’s a request for help.
I would like to get a node-red device, feed its output into a NodeRed-HA-sensor-entity-node, so it can act as the devices sensor, visible to HA. Unfortunately, attempts to get the fevice funtioning properly directly in HA, were unsucessful.
The device is working fine. The reason for my request is, that I don’t have the coding knowledge or understanding, to get doing as requested.

this is the setup in question:

The sensor’s config form is opened. Next to it, the output data of the device

I’d appreciate, some guidance, as to what goes where and how.

msg.payload.object is not the right path. You also do not need any attributes, you can delete them all.
Next to the value for ulimitset there will be a button for copy path, choose that. Then paste that result where msg.payload.object is.

hey Mike,
I will give it a whirl, asap. will report back.
For now, thank you for the quick reply.

Hello Mike,
followed up on you suggestion. It did something correctly. The sensor node ist filled with the message data. for some reason, it still produces an API error. Still looking for a possible reason. Maybe you are quicker

Sorry didn’t notice you had it set to sensor, it needs to be a binary sensor. true/false, open/close, on/off, whenever it is a yes or no type answer it will be a binary sensor.

To add about attributes, this is secondary information that can also be sent to the sensor. To add an attribute, use the same method you used to get the path, then when you add the attribute set it to msg. and paste the path in the attribute value box. The sensor/binary sensor is set according to the primary value.

I see. Well there is lots of nonbinary data, which i am interested in using. I’ll just tinker on. I have made non-binary sensors work to display number states, but the output from their connected device, was configured in such a way, that only the required data is transmitted.

I’d live to cut back on entities though, and love to configure the sensors to catch the entire dataset. And it did work, by the way. as you can see here:

Still, the API error puzzles me

Which path are you using? It should be the yellow.

Why ulimitset? That only indicates, whether the upper limit is set. Its upperlimit set, tru/false.

the ones I am inteested in are control [on/off], percent_control: [int], percent_state: [int]:work_state:[opening/stopped/closing]

That’s fine just use the path above completeData for your path.

use this section
Screenshot 2021-07-26 135738

Thanks for your help. I think the issue is solved.

On the same flow, there now seems to be another issue. It concerns feedback reporting and command acceptance of the device node (the grey node in the flow graphic).

It seems, that there is some form of hibernation mode for the node. As it happens, it does not consistently report position back to node-red or home assistant. At the same time, commands from node-red or HA are not executed. However, using the devices own control app, shutter position is being reported and commands are executed immediately and correctly.

I work with input_booleans to transmit commands from HA to the node-red, where the state change node should sense the input booleans state change, and send the respective command string message payload straight to the device node

Any ideas on that, too?

Sounds like it is the device’s integration. Does it primarily connect to nodered or is there an integration in HA? If it connects to HA you have to trouble shoot that first.

If it connects directly to nodered, try the nodered forum.

Hey Mike,
thanks for the reply. Only just read it. In the meantime, I found a possible solution. Apparently, this has been implemented by the creators of the nodes. Sending a “?” to the device node, will wake it up and return present state

I am trying to get the attributes of a mqtt json object. How do I pull the individual attributes into the Entity?

@rlust I guess your debug node is set to Payload? I can suggest to (mostly) always set it to whole message object to see the full message.

Generally in NR you have:

  • messages: the whole thing that gets transferred between nodes
  • objects: are inside a message and can contain more objects or keys
  • keys: or key-value pairs contain the actual data

The grey object just says that config or state are objects. You can’t use object in the State field

You can set your dgn attribute via msg. payload.state.dgn. Then the attribute should have the value 1FFF4
If your debug node is set to whole message object it would just be msg. state.dgn

Syntox thanks so much for your help! My brain is missing something in your explanation. I need a picture. Could you give me an example of how to pull attributes into an entity. Does not need to be like mine just an idea of where to put the objects. Thanks so much!

In the attribute key, hit the add button under that section. Take the message path from the debug node.

I have set my Debug node to complete msg object to see the entire message in the debug log:
image

In the entity-node you just put the path of the wanted value (1FFF4) inside the value field of the attribute. You can copy the path by clicking the icon (green box) next to the wanted value in your debug log. And of course, don’t forget to select msg. from the dropdown so it’ll be msg.PATH.TO.VALUE:

Also, the device class isn’t sensor. You’ve configured the node to be a sensor in the Type dropdown before.
Possible device classes can be seen here:

2 Likes

So is there a way to filter payload information with the exception of some specific information? Basically I have a numerically that defines (by measured distance) whether my car is in the garage or not. I cant seam to filter out this information. I’m posting here as I am using the entity node to push the data to my dash board. A “True” response mean car is occuping the garage, false is vacant, and because my sensor some times returns an unknown response this to is marked as vacant, the problem is the sensor sends its numerically information and posts it to the dash board, This information I do not want.

Have you tried using the Change Node to extract the part of the payload you are interested in and put it into a separate message variable?

For instance, in the above example it’s extracting the current temperature from the panel heater and putting it into the msg.currtemp variable.

You can extract the path to the variable in question by hovering over the attribute and then selecting “Copy Path” from the icons that show up on the right of the highlighted row. All you need to do is then paste that into the “to the value” box, give the msg. variable an appropriate name and hit OK.