2018-04-11 11:54:22 -07:00
|
|
|
/**
|
|
|
|
* This script generates the supported devices page.
|
|
|
|
* Run by executing: npm run docs
|
|
|
|
*/
|
|
|
|
|
2018-04-13 10:00:17 -07:00
|
|
|
const plannedToSupport = [
|
|
|
|
{
|
|
|
|
model: 'SJCGQ11LM',
|
|
|
|
description: 'Aqara water leak sensor',
|
|
|
|
supports: '-',
|
2018-04-18 09:25:40 -07:00
|
|
|
vendor: 'Xiaomi',
|
2018-04-13 10:00:17 -07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
model: 'MFKZQ01LM',
|
|
|
|
description: 'Mi magic cube controller',
|
|
|
|
supports: '-',
|
2018-04-18 09:25:40 -07:00
|
|
|
vendor: 'Xiaomi',
|
2018-04-13 10:00:17 -07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
model: 'WXKG03LM',
|
|
|
|
description: 'Aqara single key wireless wall switch',
|
|
|
|
supports: '-',
|
2018-04-18 09:25:40 -07:00
|
|
|
vendor: 'Xiaomi',
|
2018-04-13 10:00:17 -07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
model: 'QBKG11LM',
|
|
|
|
description: 'Aqara single key wired wall switch',
|
|
|
|
supports: '-',
|
2018-04-18 09:25:40 -07:00
|
|
|
vendor: 'Xiaomi',
|
2018-04-13 10:00:17 -07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
model: 'QBKG03LM',
|
|
|
|
description: 'Aqara double key wired wall switch',
|
|
|
|
supports: '-',
|
2018-04-18 09:25:40 -07:00
|
|
|
vendor: 'Xiaomi',
|
2018-04-13 10:00:17 -07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
model: 'ZNCZ02LM',
|
|
|
|
description: 'Mi power plug ZigBee',
|
|
|
|
supports: '-',
|
2018-04-18 09:25:40 -07:00
|
|
|
vendor: 'Xiaomi',
|
2018-04-13 10:00:17 -07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
model: 'QBCZ11LM',
|
|
|
|
description: 'Aqara wall socket',
|
|
|
|
supports: '-',
|
2018-04-18 09:25:40 -07:00
|
|
|
vendor: 'Xiaomi',
|
2018-04-13 10:00:17 -07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
model: 'JTYJ-GD-01LM/BW',
|
|
|
|
description: 'MiJia Honeywell smoke detector',
|
|
|
|
supports: '-',
|
2018-04-18 09:25:40 -07:00
|
|
|
vendor: 'Xiaomi',
|
2018-04-13 10:00:17 -07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
model: 'KTBL01LM',
|
|
|
|
description: 'Aqara air conditioning companion',
|
|
|
|
supports: '-',
|
2018-04-18 09:25:40 -07:00
|
|
|
vendor: 'Xiaomi',
|
2018-04-13 10:00:17 -07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
model: 'KTBL02LM',
|
|
|
|
description: 'Aqara air conditioning companion 2',
|
|
|
|
supports: '-',
|
2018-04-18 09:25:40 -07:00
|
|
|
vendor: 'Xiaomi',
|
2018-04-13 10:00:17 -07:00
|
|
|
},
|
|
|
|
];
|
|
|
|
|
2018-04-18 09:25:40 -07:00
|
|
|
const zigbee2mqtt = require('../lib/converters/zigbee2mqtt');
|
|
|
|
const deviceMapping = require('../lib/devices');
|
2018-04-21 10:19:51 -07:00
|
|
|
const fs = require('fs');
|
2018-04-11 11:54:22 -07:00
|
|
|
|
|
|
|
// Sanity check if all supported devices are in deviceMapping
|
|
|
|
const supportedDevices = new Set();
|
2018-04-18 09:25:40 -07:00
|
|
|
zigbee2mqtt.forEach((p) => supportedDevices.add(...p.devices));
|
2018-04-11 11:54:22 -07:00
|
|
|
|
|
|
|
// Check if in deviceMapping.
|
|
|
|
supportedDevices.forEach((s) => {
|
|
|
|
if (!Object.values(deviceMapping).find((d) => d.model === s)) {
|
|
|
|
console.log(`ERROR: ${s} not in deviceMapping`);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-04-21 10:19:51 -07:00
|
|
|
const outputdir = process.argv[2];
|
|
|
|
|
|
|
|
if (!outputdir) {
|
|
|
|
console.error("Please specify an output directory");
|
|
|
|
}
|
|
|
|
|
|
|
|
let file = 'Supported-devices.md';
|
|
|
|
let text = '*NOTE: Automatically generated by `npm run docgen`*\n';
|
|
|
|
text += `
|
|
|
|
In case your device is **NOT** listed here, please create an issue at: https://github.com/Koenkk/zigbee2mqtt/issues
|
|
|
|
\n`;
|
|
|
|
|
2018-04-13 10:00:17 -07:00
|
|
|
const logDevices = (devices) => {
|
2018-04-21 10:19:51 -07:00
|
|
|
let result = '';
|
|
|
|
result += '| Model | Description | Picture |\n';
|
|
|
|
result += '| ------------- | ------------- | -------------------------- |\n';
|
|
|
|
|
2018-04-13 10:00:17 -07:00
|
|
|
devices.forEach((device) => {
|
2018-04-21 10:19:51 -07:00
|
|
|
result += `| ${device.model} | ${device.vendor} ${device.description} (${device.supports}) | ![${device.model}](images/devices/${device.model.replace('/', '-')}.jpg) |\n`;
|
2018-04-13 10:00:17 -07:00
|
|
|
});
|
2018-04-21 10:19:51 -07:00
|
|
|
|
|
|
|
return result;
|
2018-04-13 10:00:17 -07:00
|
|
|
}
|
|
|
|
|
2018-04-18 13:27:44 -07:00
|
|
|
const vendors = Array.from(new Set(Object.values(deviceMapping).map((d) => d.vendor)));
|
|
|
|
vendors.sort();
|
|
|
|
vendors.forEach((vendor) => {
|
2018-04-21 10:19:51 -07:00
|
|
|
text += `### ${vendor}\n`;
|
|
|
|
text += logDevices(Object.values(deviceMapping).filter((d) => d.vendor === vendor));
|
|
|
|
text += '\n';
|
2018-04-18 13:27:44 -07:00
|
|
|
})
|
2018-04-21 10:19:51 -07:00
|
|
|
|
|
|
|
fs.writeFileSync(outputdir + '/' + file, text);
|