openhab / openhab-webui

Web UIs of openHAB
Eclipse Public License 2.0
212 stars 232 forks source link

[BasicUI] Switch with buttons: item state update can be ignored #2537

Closed lolodomo closed 3 weeks ago

lolodomo commented 3 weeks ago

Which UI are you reporting an issue for?

The problem

It can happen that an item state update is ignored for a switch element rendered with buttons. It happens after clicking twice on the same button. Then the next received item state update that should change the selected button is ignored.

Expected behavior

When receiving any item state update, the buttons should be updated to show this last state whatever the previous actions done on this sitemap element.

Steps to reproduce

  1. Click a first time to a particular button. The command associated to this button is sent to the item.
  2. Click a second time on a same button. The command associated to this button is sent to the item but this time there is no feedback state received because the item state is not changed (same state).
  3. Now change the item state from another mean (another sitemap element for example). You can see that the sitemap element is not updated, the same button is still enabled while another should.

Additional information

This is due to the fact that when clicking a button, the state of all buttons is updated immediately before sending the command and then Basic UI is setting a flag to ignore the next event which generally is the feedback event to the command acting the change of the state. But if the command does not trigger any state update, Basic UI still is in a state that the next update will be ignored for this element.

I believe the idea was to show immediately the result of pushing a button without waiting for the server feedback. And then there was a kind of optimization to not reselect the button when receiving the feedback event as it is the most frequent case.

To cover all cases, this optimisation has to be removed.