HA Entity Switch node in Node-RED ignoring input for state synchronization

Hello everyone,

I am trying to set up a bidirectional synchronization for a Home Assistant Entity Switch node in Node-RED.

My Goal: I want to have a switch in Home Assistant that controls a relay (UniPi). At the same time, I need this switch to reflect the real-time state of the light, which can be toggled by other external sources.

My Setup:

  • I am using the home-assistant-entities-switch node.
  • I have a logic branch that monitors the hardware state and sends a boolean (true/false) to the input of this Switch node.

The Problem: The Switch node completely ignores the input payload. Even though I can see the correct boolean values arriving at the node in the debug console, the entity state in Home Assistant does not change and the icon remains unmoved.

I have also tried using an events: state node to feed the state back into the switch, but the result is the same—the node receives the message (timestamp updates) but the internal state of the HA entity is not updated.

Questions:

  1. Does the HA Entity Switch node intentionally ignore input payloads to prevent loops?
  2. Is there a specific property I need to include in the msg object (e.g., within msg.data or a specific msg.topic) to force a state update without triggering an output command?

Any advice on how to achieve this “feedback” state synchronization using the Entity Switch node would be greatly appreciated.

Thank you!

You need to set msg.enable to either true or false to change the state of the switch from an input message.

https://zachowj.github.io/node-red-contrib-home-assistant-websocket/node/switch.html#msg-enable

Thanks a lot - you were right msg.enable with entity state “as Home Assistant Boolean” works.
I had to add state node and sensor node.