mirror of
https://github.com/Koenkk/zigbee2mqtt.git
synced 2024-11-16 18:39:09 -07:00
Edp redy - Power Plug (#53)
* fixed json * added mqtt commands * added endpoints * support battery status * added firmware for CC2531 USB Stick with maximum number of possible devices (48) * support aqara magnet * added support for wall switch * update regex * Update README.md * added automatic chip selection * fix reconnect * Update README.md * added missing dependency * fix magnets * fix topic * support for aqara button * yaml based configuration * restore project defaults * save bridgeID * default values Don’t change the configured bridgeID (backward compatible with bridgeID = “bridge”) * personal configuration * added EDP RE:DY * don't mess remote * don't mess remote * don't mess remote * fix * clean * lint * generic * lint * Update devices.js * Update zigbee2mqtt.js * lint * Refactor configure reports. * Fix lint.
This commit is contained in:
parent
b912386786
commit
567bdca276
@ -21,6 +21,7 @@ class Controller {
|
||||
this.zigbee = new Zigbee();
|
||||
this.mqtt = new MQTT();
|
||||
this.stateCache = {};
|
||||
this.configuredReport = [];
|
||||
this.handleZigbeeMessage = this.handleZigbeeMessage.bind(this);
|
||||
this.handleMQTTMessage = this.handleMQTTMessage.bind(this);
|
||||
}
|
||||
@ -33,7 +34,10 @@ class Controller {
|
||||
// Log zigbee clients on startup.
|
||||
const devices = this.zigbee.getAllClients();
|
||||
logger.info(`Currently ${devices.length} devices are joined:`);
|
||||
devices.forEach((device) => logger.info(this.getDeviceStartupLogMessage(device)));
|
||||
devices.forEach((device) => {
|
||||
logger.info(this.getDeviceStartupLogMessage(device));
|
||||
this.configureDevice(device);
|
||||
});
|
||||
|
||||
// Connect to MQTT broker
|
||||
const subscriptions = [
|
||||
@ -123,6 +127,20 @@ class Controller {
|
||||
this.zigbee.stop(callback);
|
||||
}
|
||||
|
||||
configureDevice(device) {
|
||||
// Configure reporting for this device.
|
||||
const ieeeAddr = device.ieeeAddr;
|
||||
if (ieeeAddr && device.modelId && !this.configuredReport.includes(ieeeAddr)) {
|
||||
const mappedModel = deviceMapping[device.modelId];
|
||||
|
||||
if (mappedModel && mappedModel.report) {
|
||||
this.zigbee.configureReport(ieeeAddr, mappedModel.report);
|
||||
}
|
||||
|
||||
this.configuredReport.push(ieeeAddr);
|
||||
}
|
||||
}
|
||||
|
||||
getDeviceStartupLogMessage(device) {
|
||||
let friendlyName = 'unknown';
|
||||
let friendlyDevice = {model: 'unkown', description: 'unknown'};
|
||||
@ -184,6 +202,9 @@ class Controller {
|
||||
return;
|
||||
}
|
||||
|
||||
// Configure device.
|
||||
this.configureDevice(device);
|
||||
|
||||
// Home Assistant MQTT discovery
|
||||
if (settings.get().homeassistant) {
|
||||
homeassistant.discover(device.ieeeAddr, mappedModel.model, this.mqtt);
|
||||
|
@ -360,6 +360,14 @@ const parsers = [
|
||||
return {smoke: msg.data.zoneStatus === 1};
|
||||
},
|
||||
},
|
||||
{
|
||||
devices: ['PLUG EDP RE:DY'],
|
||||
cid: 'seMetering',
|
||||
type: 'attReport',
|
||||
convert: (msg) => {
|
||||
return {power: precisionRound(msg.data.data['instantaneousDemand'], 2)};
|
||||
},
|
||||
},
|
||||
{
|
||||
devices: ['CC2530.ROUTER'],
|
||||
cid: 'genOnOff',
|
||||
@ -387,6 +395,7 @@ const parsers = [
|
||||
devices: [
|
||||
'WXKG11LM', 'MCCGQ11LM', 'MCCGQ01LM', 'WXKG01LM', 'LED1545G12', '7146060PH', 'LED1537R6', 'ZNCZ02LM',
|
||||
'QBCZ11LM', 'QBKG04LM', 'QBKG03LM', 'LED1623G12', 'LED1650R5', 'LED1536G5', 'F7C033', 'LED1622G12',
|
||||
'PLUG EDP RE:DY',
|
||||
],
|
||||
cid: 'genOnOff',
|
||||
type: 'devChange',
|
||||
@ -449,6 +458,12 @@ const parsers = [
|
||||
type: 'devChange',
|
||||
convert: () => null,
|
||||
},
|
||||
{
|
||||
devices: ['PLUG EDP RE:DY'],
|
||||
cid: 'seMetering',
|
||||
type: 'devChange',
|
||||
convert: () => null,
|
||||
},
|
||||
];
|
||||
|
||||
module.exports = parsers;
|
||||
|
@ -167,6 +167,22 @@ const devices = {
|
||||
supports: 'on/off, brightness',
|
||||
},
|
||||
|
||||
// EDP
|
||||
'ZB-SmartPlug-1.0.0': {
|
||||
model: 'PLUG EDP RE:DY',
|
||||
vendor: 'EDP',
|
||||
description: 'Plug EDP re:dy',
|
||||
supports: 'on/off, power measurement',
|
||||
report: [{
|
||||
'cid': 'seMetering',
|
||||
'attr': 'instantaneousDemand',
|
||||
'ep': 85,
|
||||
'minInt': 10,
|
||||
'maxInt': 60,
|
||||
'repChange': 1,
|
||||
}],
|
||||
},
|
||||
|
||||
// Texax Instruments
|
||||
'lumi.router': {
|
||||
model: 'CC2530.ROUTER',
|
||||
|
@ -222,6 +222,7 @@ const mapping = {
|
||||
'7146060PH': [configurations.light_brightness_colortemp_xy],
|
||||
'F7C033': [configurations.light_brightness],
|
||||
'JTYJ-GD-01LM/BW': [configurations.binary_sensor_smoke],
|
||||
'PLUG EDP RE:DY': [configurations.switch, configurations.sensor_power],
|
||||
'CC2530.ROUTER': [configurations.binary_sensor_router],
|
||||
};
|
||||
|
||||
|
@ -109,6 +109,23 @@ class Zigbee {
|
||||
}
|
||||
}
|
||||
|
||||
configureReport(ieeeAddr, reports) {
|
||||
reports.forEach((r) => {
|
||||
const device = this.shepherd.find(ieeeAddr, r.ep);
|
||||
if (device) {
|
||||
device.report(r.cid, r.attr, r.minInt, r.maxInt, r.repChange, (error) => {
|
||||
if (error) {
|
||||
logger.warn(`Failed to configure reporting for ${ieeeAddr} ${r.cid} ${r.attr}`);
|
||||
} else {
|
||||
logger.info(`Configured reporting for ${ieeeAddr} ${r.cid} ${r.attr}`);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
logger.warn(`Failed to configure reporting for ${ieeeAddr} ${r.cid} ${r.attr} (device not found)`);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
getDevice(deviceID) {
|
||||
return this.shepherd.list().find((d) => d.ieeeAddr === deviceID);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user