From 7f5865aaf92fbcfd4f52bb48639ea736d8acda5d Mon Sep 17 00:00:00 2001 From: Koenkk Date: Thu, 17 May 2018 18:03:54 +0200 Subject: [PATCH] Update lumi.router device specification. --- lib/converters/zigbee2mqtt.js | 43 ++++++++++++++++++----------------- lib/devices.js | 10 ++++---- lib/homeassistant.js | 12 ++++++++++ 3 files changed, 39 insertions(+), 26 deletions(-) diff --git a/lib/converters/zigbee2mqtt.js b/lib/converters/zigbee2mqtt.js index deb1ba3f..b5d127e3 100644 --- a/lib/converters/zigbee2mqtt.js +++ b/lib/converters/zigbee2mqtt.js @@ -344,7 +344,7 @@ const parsers = [ return result; } } - }, + }, { devices: ['QBKG04LM'], cid: 'genOnOff', @@ -376,6 +376,27 @@ const parsers = [ return {smoke: msg.data.zoneStatus === 1}; }, }, + { + devices: ['CC2530.ROUTER'], + cid: 'genOnOff', + type: 'attReport', + convert: (msg) => { + return {state: msg.data.data['onOff'] === 1}; + }, + }, + { + devices: ['CC2530.ROUTER'], + cid: 'genBinaryValue', + type: 'attReport', + convert: (msg) => { + const data = msg.data.data; + return { + description: data['description'], + type: data['inactiveText'], + rssi: data['presentValue'], + }; + }, + }, // Ignore parsers (these message dont need parsing). { @@ -444,26 +465,6 @@ const parsers = [ type: 'devChange', convert: () => null, }, - { - devices: ['LUMI.ROUTER'], - cid: 'genOnOff', - type: 'attReport', - convert: (msg) => {return {state: msg.data.data['onOff'] === 1 ? "ON" : "OFF"}} - }, - { - devices: ['LUMI.ROUTER'], - cid: 'genBinaryValue', - type: 'attReport', - convert: (msg) => { - const data = msg.data.data; - const result = { - description: data['description'], - type: data['inactiveText'], - rssi: data['presentValue'] - }; - return result; - } - }, ]; module.exports = parsers; diff --git a/lib/devices.js b/lib/devices.js index d52d5557..3f4a9dd2 100644 --- a/lib/devices.js +++ b/lib/devices.js @@ -157,12 +157,12 @@ const devices = { supports: 'on/off, brightness', }, - // Zigbee router: http://ptvo.info/cc2530-based-zigbee-coordinator-and-router-112/ + // Texax Instruments 'lumi.router': { - model: 'LUMI.ROUTER', - vendor: 'TexasInstruments', - description: 'Router', - supports: 'on/off' + model: 'CC2530.ROUTER', + vendor: 'Texas Instruments', + description: 'CC2530 router [link](http://ptvo.info/cc2530-based-zigbee-coordinator-and-router-112/)', + supports: 'state, description, type, rssi', }, }; diff --git a/lib/homeassistant.js b/lib/homeassistant.js index 81dd65d7..f6a0f0f2 100644 --- a/lib/homeassistant.js +++ b/lib/homeassistant.js @@ -46,6 +46,17 @@ const configurations = { json_attributes: ['battery'], }, }, + 'binary_sensor_router': { + type: 'binary_sensor', + object_id: 'router', + discovery_payload: { + payload_on: true, + payload_off: false, + value_template: '{{ value_json.state }}', + device_class: 'connectivity', + json_attributes: ['description', 'type', 'rssi'], + }, + }, // Sensor 'sensor_illuminance': { @@ -209,6 +220,7 @@ const mapping = { '7146060PH': [configurations.light_brightness_colortemp_xy], 'F7C033': [configurations.light_brightness], 'JTYJ-GD-01LM/BW': [configurations.binary_sensor_smoke], + 'CC2530.ROUTER': [configurations.binary_sensor_router], }; // A map of all discoverd devices