Validate settings on startup with JSON schema.

This commit is contained in:
Koen Kanters
2019-09-25 12:08:39 +02:00
parent 34111159ae
commit cfefaeb73c
8 changed files with 203 additions and 43 deletions
+13 -1
View File
@@ -70,6 +70,18 @@ class Controller {
}
async start() {
const settingsErrors = settings.validate();
if (settingsErrors) {
logger.error(`Refusing to start, configuration.yaml is not valid, found the following errors:`);
for (const error of settingsErrors) {
logger.error(`\t - ${error}`);
}
logger.error(
`If you don't know how to solve this, read https://www.zigbee2mqtt.io/configuration/configuration.html`
);
process.exit(1);
}
logger.info(`Logging to directory: '${logger.directory}'`);
logger.cleanup();
this.state.start();
@@ -242,7 +254,7 @@ class Controller {
}
const options = {
retain: entity.settings.hasOwnProperty('retain') ? entity.settings.retain : false,
retain: entity.settings.retain,
qos: entity.settings.hasOwnProperty('qos') ? entity.settings.qos : 0,
};