HestiaPi / hestia-touch-openhab

OpenHAB2 files for HestiaPi Touch model
GNU General Public License v3.0
60 stars 17 forks source link

Update packitupandgo.sh to support JSONDB #46

Open gulliverrr opened 4 years ago

gulliverrr commented 4 years ago

/home/pi/scripts/packitupandgo.sh needs updating as sudo rm -f /var/lib/openhab2/persistence/mapdb/*; is not getting reinitialised on first boot as mentioned here. @rkoshak should we keep this line in and work around initialisation or something else?

rkoshak commented 4 years ago

I think I need more info.

The way I'm expecting it to work is that on the first boot the MapDB is empty. Once the Initialization Rule kicks off, it commands and updates the settings Items with appropriate defaults based on the initial settings (Temp Unit Type, System Type which get pulled from the files in scripts). At that point those values and any subsequent changes to them get saved to MapDB and restored the next time OH is booted.

If you watch openhab.log during a boot, you should see a bunch of log statements along the lines of "Blah is undefined initializing to blah". That indicates the Item was not restored from the database. The next time you boot those lines will disappear indicating that the Item's state was restored from MapDB. You can set the initialization logger to DEBUG and see what they are restored to in the logs if desired.

So my questions are:

Assuming that it's working right, I think we want to delete the MapDB files which will give the users a nice clean environment with everything initialized to the hard coded defaults to start with (similar to how it came up before every time it rebooted before all these changes). Without deleting the MapDB files, any changes you make prior to cutting the SD card image will be preserved and restored when the users first boot.