How to avoid lots of switch.nodered_********** entities in Home Assistant, from Node-RED Companion?

I like the UX of the Device nodes in Node-RED:

The form is a bit nicer with autocomplete for device names and triggers. But I find it annoying that Node-RED Companion adds a bunch of switch.nodered_********** entities to Home Assistant:

Any way to avoid this by default? Or should I switch to using “events:state” nodes?

I also have an annoying problem where many of the device nodes seem to randomly go into a DISABLED state, and I have re-enable them. I’m not sure why that happens. Maybe that’s another good reason to just use “events:state” nodes.

I am no expert, but I have dozens of Node Red flows integrated with my Home Assistant, but I have never needed the “Device” node. What am I missing? I use “call service” and “current state” nodes a lot.

1 Like

I think it’s just a matter of preference, although the implementation / performance might be a little different behind the scenes. I agree, the “call service” and “current state” nodes are probably all we need.

There’s supposed to be a checkbox like “expose to home assistant” I believe. That makes a switch entity with the name and icon you specify at the bottom in the “home assistant config” section. That switch can then be used to toggle the node on and off without needing a redeploy of node red. You can see this behavior working properly if you try it with an events:state node.

I’m guessing you just found a bug with the device node. Since it seems to be making that switch without you telling it to. The node is marked as alpha in the warning at the top so bugs are probably to be expected. You should report it here

They are useful if you are using ZigBee devices at least.
Instead of setting up a events state node listening to the ZHA then either using switch nodes to get to the part you want, or using a function node like:

if(msg.payload.event.device_id == "f594d0a16628c130b023f476a35c0091" && msg.payload.event.command == "move"){
... and so on...
}

With device you just use this:

A lot simpler than finding device id, command and arguments.

1 Like