I’ve merged the hierarchical settings development originally proposed and developed by @anna_carboncoop and @borpin into the emoncms master branch. This work has been ongoing for the last year as its quite a significant change to the way settings are handled within emoncms as well as providing a new ini based format.
The idea behind hierarchical settings is to have a default settings file as a starting point that includes all available settings, and then a user settings file that inherits the default settings and overwrites the defaults for only the settings that the user has included in their settings file. This makes updating and adding new settings easier and allows for a cleaner more compact user settings file.
The full list of default settings is available here:
and an example of a cut down settings file here:
; ----------------------------------------------------- ; Example emoncms settings.ini file ; ; default-settings.ini contains the default settings ; enter only the settings you wish to customise here ; the default settings are inherited ; ; The following is a barebones example, copy across ; other settings from default-settings.ini as required ; ; ----------------------------------------------------- ; MYSQL Database settings [sql] server = "localhost" database = "emoncms" username = "emoncms" password = "password" ; Redis Database (used as a cache for improved performance) [redis] enabled = true ; MQTT Used with emoncms_mqtt service to send and receive data over MQTT [mqtt] enabled = false user = 'username' password = 'password' ; Feed engine settings [feed] ; 5:phpfina and 2:phptimeseries are the recommended emoncms feed engines ; its possible to hide unused engines e.g: 0:mysql, 6:phpfiwa & 10:cassandra engines_hidden = [0,6,10] ; Buffer data to be written to redisbuffer[enabled] = false phpfina[datadir] = '/var/opt/emoncms/phpfina/' phptimeseries[datadir] = '/var/opt/emoncms/phptimeseries/' ; Enable the graph module if you have it installed [interface] feedviewpath = "graph/"
This development is backwards compatible, the old settings file and format still works, it is parsed into the new format if detected.
As this is a big change, it would be great to have help testing this while it is in the master branch before we merge it into stable. I’ve tested it quite a bit here myself and it all looks fine, but I will usually miss something.
If you have an emonSD system running the emoncms master branch, run emonpi/emonbase update to pull in the latest changes. Emoncms will parse the old settings file at this point - and should work fine with no apparent change.
Copy the default emonSD settings.ini example from here: https://github.com/openenergymonitor/emonpi/blob/master/defaults/emoncms/emonpi.settings.ini place in /var/www/emoncms and rename to settings.ini - check to ensure everything keeps working as expected.
Try restarting the emoncms_mqtt and feedwriter services e.g:
sudo systemctl restart emoncms_mqtt
sudo systemctl restart feedwriter
The only part I have not tested is the environment variables side of things used by some for docker installations. There is an example env settings file here: https://github.com/emoncms/emoncms/blob/master/settings.env.ini, rename to settings.ini in order to use this approach.