Switch should update with status update

I am new to Openhab. I connected NodeMCU with Openhab using MQTT and its working. What I want now is to update switch when the status changes. I wrote an example code like this

if(payload[0] == '1'){
    digitalWrite(relay1, LOW);
    client.publish("room1/light1confirm", "ON");
    delay(5000);
    client.publish("room1/light1confirm", "OFF");

  }

Item coded as

Switch room1_light1 "Light 1[%s]" <light> {mqtt=">[mymqtt:room1/light1:command:*:MAP(onoff.map)],<[mymqtt:room1/light1confirm:state:*:MAP(onoff.map)]"}

So when the switch room1_light1 is toggled to on it should ON and after a delay of 5sec when the OFF status is published on room1/light1confirm the switch should toggle back to off position.

I am getting the message on my MQTT console, but the switch is not toggling back to OFF

Hello Ajay,
This time you don’t need the MAP transform because the payload of your mqtt reply from your nodeMUC is ON or OFF which is understood by openHAB.
So do like this:
<[mymqtt:room1/light1confirm:state:default]

And again you didn’t read the docs…
The outbound mqtt binding that 5 parameters
The inbound only 4 no need for :*: