Update entity when light is operated by PLC

Hello,

I have an Siemens PLC to control my house and use Home assistant for the visualization.
I made and light switch entity to operate the light, also the light bulb icon colors if i press on the bulb.
I can operate the light in the PLC.
But when i operate the light from push button that is connected to the PLC, home assistant light bulb doesn’t change from state because there was no feedback.
Therefore i made an switch node to change the state of the entity. But when i operate the light from Home assistant the light goes immidiatly back off because the state of entity is changed.
I may only update the entity when the value of PLC and entity are different.
therefore i downloaded an boolean library to use XOR function but is says always unknown state because the state value of entities are only send when state is changed. Does someone have a solution for this?
Many thanks for your help.
Sorry for the dutch (lamp means light)

Regards,
Jeroen