Success or failure of a sendCommand - jython rules

Definitely try sending the REFRESH command. I think Zigbee is one of the bindings that supports it. I know Zwave definitely is and since they have the same author, assuming Zigbee supports polling, I’d expect both support it.

That can be a way to force the binding to poll the device linked to that Item with it’s current state.

But just to be clear, that change is caused by autoupdate, not the binding. You don’t really know whether the device actually turned off. Autoupdate is updating the Item because it’s supposed to go OFF. But who knows what the device has actually done?

You won’t see that “predicted” entry in the logs when autoupdate is disabled and the Item won’t change to OFF until after the device actually reports that it’s turned off.

Are you sure? Or is it autoupdate that updated the Item? I’ve not seen any evidence that you’ve ever run with autoupdate disabled. Until you do that you don’t know what the binding is actually doing.

What I would do ion the library function is (after turning off autoupdate on the Item of course):

  1. sendCommand to the Item
  2. enter a busy wait while loop that loops until the Item changes or we’ve waited too long
    a. send a REFRESH command to the Item
    b. sleep an appropriate amount of time
  3. if the Item changed return, if not log an error and return

The amount of time to wait over all and the amount of time to wait in the loop you’ll have to determine. Each refresh command will hit your zigbee network so sending lots of REFRESH command real fast may cause more problems than it solves.

But in general I’ve found and have seen reported that Zigbee devices in general, even the cheap ones, tend to be pretty reliable. Maybe you don’t have a good mesh network and one or two more Zigbee devices is the true solution to your problems. It’s most likely that the command message is getting lost.

Another problem might be you are sending the commands too fast. I know that’s a problem with Hue so suspect it’s a generic Zigbee problem too. Adding a delay between commands to Zigbee devices might be the solution. See Design Pattern: Gate Keeper. There is a Python implementation linked to there that would only need to replace Joda DateTime with ZonedDateTime to make it usable in OH 3.

If it’s possible it’s possible from Jython. But in this case it’s a core capability available in all languages.

https://www.openhab.org/docs/configuration/actions.html#thing-status-action