mirror of
https://github.com/Koenkk/zigbee2mqtt.git
synced 2026-07-14 23:58:50 +00:00
Make panID configurable. #34
This commit is contained in:
@@ -18,3 +18,8 @@ mqtt:
|
||||
serial:
|
||||
# Location of CC2531 USB sniffer
|
||||
port: /dev/ttyACM0
|
||||
|
||||
# Advanced configuration
|
||||
advanced:
|
||||
version: 1
|
||||
pan_id: 0x1a62
|
||||
|
||||
+20
-2
@@ -2,9 +2,28 @@ const YAWN = require('yawn-yaml/cjs');
|
||||
const fs = require('fs');
|
||||
const data = require('./data');
|
||||
const file = data.joinPath('configuration.yaml');
|
||||
const logger = require('./logger');
|
||||
|
||||
let yawn = read();
|
||||
|
||||
// Migrate configuration.
|
||||
if (!yawn.json.advanced) {
|
||||
// 1: Add advanced section to configuration.yaml
|
||||
logger.info("Migrating configuration.yaml to version 1...");
|
||||
yawn.yaml += "\n\n" +
|
||||
"# Advanced configuration\n" +
|
||||
"advanced:\n" +
|
||||
" version: 1\n" +
|
||||
" pan_id: 0x1a62\n";
|
||||
|
||||
write_read();
|
||||
}
|
||||
|
||||
function write_read() {
|
||||
write();
|
||||
yawn = read();
|
||||
}
|
||||
|
||||
function write() {
|
||||
fs.writeFileSync(file, yawn.yaml);
|
||||
}
|
||||
@@ -32,8 +51,7 @@ function addDevice(id) {
|
||||
yawn.json = {...yawn.json, devices: devices};
|
||||
}
|
||||
|
||||
write();
|
||||
yawn = read();
|
||||
write_read();
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ const deviceMapping = require('./devices');
|
||||
const data = require('./util/data');
|
||||
|
||||
const shepherdSettings = {
|
||||
net: {panId: 0x1a62},
|
||||
net: {panId: settings.get().advanced.pan_id},
|
||||
dbPath: data.joinPath('database.db')
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user