Node Red Companion - Do I need it?

Hi just getting into Node Red. I installed the add on and its running as expected.
I then installed the companion, which although it installs I cant work out what its meant to do.
installing The companion just creates an entry called “name” which says "no devices or entities.
Question is do I need it in a HA only environment or is it for external NR installs maybe?
Thanks

There is another set of HA nodes further down the left side bar.

image

These nodes will create entities in home assistant. They show up under the companion integration. It also allows you to shut off certain home assistant nodes.

Event state or trigger nodes can use this. It is NR’s adaptation of the switch an automation in HA has. To disable/enable an automation.

1 Like

Hi! I add one binary sensor (Rain sensor) working fine, I can see in HA. Than I tried to add one Athmospheric Pressure sensor as Sensor, but no succes. No clear instruction for settings. Wat is Attribute key, value, and Output properties.
Untill now HA says “This entity is no longer being provided by the nodered integration. If the entity is no longer in use, delete it in settings.”
image

These nodes are all well documented but I do recall my own confusion when I first tried to set up my own HA sensor from Node-RED. There is a lot going on…

To be clear, each HA sensor requires

  • one and only one HA server configuration node, correctly setup and working
  • an entity configuration node, one per sensor, correctly configured to use the HA server
  • a flow node (the blue sensor node) that is configured to connect with the entity configuration node

To answer your specific questions:
The Attributes are extra key-value data that can optionally be added to an entity in Home Assistant. The main entity (sensor) has the entity state value updated, usually from msg.payload. As an extra, the ‘friendly name’ is typically added as an attribute. The Sensor node allows for additional attributes of your choice to be added, which is a way to pass extra information and large objects/arrays to Home Assistant, along with the entity state value.
The Output Properties are properties (message key-values) that are output from the node after the entity has been updated. These are optional extra fields that you might want later, perhaps recording the ‘sent’ data that was actually passed to Home Assistant, or to do any post-action data manipulation ahead of the next node in your flow.

So, as an example:

I drag and drop a Sensor node, and edit

  • the Name is the name of the node in the flow
  • I need to add (+) an Entity config node (see below)
  • I keep the default to update the sensor (entity) State from msg.payload
  • I optionally add an Attribute (key is the name, value is whatever I want this to be set to)
  • I optionally add an Output, here passing the ‘sent data’ into msg.test

Here is the Entity config node, that is created using the (+) above

This is the minimum required:

  • the Name is the name of this configuration node (not the flow node, and not the name of the entity in HA)
  • the Server is my HA server (pick from the list of the one you should already have)
  • I keep the default Type as ‘sensor’ in this case
  • the Friendly name is very important to enter when you first create this configuration node, as this will be the name of the entity in Home Assistant

You can add a Device class (pressure) and a Unit of measurement, but these are optional

That will get you an Entity configuration node, and a Sensor (entity) node for the flow. Deployment will create the new entity (using the Friendly Name), and passing msg.payload into the node will update the entity state value (and any optional attributes).

This is the output message from the Sensor node when I input msg.payload as 42:
You can see ‘test’ has been created as an output property of the message.

{
    "_msgid":"d7c22254138a7aa3",
    "payload":42,
    "test": {
        "type":"nodered/entity",
        "server_id":"ae8c890fd1f09885",
        "node_id":"4e9da3e623babe01",
        "state":42,
        "attributes": {
            "extra_details":"only if you need this"
        },
    "id":469
    }
}

Here is the new entity (sensor) with both a state and attribute in Home Assistant

You will see the name is the Friendly Name I used in the Entity Configuration editor. This is important.

When you first create a new Entity Config node, and then deploy this, the HA WebSocket is used to register the new entity (sensor) in Home Assistant. This creates the new entity for the very first time, and gives it a name.

This entity belongs to Node-RED (since NR created it) and it will stick around in Home Assistant, even when Node-RED stops using it. If you edit the Entity Config node and change the name, at the next deployment Node-RED might add a new entity with the new name, rather than changing the name of the existing entity. This leaves orphaned entities in Home Assistant.

You will typically see “This entity is no longer being provided…” when any integration that created an entity is restarted and, at restart, does not re-register all the entities that belong to it.

To avoid this issue, it is important to edit the Entity Config node correct the very first time it is created, and to add the Friendly Name. If you ever need to change the name of an entity, then first disable the Entity Config node, re-deploy, check in Home Assistant that the entity has gone, then edit the name in the Entity Config, enable the config node, and redeploy. Unless someone else has a better way of doing this, this is how I change Entity Config nodes.

I suggest that you delete your problematic Sensor (both the flow node and the config node) and redeploy to clear, then start again. You may need to delete the orphaned node in HA, although this can sometimes be difficult and may require an HA restart to actually get it to go.

Hope this helps!

2 Likes

Thanks! Problem solved!