mirror of
https://github.com/Koenkk/zigbee2mqtt.git
synced 2026-08-27 21:20:03 +00:00
Add endpoint to request connected devices. #77
This commit is contained in:
@@ -277,6 +277,20 @@ class Controller {
|
||||
|
||||
if (option === 'permit_join') {
|
||||
this.zigbee.permitJoin(message.toString().toLowerCase() === 'true');
|
||||
} else if (option === 'devices') {
|
||||
const devices = this.zigbee.getAllClients().map((device) => {
|
||||
const mappedModel = deviceMapping[device.modelId];
|
||||
const friendlyDevice = settings.getDevice(device.ieeeAddr);
|
||||
|
||||
return {
|
||||
ieeeAddr: device.ieeeAddr,
|
||||
type: device.type,
|
||||
model: mappedModel ? mappedModel.model : device.modelId,
|
||||
friendly_name: friendlyDevice ? friendlyDevice.friendly_name : device.ieeeAddr,
|
||||
};
|
||||
});
|
||||
|
||||
this.mqtt.publish('bridge/devices', JSON.stringify(devices), {retain: false});
|
||||
} else {
|
||||
logger.warn(`Cannot handle MQTT config option '${option}' with message '${message}'`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user