mirror of
https://github.com/Koenkk/zigbee2mqtt.git
synced 2026-10-22 05:52:20 +00:00
Refactor homeassistant configuration out of devices.js. #45
This commit is contained in:
1 parent
ca40cf622a
commit
8559ea2301
7 files changed
+56
-39
No files matched your search
+4
-2
@@ -7,6 +7,7 @@ const zigbee2mqtt = require('../lib/converters/zigbee2mqtt');
|
||||
const deviceMapping = require('../lib/devices');
|
||||
const fs = require('fs');
|
||||
const YAML = require('json2yaml');
|
||||
const homeassistant = require('../lib/homeassistant');
|
||||
|
||||
// Sanity check if all supported devices are in deviceMapping
|
||||
const supportedDevices = new Set();
|
||||
@@ -106,9 +107,10 @@ Object.values(deviceMapping).forEach((device) => {
|
||||
text += `### ${device.model}\n`;
|
||||
text += '```yaml\n'
|
||||
|
||||
device.homeassistant.forEach((d, i) => {
|
||||
const configurations = homeassistant.mapping[device.model]
|
||||
configurations.forEach((d, i) => {
|
||||
text += homeassistantConfig(d);
|
||||
if (device.homeassistant.length > 1 && i < device.homeassistant.length - 1) {
|
||||
if (configurations.length > 1 && i < configurations.length - 1) {
|
||||
text += '\n';
|
||||
}
|
||||
})
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
// Verify that there are homeassistant mappings for every device.
|
||||
const devices = require('../lib/devices');
|
||||
const homeassistant = require('../lib/homeassistant');
|
||||
|
||||
let failed = false;
|
||||
Object.values(devices).forEach((d) => {
|
||||
if (!homeassistant.mapping[d.model]) {
|
||||
console.error(`Missing homeassistant mapping for '${d.model}'`);
|
||||
failed = true;
|
||||
}
|
||||
});
|
||||
|
||||
process.exit(failed ? 1 : 0);
|
||||
Reference in new issue
Block a user