From 8109bf68e7fbb3ede09474545ac46ae2433ccde9 Mon Sep 17 00:00:00 2001 From: Koen Kanters Date: Sat, 21 Apr 2018 23:05:53 +0200 Subject: [PATCH] Add home assistant MQTT discovery for missing devices. #9 --- lib/devices.js | 3 +++ support/docgen.js | 25 +++++++++++-------------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/devices.js b/lib/devices.js index 12a4cde918..21c525fe21 100644 --- a/lib/devices.js +++ b/lib/devices.js @@ -99,6 +99,7 @@ const devices = { vendor: 'Xiaomi', description: 'MiJia wireless switch', supports: 'single, double, triple, quadruple, many and long click', + homeassistant: [homeassistant.sensor_button] }, 'lumi.sensor_switch.aq2': { model: 'WXKG11LM', @@ -119,6 +120,7 @@ const devices = { vendor: 'Xiaomi', description: 'MiJia temperature & humidity sensor ', supports: 'temperature and humidity', + homeassistant: [homeassistant.sensor_temperature, homeassistant.sensor_humidity] }, 'lumi.weather': { model: 'WSDCGQ11LM', @@ -146,6 +148,7 @@ const devices = { vendor: 'Xiaomi', description: 'MiJia door & window contact sensor', supports: 'open and closed state', + homeassistant: [homeassistant.binary_sensor_state] }, 'lumi.sensor_magnet.aq2': { model: 'MCCGQ11LM', diff --git a/support/docgen.js b/support/docgen.js index e17dd39ad3..bc350d479d 100644 --- a/support/docgen.js +++ b/support/docgen.js @@ -166,20 +166,17 @@ const homeassistantConfig = (device) => { } Object.values(deviceMapping).forEach((device) => { - if (device.homeassistant) { - //console.log(device); - text += `### ${device.model}\n`; - text += '```yaml\n' - - device.homeassistant.forEach((d, i) => { - text += homeassistantConfig(d); - if (device.homeassistant.length > 1 && i < device.homeassistant.length - 1) { - text += '\n'; - } - }) - - text += '```\n\n'; - } + text += `### ${device.model}\n`; + text += '```yaml\n' + + device.homeassistant.forEach((d, i) => { + text += homeassistantConfig(d); + if (device.homeassistant.length > 1 && i < device.homeassistant.length - 1) { + text += '\n'; + } + }) + + text += '```\n\n'; }); fs.writeFileSync(outputdir + '/' + file, text);