Move converters to devices.js. #45

This commit is contained in:
Koenkk 2018-05-23 17:55:30 +02:00
parent bc4dff65ff
commit 3fdfc6f57f
4 changed files with 83 additions and 109 deletions

View File

@ -3,7 +3,6 @@ const Zigbee = require('./zigbee');
const logger = require('./util/logger'); const logger = require('./util/logger');
const settings = require('./util/settings'); const settings = require('./util/settings');
const deviceMapping = require('./devices'); const deviceMapping = require('./devices');
const zigbee2mqtt = require('./converters/zigbee2mqtt');
const mqtt2zigbee = require('./converters/mqtt2zigbee'); const mqtt2zigbee = require('./converters/mqtt2zigbee');
const homeassistant = require('./homeassistant'); const homeassistant = require('./homeassistant');
const debug = require('debug')('zigbee2mqtt:controller'); const debug = require('debug')('zigbee2mqtt:controller');
@ -217,9 +216,7 @@ class Controller {
// Find a conveter for this message. // Find a conveter for this message.
const cid = message.data.cid; const cid = message.data.cid;
const converters = zigbee2mqtt.filter((c) => const converters = mappedModel.fromZigbee.filter((c) => c.cid === cid && c.type === message.type);
c.devices.includes(mappedModel.model) && c.cid === cid && c.type === message.type
);
if (!converters.length) { if (!converters.length) {
logger.warn( logger.warn(

View File

@ -43,12 +43,8 @@ const precisionRound = (number, precision) => {
// Global variable store that can be used by devices. // Global variable store that can be used by devices.
const store = {}; const store = {};
const parsers = [ const parsers = {
{ xiaomi_battery_3v: {
devices: [
'WXKG01LM', 'RTCGQ01LM', 'WSDCGQ01LM', 'MCCGQ01LM', 'WXKG11LM', 'MCCGQ11LM', 'RTCGQ11LM', 'WSDCGQ11LM',
'SJCGQ11LM', 'MFKZQ01LM', 'JTYJ-GD-01LM/BW', 'WXKG02LM', 'WXKG03LM',
],
cid: 'genBasic', cid: 'genBasic',
type: 'attReport', type: 'attReport',
convert: (msg) => { convert: (msg) => {
@ -65,8 +61,7 @@ const parsers = [
} }
}, },
}, },
{ WXKG01LM_click: {
devices: ['WXKG01LM'],
cid: 'genOnOff', cid: 'genOnOff',
type: 'attReport', type: 'attReport',
convert: (msg, publish) => { convert: (msg, publish) => {
@ -92,16 +87,14 @@ const parsers = [
} }
}, },
}, },
{ xiaomi_temperature: {
devices: ['WSDCGQ01LM', 'WSDCGQ11LM'],
cid: 'msTemperatureMeasurement', cid: 'msTemperatureMeasurement',
type: 'attReport', type: 'attReport',
convert: (msg) => { convert: (msg) => {
return {temperature: parseFloat(msg.data.data['measuredValue']) / 100.0}; return {temperature: parseFloat(msg.data.data['measuredValue']) / 100.0};
}, },
}, },
{ MFKZQ01LM_action_multistate: {
devices: ['MFKZQ01LM'],
cid: 'genMultistateInput', cid: 'genMultistateInput',
type: 'attReport', type: 'attReport',
convert: (msg) => { convert: (msg) => {
@ -139,8 +132,7 @@ const parsers = [
return action ? {'action': action} : null; return action ? {'action': action} : null;
}, },
}, },
{ MFKZQ01LM_action_analog: {
devices: ['MFKZQ01LM'],
cid: 'genAnalogInput', cid: 'genAnalogInput',
type: 'attReport', type: 'attReport',
convert: (msg) => { convert: (msg) => {
@ -152,16 +144,14 @@ const parsers = [
return {action: value < 0 ? 'rotate_left' : 'rotate_right'}; return {action: value < 0 ? 'rotate_left' : 'rotate_right'};
}, },
}, },
{ xiaomi_humidity: {
devices: ['WSDCGQ01LM', 'WSDCGQ11LM'],
cid: 'msRelativeHumidity', cid: 'msRelativeHumidity',
type: 'attReport', type: 'attReport',
convert: (msg) => { convert: (msg) => {
return {humidity: parseFloat(msg.data.data['measuredValue']) / 100.0}; return {humidity: parseFloat(msg.data.data['measuredValue']) / 100.0};
}, },
}, },
{ xiaomi_occupancy: {
devices: ['RTCGQ01LM', 'RTCGQ11LM'],
cid: 'msOccupancySensing', cid: 'msOccupancySensing',
type: 'attReport', type: 'attReport',
convert: (msg, publish, options) => { convert: (msg, publish, options) => {
@ -183,27 +173,21 @@ const parsers = [
return {occupancy: true}; return {occupancy: true};
}, },
}, },
{ xiaomi_contact: {
devices: ['MCCGQ01LM', 'MCCGQ11LM'],
cid: 'genOnOff', cid: 'genOnOff',
type: 'attReport', type: 'attReport',
convert: (msg) => { convert: (msg) => {
return {contact: msg.data.data['onOff'] === 0}; return {contact: msg.data.data['onOff'] === 0};
}, },
}, },
{ light_brightness: {
devices: [
'LED1545G12', '7146060PH', 'LED1537R6', 'LED1623G12', 'LED1650R5', 'LED1536G5', 'F7C033',
'LED1622G12',
],
cid: 'genLevelCtrl', cid: 'genLevelCtrl',
type: 'devChange', type: 'devChange',
convert: (msg) => { convert: (msg) => {
return {brightness: msg.data.data['currentLevel']}; return {brightness: msg.data.data['currentLevel']};
}, },
}, },
{ light_color_colortemp: {
devices: ['LED1545G12', '7146060PH', 'LED1537R6', 'LED1536G5'],
cid: 'lightingColorCtrl', cid: 'lightingColorCtrl',
type: 'devChange', type: 'devChange',
convert: (msg) => { convert: (msg) => {
@ -223,8 +207,7 @@ const parsers = [
return result; return result;
}, },
}, },
{ WXKG11LM_click: {
devices: ['WXKG11LM'],
cid: 'genOnOff', cid: 'genOnOff',
type: 'attReport', type: 'attReport',
convert: (msg) => { convert: (msg) => {
@ -242,72 +225,63 @@ const parsers = [
} }
}, },
}, },
{ xiaomi_illuminance: {
devices: ['RTCGQ11LM'],
cid: 'msIlluminanceMeasurement', cid: 'msIlluminanceMeasurement',
type: 'attReport', type: 'attReport',
convert: (msg) => { convert: (msg) => {
return {illuminance: msg.data.data['measuredValue']}; return {illuminance: msg.data.data['measuredValue']};
}, },
}, },
{ xiaomi_pressure: {
devices: ['WSDCGQ11LM'],
cid: 'msPressureMeasurement', cid: 'msPressureMeasurement',
type: 'attReport', type: 'attReport',
convert: (msg) => { convert: (msg) => {
return {pressure: msg.data.data['measuredValue']}; return {pressure: msg.data.data['measuredValue']};
}, },
}, },
{ WXKG02LM_click: {
devices: ['WXKG02LM'],
cid: 'genOnOff', cid: 'genOnOff',
type: 'attReport', type: 'attReport',
convert: (msg) => { convert: (msg) => {
return {click: WXKG02LM[msg.endpoints[0].epId]}; return {click: WXKG02LM[msg.endpoints[0].epId]};
}, },
}, },
{ WXKG03LM_click: {
devices: ['WXKG03LM'],
cid: 'genOnOff', cid: 'genOnOff',
type: 'attReport', type: 'attReport',
convert: () => { convert: () => {
return {click: 'single'}; return {click: 'single'};
}, },
}, },
{ SJCGQ11LM_water_leak_basic: {
devices: ['SJCGQ11LM'],
cid: 'genBasic', cid: 'genBasic',
type: 'attReport', type: 'attReport',
convert: (msg) => { convert: (msg) => {
return {water_leak: msg.data.data['65281']['100'] === 1}; return {water_leak: msg.data.data['65281']['100'] === 1};
}, },
}, },
{ SJCGQ11LM_water_leak_iaszone: {
devices: ['SJCGQ11LM'],
cid: 'ssIasZone', cid: 'ssIasZone',
type: 'statusChange', type: 'statusChange',
convert: (msg) => { convert: (msg) => {
return {water_leak: msg.data.zoneStatus === 1}; return {water_leak: msg.data.zoneStatus === 1};
}, },
}, },
{ xiaomi_state: {
devices: ['ZNCZ02LM', 'QBCZ11LM'],
cid: 'genOnOff', cid: 'genOnOff',
type: 'attReport', type: 'attReport',
convert: (msg) => { convert: (msg) => {
return {state: msg.data.data['onOff'] === 1 ? 'ON' : 'OFF'}; return {state: msg.data.data['onOff'] === 1 ? 'ON' : 'OFF'};
}, },
}, },
{ xiaomi_power: {
devices: ['ZNCZ02LM', 'QBCZ11LM'],
cid: 'genAnalogInput', cid: 'genAnalogInput',
type: 'attReport', type: 'attReport',
convert: (msg) => { convert: (msg) => {
return {power: precisionRound(msg.data.data['presentValue'], 2)}; return {power: precisionRound(msg.data.data['presentValue'], 2)};
}, },
}, },
{ ZNCZ02LM_state: {
devices: ['ZNCZ02LM'],
cid: 'genBasic', cid: 'genBasic',
type: 'attReport', type: 'attReport',
convert: (msg) => { convert: (msg) => {
@ -323,8 +297,7 @@ const parsers = [
} }
}, },
}, },
{ QBKG04LM_state: {
devices: ['QBKG04LM'],
cid: 'genOnOff', cid: 'genOnOff',
type: 'attReport', type: 'attReport',
convert: (msg) => { convert: (msg) => {
@ -333,8 +306,7 @@ const parsers = [
} }
}, },
}, },
{ QBKG03LM_state: {
devices: ['QBKG03LM'],
cid: 'genOnOff', cid: 'genOnOff',
type: 'attReport', type: 'attReport',
convert: (msg) => { convert: (msg) => {
@ -346,32 +318,28 @@ const parsers = [
} }
}, },
}, },
{ JTYJGD01LMBW_smoke: {
devices: ['JTYJ-GD-01LM/BW'],
cid: 'ssIasZone', cid: 'ssIasZone',
type: 'statusChange', type: 'statusChange',
convert: (msg) => { convert: (msg) => {
return {smoke: msg.data.zoneStatus === 1}; return {smoke: msg.data.zoneStatus === 1};
}, },
}, },
{ EDP_power: {
devices: ['PLUG EDP RE:DY'],
cid: 'seMetering', cid: 'seMetering',
type: 'attReport', type: 'attReport',
convert: (msg) => { convert: (msg) => {
return {power: precisionRound(msg.data.data['instantaneousDemand'], 2)}; return {power: precisionRound(msg.data.data['instantaneousDemand'], 2)};
}, },
}, },
{ CC2530ROUTER_state: {
devices: ['CC2530.ROUTER'],
cid: 'genOnOff', cid: 'genOnOff',
type: 'attReport', type: 'attReport',
convert: (msg) => { convert: (msg) => {
return {state: msg.data.data['onOff'] === 1}; return {state: msg.data.data['onOff'] === 1};
}, },
}, },
{ CC2530ROUTER_meta: {
devices: ['CC2530.ROUTER'],
cid: 'genBinaryValue', cid: 'genBinaryValue',
type: 'attReport', type: 'attReport',
convert: (msg) => { convert: (msg) => {
@ -385,79 +353,56 @@ const parsers = [
}, },
// Ignore parsers (these message dont need parsing). // Ignore parsers (these message dont need parsing).
{ ignore_onoff_change: {
devices: [
'WXKG11LM', 'MCCGQ11LM', 'MCCGQ01LM', 'WXKG01LM', 'LED1545G12', '7146060PH', 'LED1537R6', 'ZNCZ02LM',
'QBCZ11LM', 'QBKG04LM', 'QBKG03LM', 'LED1623G12', 'LED1650R5', 'LED1536G5', 'F7C033', 'LED1622G12',
'PLUG EDP RE:DY',
],
cid: 'genOnOff', cid: 'genOnOff',
type: 'devChange', type: 'devChange',
convert: () => null, convert: () => null,
}, },
{ ignore_basic_change: {
devices: [
'WXKG11LM', 'MCCGQ11LM', 'RTCGQ11LM', 'WSDCGQ11LM', 'SJCGQ11LM', 'MCCGQ01LM', 'RTCGQ01LM', 'WXKG01LM',
'WSDCGQ01LM', 'JTYJ-GD-01LM/BW', 'ZNCZ02LM',
],
cid: 'genBasic', cid: 'genBasic',
type: 'devChange', type: 'devChange',
convert: () => null, convert: () => null,
}, },
{ ignore_illuminance_change: {
devices: ['RTCGQ11LM'],
cid: 'msIlluminanceMeasurement', cid: 'msIlluminanceMeasurement',
type: 'devChange', type: 'devChange',
convert: () => null, convert: () => null,
}, },
{ ignore_occupancy_change: {
devices: ['RTCGQ11LM'],
cid: 'msOccupancySensing', cid: 'msOccupancySensing',
type: 'devChange', type: 'devChange',
convert: () => null, convert: () => null,
}, },
{ ignore_temperature_change: {
devices: ['WSDCGQ11LM'],
cid: 'msTemperatureMeasurement', cid: 'msTemperatureMeasurement',
type: 'devChange', type: 'devChange',
convert: () => null, convert: () => null,
}, },
{ ignore_humidity_change: {
devices: ['WSDCGQ11LM'],
cid: 'msRelativeHumidity', cid: 'msRelativeHumidity',
type: 'devChange', type: 'devChange',
convert: () => null, convert: () => null,
}, },
{ ignore_pressure_change: {
devices: ['WSDCGQ11LM'],
cid: 'msPressureMeasurement', cid: 'msPressureMeasurement',
type: 'devChange', type: 'devChange',
convert: () => null, convert: () => null,
}, },
{ ignore_analog_change: {
devices: ['ZNCZ02LM', 'QBCZ11LM'],
cid: 'genAnalogInput', cid: 'genAnalogInput',
type: 'devChange', type: 'devChange',
convert: () => null, convert: () => null,
}, },
{ ignore_multistate_change: {
devices: ['MFKZQ01LM'],
cid: 'genMultistateInput', cid: 'genMultistateInput',
type: 'devChange', type: 'devChange',
convert: () => null, convert: () => null,
}, },
{ ignore_metering_change: {
devices: ['MFKZQ01LM'],
cid: 'genAnalogInput',
type: 'devChange',
convert: () => null,
},
{
devices: ['PLUG EDP RE:DY'],
cid: 'seMetering', cid: 'seMetering',
type: 'devChange', type: 'devChange',
convert: () => null, convert: () => null,
}, },
]; };
module.exports = parsers; module.exports = parsers;

View File

@ -1,8 +1,11 @@
const fz = require('./converters/fromZigbee');
const LED1623G12 = { const LED1623G12 = {
model: 'LED1623G12', model: 'LED1623G12',
vendor: 'IKEA', vendor: 'IKEA',
description: 'TRADFRI LED bulb E27 1000 lumen, dimmable, opal white', description: 'TRADFRI LED bulb E27 1000 lumen, dimmable, opal white',
supports: 'on/off, brightness', supports: 'on/off, brightness',
fromZigbee: [fz.light_brightness, fz.ignore_onoff_change],
}; };
const LED1536G5 = { const LED1536G5 = {
@ -10,6 +13,7 @@ const LED1536G5 = {
vendor: 'IKEA', vendor: 'IKEA',
description: 'TRADFRI LED bulb E12/E14 400 lumen, dimmable, white spectrum, opal white', description: 'TRADFRI LED bulb E12/E14 400 lumen, dimmable, white spectrum, opal white',
supports: 'on/off, brightness, color temperature', supports: 'on/off, brightness, color temperature',
fromZigbee: [fz.light_brightness, fz.light_color_colortemp, fz.ignore_onoff_change],
}; };
const devices = { const devices = {
@ -19,30 +23,35 @@ const devices = {
vendor: 'Xiaomi', vendor: 'Xiaomi',
description: 'MiJia wireless switch', description: 'MiJia wireless switch',
supports: 'single, double, triple, quadruple, many and long click', supports: 'single, double, triple, quadruple, many and long click',
fromZigbee: [fz.xiaomi_battery_3v, fz.WXKG01LM_click, fz.ignore_onoff_change, fz.ignore_basic_change],
}, },
'lumi.sensor_switch.aq2': { 'lumi.sensor_switch.aq2': {
model: 'WXKG11LM', model: 'WXKG11LM',
vendor: 'Xiaomi', vendor: 'Xiaomi',
description: 'Aqara wireless switch', description: 'Aqara wireless switch',
supports: 'single, double, triple, quadruple click', supports: 'single, double, triple, quadruple click',
fromZigbee: [fz.xiaomi_battery_3v, fz.WXKG11LM_click, fz.ignore_onoff_change, fz.ignore_basic_change],
}, },
'lumi.sensor_86sw1\u0000lu': { 'lumi.sensor_86sw1\u0000lu': {
model: 'WXKG03LM', model: 'WXKG03LM',
vendor: 'Xiaomi', vendor: 'Xiaomi',
description: 'Aqara single key wireless wall switch', description: 'Aqara single key wireless wall switch',
supports: 'single click', supports: 'single click',
fromZigbee: [fz.xiaomi_battery_3v, fz.WXKG03LM_click],
}, },
'lumi.sensor_86sw2\u0000Un': { 'lumi.sensor_86sw2\u0000Un': {
model: 'WXKG02LM', model: 'WXKG02LM',
vendor: 'Xiaomi', vendor: 'Xiaomi',
description: 'Aqara double key wireless wall switch', description: 'Aqara double key wireless wall switch',
supports: 'left, right and both click', supports: 'left, right and both click',
fromZigbee: [fz.xiaomi_battery_3v, fz.WXKG02LM_click],
}, },
'lumi.ctrl_neutral1': { 'lumi.ctrl_neutral1': {
model: 'QBKG04LM', model: 'QBKG04LM',
vendor: 'Xiaomi', vendor: 'Xiaomi',
description: 'Aqara single key wired wall switch', description: 'Aqara single key wired wall switch',
supports: 'on/off', supports: 'on/off',
fromZigbee: [fz.QBKG04LM_state, fz.ignore_onoff_change],
ep: {'': 2}, ep: {'': 2},
}, },
'lumi.ctrl_neutral2': { 'lumi.ctrl_neutral2': {
@ -50,6 +59,7 @@ const devices = {
vendor: 'Xiaomi', vendor: 'Xiaomi',
description: 'Aqara double key wired wall switch', description: 'Aqara double key wired wall switch',
supports: 'l1 and l2 on/off', supports: 'l1 and l2 on/off',
fromZigbee: [fz.QBKG03LM_state, fz.ignore_onoff_change],
ep: {'l1': 2, 'l2': 3}, ep: {'l1': 2, 'l2': 3},
}, },
'lumi.sens': { 'lumi.sens': {
@ -57,66 +67,92 @@ const devices = {
vendor: 'Xiaomi', vendor: 'Xiaomi',
description: 'MiJia temperature & humidity sensor ', description: 'MiJia temperature & humidity sensor ',
supports: 'temperature and humidity', supports: 'temperature and humidity',
fromZigbee: [fz.xiaomi_battery_3v, fz.xiaomi_temperature, fz.xiaomi_humidity, fz.ignore_basic_change],
}, },
'lumi.weather': { 'lumi.weather': {
model: 'WSDCGQ11LM', model: 'WSDCGQ11LM',
vendor: 'Xiaomi', vendor: 'Xiaomi',
description: 'Aqara temperature, humidity and pressure sensor', description: 'Aqara temperature, humidity and pressure sensor',
supports: 'temperature, humidity and pressure', supports: 'temperature, humidity and pressure',
fromZigbee: [
fz.xiaomi_battery_3v, fz.xiaomi_temperature, fz.xiaomi_humidity, fz.xiaomi_pressure, fz.ignore_basic_change,
fz.ignore_temperature_change, fz.ignore_humidity_change, fz.ignore_pressure_change,
],
}, },
'lumi.sensor_motion': { 'lumi.sensor_motion': {
model: 'RTCGQ01LM', model: 'RTCGQ01LM',
vendor: 'Xiaomi', vendor: 'Xiaomi',
description: 'MiJia human body movement sensor', description: 'MiJia human body movement sensor',
supports: 'occupancy', supports: 'occupancy',
fromZigbee: [fz.xiaomi_battery_3v, fz.xiaomi_occupancy, fz.ignore_basic_change],
}, },
'lumi.sensor_motion.aq2': { 'lumi.sensor_motion.aq2': {
model: 'RTCGQ11LM', model: 'RTCGQ11LM',
vendor: 'Xiaomi', vendor: 'Xiaomi',
description: 'Aqara human body movement and illuminance sensor', description: 'Aqara human body movement and illuminance sensor',
supports: 'occupancy and illuminance', supports: 'occupancy and illuminance',
fromZigbee: [
fz.xiaomi_battery_3v, fz.xiaomi_occupancy, fz.xiaomi_illuminance, fz.ignore_basic_change,
fz.ignore_illuminance_change, fz.ignore_occupancy_change,
],
}, },
'lumi.sensor_magnet': { 'lumi.sensor_magnet': {
model: 'MCCGQ01LM', model: 'MCCGQ01LM',
vendor: 'Xiaomi', vendor: 'Xiaomi',
description: 'MiJia door & window contact sensor', description: 'MiJia door & window contact sensor',
supports: 'contact', supports: 'contact',
fromZigbee: [fz.xiaomi_battery_3v, fz.xiaomi_contact, fz.ignore_onoff_change, fz.ignore_basic_change],
}, },
'lumi.sensor_magnet.aq2': { 'lumi.sensor_magnet.aq2': {
model: 'MCCGQ11LM', model: 'MCCGQ11LM',
vendor: 'Xiaomi', vendor: 'Xiaomi',
description: 'Aqara door & window contact sensor', description: 'Aqara door & window contact sensor',
supports: 'contact', supports: 'contact',
fromZigbee: [fz.xiaomi_battery_3v, fz.xiaomi_contact, fz.ignore_onoff_change, fz.ignore_basic_change],
}, },
'lumi.sensor_wleak.aq1': { 'lumi.sensor_wleak.aq1': {
model: 'SJCGQ11LM', model: 'SJCGQ11LM',
vendor: 'Xiaomi', vendor: 'Xiaomi',
description: 'Aqara water leak sensor', description: 'Aqara water leak sensor',
supports: 'water leak true/false', supports: 'water leak true/false',
fromZigbee: [
fz.xiaomi_battery_3v, fz.SJCGQ11LM_water_leak_basic, fz.SJCGQ11LM_water_leak_iaszone,
fz.ignore_basic_change,
],
}, },
'lumi.sensor_cube': { 'lumi.sensor_cube': {
model: 'MFKZQ01LM', model: 'MFKZQ01LM',
vendor: 'Xiaomi', vendor: 'Xiaomi',
description: 'Mi smart home cube', description: 'Mi smart home cube',
supports: 'shake, wakeup, fall, tap, slide, flip180, flip90, rotate_left and rotate_right', supports: 'shake, wakeup, fall, tap, slide, flip180, flip90, rotate_left and rotate_right',
fromZigbee: [
fz.xiaomi_battery_3v, fz.MFKZQ01LM_action_multistate, fz.MFKZQ01LM_action_analog,
fz.ignore_analog_change, fz.ignore_multistate_change,
],
}, },
'lumi.plug': { 'lumi.plug': {
model: 'ZNCZ02LM', model: 'ZNCZ02LM',
description: 'Mi power plug ZigBee', description: 'Mi power plug ZigBee',
supports: 'on/off, power measurement', supports: 'on/off, power measurement',
vendor: 'Xiaomi', vendor: 'Xiaomi',
fromZigbee: [
fz.xiaomi_state, fz.xiaomi_power, fz.ZNCZ02LM_state, fz.ignore_onoff_change,
fz.ignore_basic_change, fz.ignore_analog_change,
],
}, },
'lumi.ctrl_86plug': { 'lumi.ctrl_86plug': {
model: 'QBCZ11LM', model: 'QBCZ11LM',
description: 'Aqara socket Zigbee', description: 'Aqara socket Zigbee',
supports: 'on/off, power measurement', supports: 'on/off, power measurement',
vendor: 'Xiaomi', vendor: 'Xiaomi',
fromZigbee: [fz.xiaomi_state, fz.xiaomi_power, fz.ignore_onoff_change, fz.ignore_analog_change],
}, },
'lumi.sensor_smoke': { 'lumi.sensor_smoke': {
model: 'JTYJ-GD-01LM/BW', model: 'JTYJ-GD-01LM/BW',
description: 'MiJia Honeywell smoke detector', description: 'MiJia Honeywell smoke detector',
supports: 'smoke', supports: 'smoke',
vendor: 'Xiaomi', vendor: 'Xiaomi',
fromZigbee: [fz.xiaomi_battery_3v, fz.JTYJGD01LMBW_smoke, fz.ignore_basic_change],
}, },
// IKEA // IKEA
@ -125,6 +161,7 @@ const devices = {
vendor: 'IKEA', vendor: 'IKEA',
description: 'TRADFRI LED bulb E27 980 lumen, dimmable, white spectrum, opal white', description: 'TRADFRI LED bulb E27 980 lumen, dimmable, white spectrum, opal white',
supports: 'on/off, brightness, color temperature', supports: 'on/off, brightness, color temperature',
fromZigbee: [fz.light_brightness, fz.light_color_colortemp, fz.ignore_onoff_change],
}, },
// LED1623G12 uses 2 model IDs, see https://github.com/Koenkk/zigbee2mqtt/issues/21 // LED1623G12 uses 2 model IDs, see https://github.com/Koenkk/zigbee2mqtt/issues/21
'TRADFRI bulb E27 opal 1000lm': LED1623G12, 'TRADFRI bulb E27 opal 1000lm': LED1623G12,
@ -134,12 +171,14 @@ const devices = {
vendor: 'IKEA', vendor: 'IKEA',
description: 'TRADFRI LED bulb GU10 400 lumen, dimmable, white spectrum', description: 'TRADFRI LED bulb GU10 400 lumen, dimmable, white spectrum',
supports: 'on/off, brightness, color temperature', supports: 'on/off, brightness, color temperature',
fromZigbee: [fz.light_brightness, fz.light_color_colortemp, fz.ignore_onoff_change],
}, },
'TRADFRI bulb GU10 W 400lm': { 'TRADFRI bulb GU10 W 400lm': {
model: 'LED1650R5', model: 'LED1650R5',
vendor: 'IKEA', vendor: 'IKEA',
description: 'TRADFRI LED bulb GU10 400 lumen, dimmable', description: 'TRADFRI LED bulb GU10 400 lumen, dimmable',
supports: 'on/off, brightness', supports: 'on/off, brightness',
fromZigbee: [fz.light_brightness, fz.ignore_onoff_change],
}, },
// LED1536G5 has an E12 and E14 version. // LED1536G5 has an E12 and E14 version.
'TRADFRI bulb E14 WS opal 400lm': LED1536G5, 'TRADFRI bulb E14 WS opal 400lm': LED1536G5,
@ -149,6 +188,7 @@ const devices = {
vendor: 'IKEA', vendor: 'IKEA',
description: 'TRADFRI LED bulb E26 1000 lumen, dimmable, opal white', description: 'TRADFRI LED bulb E26 1000 lumen, dimmable, opal white',
supports: 'on/off, brightness', supports: 'on/off, brightness',
fromZigbee: [fz.light_brightness, fz.ignore_onoff_change],
}, },
// Philips // Philips
@ -157,6 +197,7 @@ const devices = {
vendor: 'Philips', vendor: 'Philips',
description: 'Hue Go', description: 'Hue Go',
supports: 'on/off, brightness, color temperature, color xy', supports: 'on/off, brightness, color temperature, color xy',
fromZigbee: [fz.light_brightness, fz.light_color_colortemp, fz.ignore_onoff_change],
}, },
// Belkin // Belkin
@ -165,6 +206,7 @@ const devices = {
vendor: 'Belkin', vendor: 'Belkin',
description: 'WeMo smart LED bulb', description: 'WeMo smart LED bulb',
supports: 'on/off, brightness', supports: 'on/off, brightness',
fromZigbee: [fz.light_brightness, fz.ignore_onoff_change],
}, },
// EDP // EDP
@ -173,6 +215,7 @@ const devices = {
vendor: 'EDP', vendor: 'EDP',
description: 're:dy plug', description: 're:dy plug',
supports: 'on/off, power measurement', supports: 'on/off, power measurement',
fromZigbee: [fz.ignore_onoff_change, fz.EDP_power, fz.ignore_metering_change],
report: [{ report: [{
'cid': 'seMetering', 'cid': 'seMetering',
'attr': 'instantaneousDemand', 'attr': 'instantaneousDemand',
@ -189,6 +232,7 @@ const devices = {
vendor: 'Texas Instruments', vendor: 'Texas Instruments',
description: '[CC2530 router](http://ptvo.info/cc2530-based-zigbee-coordinator-and-router-112/)', description: '[CC2530 router](http://ptvo.info/cc2530-based-zigbee-coordinator-and-router-112/)',
supports: 'state, description, type, rssi', supports: 'state, description, type, rssi',
fromZigbee: [fz.CC2530ROUTER_state, fz.CC2530ROUTER_meta],
}, },
}; };

View File

@ -3,23 +3,11 @@
* Run by executing: npm run docs * Run by executing: npm run docs
*/ */
const zigbee2mqtt = require('../lib/converters/zigbee2mqtt');
const deviceMapping = require('../lib/devices'); const deviceMapping = require('../lib/devices');
const fs = require('fs'); const fs = require('fs');
const YAML = require('json2yaml'); const YAML = require('json2yaml');
const homeassistant = require('../lib/homeassistant'); const homeassistant = require('../lib/homeassistant');
// Sanity check if all supported devices are in deviceMapping
const supportedDevices = new Set();
zigbee2mqtt.forEach((p) => supportedDevices.add(...p.devices));
// Check if in deviceMapping.
supportedDevices.forEach((s) => {
if (!Object.values(deviceMapping).find((d) => d.model === s)) {
console.log(`ERROR: ${s} not in deviceMapping`);
}
});
const outputdir = process.argv[2]; const outputdir = process.argv[2];
if (!outputdir) { if (!outputdir) {