Sometimes one needs to create a flag, control, switch, or some other control that is not bound to a device or channel. For example, a Switch to override presence detection.
Concept
Create an Item that does not have a binding configuration.
Simple Example
Switch VirtualItem "label" <icon> (groups) // No binding config
Virtual Items are a good way to store state needed by rules and to provide a way to allow the user to modify the behavior of their rules by adjusting parameters stored in Virtual Items. Data stored in Virtual Items can also be persisted and restored on startup unlike global vars and vals.
Related Design Patterns
Proxy Item: A Proxy Item is a special case for Virtual Items
Wow, wanted to bump this old DP up because I had never stumbled across it before and it is a great explanation for what I call ‘dummy’ items in my rule examples. Thanks for this Rich and I hope you don’t mind if I link to this thread in my example threads.
The DPs are there to be linked to. Most of there were written because I got tired of typing the same thing over and over again. Please do link to it and I’m happy you found it useful.
Because I have been trying to define a simple logical (unbound) Switch item to set a certain “alert” status to on or off manually (to then use further in rules) but the state of the switch (at least in Basic UI) does not seem to persist?
Perhaps you could show us what you do. An Item state stays the way it is until something happens - a new update, or system reboot etc.
“Persist” is generally taken to mean a means of surviving e.g. a reboot, but maybe that is not what you meant.
If I open the Basic UI on for example my phone and desktop at the same time, I can toggle the switch from either device, but the state is not reflected on the other device.
Have you tried manually reloading the Sitemap on the other device. Because I’m not sure if you will always see the updated state on the second device otherwise. The best way to see if it works is to look at the event log and not at the ui.
Johannes
I restarted OpenHAB and that did the trick! Tested by spamming (slowly*) about 5-10 times from each device. Works flawlessly now both ways, and also reflected in logs which I had open in another window.
Now, off to write some rules, incorporating my new button(s)!
* I mean it is a big Java thing at the end of the day after all I kid because I love