Return friendlyNames as answer to get_group_membership (#4210)

* Return friendlyNames as answer to get_group_membership

It would be a lot more useful, if you'd return the friendly names of the groups 😉

* Make the linter happy

* Gracefully echo warning if response is undefined

* Making friendship with the linter

Sorry, really shoud have used an IDE
This commit is contained in:
nobodypb
2020-08-30 22:45:40 +02:00
committed by Koen Kanters
parent 1390803738
commit 48d5ee70c0
+12 -1
View File
@@ -29,7 +29,18 @@ class DeviceGroupMembership extends Extension {
`genGroups`, 'getMembership', {groupcount: 0, grouplist: []}, {}, true,
);
const {grouplist, capacity} = response;
if (!response) {
logger.warn(`Couldn't get group membership of ${entity.device.ieeeAddr}`);
return;
}
let {grouplist, capacity} = response;
grouplist = grouplist.map((gid) => {
const g = settings.getGroup(gid);
return g ? g.friendlyName : gid;
});
const msgGroupList = `${entity.device.ieeeAddr} is in groups [${grouplist}]`;
let msgCapacity;
if (capacity === 254) {