Page 1 of 1

config.json, loadObject, etc. We Really Need Better Docs!

Posted: 31 Dec 2015 04:00
by markolbert
In my effort to try and decipher how z-way-server is put together I came across this line from the docs:
The automation folder consists of several files and subdirectories. The most important file
of the automation is called config.json. This file contains the information about all automation
modules and their instances. This file is automatically generated and should be changed without
proper knowledge.
So I figured I'd check out config.json and see if, I don't know, maybe it contained information on what modules to load (I'm trying to create a module which will bind to various devices and raise events whenever a light turns on or off).

Only there is no config.json file that I can find, anywhere in the system. I say this because I tried:

Code: Select all

sudo find / -name "config.json"
and it couldn't find the file. Pretty weird for a file that's that critical :).

I then took a look at main.js. It contains this:

Code: Select all

config = loadObject("config.json") 
so clearly an attempt is made to load config.json. But how does loadObject work?

That's hard to tell, too. Because I could not find any definition of loadObject in my system, either. And a google search didn't turn up anything that looked promising.

I really hope the developers get around to writing some better docs, with examples, one of these days. It'd be sad for the z-way project to disappear because no one can extend it or utilize it.

Re: config.json, loadObject, etc. We Really Need Better Docs

Posted: 31 Dec 2015 12:00
by pz1
You are absolutely right in your conclusins.

config.json is their shorthand for:

Code: Select all

/opt/z-wa-server/automation/storage.configjson-06b2d3b23dce96e1619d2b53d6c947ec.json
The alfa-numeric part may be different for you. Why it needs to be there I don't know.

Re: config.json, loadObject, etc. We Really Need Better Docs

Posted: 07 Jan 2016 04:36
by PoltoS
Alphanumeric is same for you. It is MD5 of the name and is needed since object name in JS can have almost any character, while filesystem can't. So, we strip all unwanted chars, but to avoid colision of two similar names we add MD% from the original. Like to avoid config-json and config.json and config/json to become same configjson.

As for the doc, totally agree with you! This comes from old times where the file was indeed config.json.