State Mismatched between Items and Actual Device

I have a situation that when a user swipe a switch button on openhab, the command is propagated to the end device via wifi. Unfortunately, the wireless network can be unreliable sometime and the command does not reach the end device to do the job. I have tried the following approaches in my custom binding but without satisfactory user experience

  1. On Openhab, wait for the response (let’s say 2sec) from the end device. If no response, rollback the switch state to previous state. Verdict: every swipe on openhab, user needs to stare on the screen in a hope that it does not rollback to previous state
  2. After user swipe on a switch on openhab, leave the state as it is. Then poll on the background to get the latest state from end device. Verdict: resourceful and on/off on openhab does not guarantee tht the command has reached the end device.

Apart from the above options, what other built in features that I can use on openhab to reliably ensure tht swiping on/off on a light switch is actually on/off on end device? The idea is really to rely on openhab/smarthome framework to check and resend command automatically until both the openhab and end device states matched. Otherwise , what other approaches would you suggest to get around this and yet provide a good user experience?

Actually that’s exactly a question I have asked myself a lot of times already. A “disabled”/“waiting for backend response” state for items is missing, where the respective widget is grayed out and give the user a visual feedback that the action is not confirmed yet.