What is autoupdate?
This is explained by many people on different places, here one more refresher.
In openHAB, when an item is linked via channel to a device, and the item sends a command to the device, different things can happen:
- the device near instantly updates its state, so that it matches the received command, and announces its new state;
- the device near instantly updates its state, so that it matches the received command, and does not announce the new state. Bindings behaving this way are improperly implemented;
- the device can ignore the command - keep on purpose its old state and announce the old state, thus
ItemStateUpdateTriggerdoes fire; - the device can ignore the command - keep on purpose its old state and do not announce the old state. In this case there is no event propagating the old state,
ItemStateUpdateTriggerdoes not fire; - the device can act slow, e.g. because it is far away; signals are lost and need to be repeated; or for mechanical reasons changing the state can take a while, so the device updates its state after a while, and then announces its new state;
- the device can be offline - openHAB sends a command, the command does not reach the device, the device does not update its state.
Items in openHAB have a property autoupdate, which has a default value for all items in openHAB, and can be overwritten per item. With autoupdate=true, when the value of the item is changed by openHAB, and the item is linked to a device, openHAB at the same time updates the state of the item within openHAB and sends the command to the device. When autoupdate=false, openHAB sends the command to the device, the device updates the state of the item, eventually notifying the UIs over the new state.
In particular, with autoupdate=false, when the device is offline, the state of the item is not changed; when the device acts slow, the state of the item is changed delayed. With autoupdate=true the state of the item is changed instantly, it is irrelevant if the device is slow or offline.
How should IU implement autoupdate=false for a switch?
There are different possiblities to implement autoupdate=false, when the user clicks in the UIs:
- The switch UI component intercepts the click/touch event, and from the intercepted event handler sends the command to the device. The intercepted event handler prevents the default action to happen (toggle the switch). After the device updates the state, there is an event in openHAB, and after that event is received by the UI, the item is updated in the UI.
- The switch UI component sends the command to the device, and at the same time changes the visual state of the toggle. So there is a difference between state of toggle and state of item and this difference creates an illusion. If after a while no event is received from openHAB, that the state of the item was changed, the switch UI component reverts to its old state, and state of UI-toggle and state of item coincide again.
An advantage of the second approach is that the user sees that the toggle command was accepted. A disadvantage is, that in case the device is slow, the toggle changes its state on the click event, reverts to its old state shortly afterwards, and when the device updates its state, the switch is toggled again. So there are in total three togglings, instead of one.
In the first approach there can also be implemented means, indicating that the toggle command was received by the UI, different from toggling the switch. Users might also not need feedback from the UI that the click command was accepted by the UI, users can get used to the fact that the UI updates its state for autoupdate=false items, only after and if the device has updated its state.
For items with autoupdate=true both approaches behave the same; users do not notice a difference, if the first or second approach is implemented.
This question is on purpose restrained to the simplest case - switch item, and avoids design discussions for slider or color light.
How do you think switch/toggle items should be implemented in the UIs of openHAB, when the items have autoupdate="false" metadata? Which of the mentioned approaches should be preferred? Should some completely diffent way be taken?



