Twoway switch with esp raspberrypi mqtt openhab

Hi all,

I am new to open hab and started my first project.

I am trying make twoway switch in openhab

I have ESP32 connected with relay which is subscribed to MQTT toppic (AM_LivingLight1_Channel)

i have created thing that is linked to an item AM_LivingLight1 which is a switch

when i turn on light from openhab UI it published “ON” on (AM_LivingLight1_Channel)
which is then received by ESP and turns on relay.

Its working fine, but i am having issue with by second switch which is a push button switch directly attached with ESP32s when i press it, it turns on/off light but the current status of light is not reflecting on my Openhab UI

since i turned light off using pushbutton it doesnot reflect on Openhab UI,
I tried publishing ON/OFF message from ESP to (AM_LivingLight1_Channel)
but no luck, please assist

You should probably look at how Tasmota does this. Essentially, you set up your device to report status changes on a different topic to the one it uses for incoming instructions.

Is that the topic or the name of the openHAB thing?

Can you post the thing config?


Appologies, I missed to reply back here.
this issue is solved, Earlier I had some issue with the code in my ESP after some debugging it got resolved.

Please tick the solution, thanks