NodeRed and ESP01 with Momentary Switch

Hi all,

I`m New to the forum but have used Node-RED for a while now.

All my flows programs and everything works..... Except for one thing.

I`ve created a dashboard with a couple of light switches on it. The light switches on and off perfectly.
If I press the momentary switch on my ESP01, the light switches on and off perfectly. (By the way, my ESP01 is running ESPEasy)
But let's say I switch on the light on my ESP01, it updates nicely and shows on my Dashboard that the light is switched on.
When I switch the light off on my dashboard the light switches off perfectly. So my Node-Red server knows exactly in which state my light is. But because I Switched the light on last on my ESP01 that device still thinks that the light is on, so when pressing the button for the first time it only then changes its state to off. So I have to press it again to be able to switch it on.

I have tried sending change status change messages through MQTT. The problem with this is the ESP then changes the input (Button) to an output. so then button presses don't work anymore until I restart the device.

If anybody has come across this or knows how to fix this please help.

What are the device settings in ESPeasy for the switch and do you have any rules in ESPeasy for the device?