How to control a node-red device from within home assistant

Hi All
I have HA and node-red correctly setup now (so it seems) and am able to update an entity sensor in home assistant from node-red.

To do this I have created a device and an entity in node-red that now appears and updates in home assistant. Great!

I now want to control this device from within home assistant. The device is a water heater. node red measures the temperature of the water and passes it to home-assistant. I want home assistant to now be able to turn on or off the water heater. I think that within node-red I just need to listen to state change events but how to update the device that I created in node-red to allow me to turn on or off the water heater.

I have a similar problem with a garage door. I currently have a garage door controlled by node-red but I want to shadow this node-red device in home assistant and alllow it to control the devide in node red.

I hope that this makes sense! I am fairly new to HA and am not quite used to devices, entities and attributes at the moment.

similar approach with an Alexa light