Open TrystanLea opened 5 years ago
Interfacers concept screen:
Nodes concept screen:
nodes configuration with node inputs properties arranged horizontally:
Initial implementation: https://github.com/emoncms/config/tree/editor
Python loader:
import json
from configobj import ConfigObj
import redis
import time
r = redis.Redis(host="localhost",port=6379,db=0)
# 1. Load config object
# settings is more than a dict of the contents, it is an instance of the configobj class
settings = ConfigObj("emonhub.conf", file_error=True)
# 2. Translate configuration into json object and reload back to python dict
jsonstr = json.dumps(settings)
r.set("get:emonhubconf",jsonstr)
while 1:
result = r.get("set:emonhubconf")
if result:
r.delete("set:emonhubconf");
jsonsettings = json.loads(result)
# 4. Merge dict with original configobj class
settings.merge(jsonsettings)
# 5. Save to conf file
settings.write()
# 6. Resave to redis
jsonstr = json.dumps(settings)
r.set("get:emonhubconf",jsonstr)
print "config set"
time.sleep(1)
Python code above included in emonhub development branch:
https://github.com/openenergymonitor/emonhub/compare/redis_config_interface
Latest included remote emoncms config interface:
At the moment the emonhub.conf configuration editor is a simple text file editor:
It would be really nice to have a web ui version of the editor to make configuration easier to edit.
The configuration format used is python ConfigObj. There is no php parser of the configobj format. Eemoncms could load the config file via a socket request, MQTT or redis key made available by emonhub.
The configuration would be shared as a JSON object and changes transposed back into the original confobj object in emonhub when edits are made.
Basic example of reading from ConfigObj file, changing the apikey and writing the change back to the original file:
If the settings are transfered to emoncms as a json object, the json changes need to be merged with the original settings in the configobj class, preserving orignal comments, ordering, spacing and indentation: