How create a rule for manual/autimatic mode

how to create a rule for switch using HABApp with the following logic?
Switching to manual - Manual mode
Switching from another rule - Auto mode
if Manual mode - The switch is switched
if Auto mode and previous mode is Manual mode - The switch is not switched
if Auto mode and previous mode is Auto mode - The switch is switched

You can use the MultiModeItem and the SwitchItemValueMode.
It’s possible to check if the SwitchItemValueMode is disabled an then enable it.

A wonderful example. I’ll try to make a rule based on it