Skip to content

Commit

Permalink
Add home assistant MQTT discovery for missing devices. #9
Browse files Browse the repository at this point in the history
  • Loading branch information
Koenkk committed Apr 21, 2018
1 parent f584b5d commit 8109bf6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
3 changes: 3 additions & 0 deletions lib/devices.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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',
Expand Down Expand Up @@ -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',
Expand Down
25 changes: 11 additions & 14 deletions support/docgen.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

0 comments on commit 8109bf6

Please sign in to comment.