zigbee2mqtt/lib/util/settings.js

25 lines
479 B
JavaScript
Raw Normal View History

2018-04-18 09:25:40 -07:00
const yamlConfig = require('yaml-config');
const file = `${__dirname}/../../data/configuration.yaml`;
let settings = read();
// Create empty device array if not set yet.
if (!settings.devices) {
settings.devices = {};
write();
}
function write() {
yamlConfig.updateConfig(settings, file, 'user');
settings = read();
}
function read() {
return yamlConfig.readConfig(file, 'user');
}
module.exports = {
get: () => settings,
2018-04-18 11:53:22 -07:00
write: () => write(),
2018-04-18 09:25:40 -07:00
}