Switch Light depending on the current state

Hey guys,
I’m newbie to all this HA stuff. I’ve read through a number of posts that seem to be similar in use case, I’ve made some examples but none of them work as I would like to. First I’ll describe what I am trying to do. My wall switch and light is connected to PLC, which is connected with RPI and Node-Red. I have got input_boolean from Node-Red which is current state of my light - “1” is “on”, “0” is “off”. I’d like to make in HA light switch that takes current state from this input_boolean but also which gives me the ability to control this light by manually pressing the button, depending on its state.

For example:
When I turn light on by switch on the wall, state change in HA to “ON” also, then when I press switch/light in HA, i’d like to switch light off by sending to Node-Red another boolean to do that. When PLC will switch off the light, state in HA will change as well.

It is possible? I will be grateful for examples, all advice and help.