I’m migrating the documentation of the Core Actions to the official docs and I’m confused by the storeStates and restoreStates actions. I’ve never heard of these before and the description on the wiki is not complete enough for me to understand. And given that at least one of the entries isn’t even an action (it’s a method call on a Group) I’m questioning whether these are indeed actions or something else.
Map<Item, State> storeStates(Item... items): Stores the current state of a list of items in a map which can be assigned to a variable. Group items are not themselves put into the map, but instead all their members.
restoreStates(Map<Item, State> statesMap): Restores item states from a map. If the saved state can be interpreted as a command, a command is sent for the item (and the physical device can send a status update if occurred). If it is no valid command, the item state is directly updated to the saved value.
Starting with storeStates:
does this return a Map<Item, State>? If I call this from one rule then restoreStates from another rule will it work? I’ve learned long ago that one cannot use the Item as the key in a Map and one must use the Item.name as the key because the object ID of the Item changes from one rule instance to the next.
Do I pass Items like the following:
storeStates(Item1, Item2, Item3)or do I need to create a java.lang.List?
And with restoreStates:
- The description on when a command is sent verses an update is unclear. Does this mean that if I have String or Number Items they will only receive updates whereas Switches and Contacts will receive commands?
Can someone please:
- confirm these are indeed actions
- are still valid for OH 2
- post a couple of examples
They appear to have been there since the beginning in @kai’s initial verison in 2013.