ben423423n32j14e / zigbee2mqttadminpanel

Node-Red-Dashboard web interface for controlling Zigbee2MQTT
GNU General Public License v3.0
111 stars 70 forks source link

Feature Request: Sort devices by friendly_name #17

Open dirstel opened 4 years ago

dirstel commented 4 years ago

As I am using a naming scheme, a sorted device list may come handy. I implemented this in my flow (lack of configuration keeps me using a "fork"). Anyway: this may help you/others:

Put a function node using the following code right behind the JSON node in Devices subflow.

BTW. the JSON node may be ommited, when configuring the mqtt-in node to do the JSON conversion by itself.

// coordinator does not have a friendly name
msg.payload.message[0].friendly_name="";
// sort
msg.payload.message.sort((a, b) => a.friendly_name.localeCompare(b.friendly_name));
return msg;