I’ve different light scenes stored in a Map. Is there a way to restore this Map when a rule starts or when the system starts?
The var that I want to store and restore looks as follows:
var HashMap <String, Map> SceneMaps = new HashMap()
I’ve different light scenes stored in a Map. Is there a way to restore this Map when a rule starts or when the system starts?
The var that I want to store and restore looks as follows:
var HashMap <String, Map> SceneMaps = new HashMap()
Create a system started rule and populate it there. Even better, consider moving the values in the map to Items, name those items so you can find them by name, put them in a group and use gMyGroup.members.filter(i| i.name == name). Then persistence will handle the restore, your rules will become simpler, and you have the option to update the values on the sitemap. I do this and it madness my does far simpler abd shorter than when i was using hashMaps.
This method seems not to work anymore with openHAB 3. Are there recommended patterns for such a kind of population?
Best regards,
ceedee
Things have changed a little after six years.
You can still do exactly as described in this thread, by doing it the way it would have been done at the time - using rules in xxx.rules
files. Not in GUI rule editor.
Well, using the .rules-files does not work anymore. I replaced the “System started” trigger with a cron trigger and things started working after the cron condition was reached. So the System Started trigger seems to have changed its functionality.
Yes, it no longer fires on editing a xxx.rules
file.
In consequence, editing this .rules-file will require either working with the cron workaround for testing or some other way. What I’m asking for is: what is that other, non-workaround way, to initialize member variables in a rule file properly (so that they are initialized in both cases)?
transform("MAP", "mymapfile.map", "Value")
to access the value assuming that it’s unchanging data.Thank you! I will explore the options. Currently, since it’s static data, I find the map/transform approach very appealing!