Realtime bandwitdh/traffic speed from Unifi Dream Machine Pro into MQTT
I wanted to display realtime Internet traffic data on my dashboards. This information is available in Unifi Controller on my UDM-Pro. (Only works with UDM PRO at the time of writing, not with standalone controller as far as I know. Please comment if you have an solution).
- Install this Node-RED plugin: node-red-contrib-unifi-os
- Add the new node to your flow. Enter configuration for the node. Add an "Controller" with your ip & credentials
- Use this endpoint:
/proxy/network/wss/s/default/events
- Add a switch node that switches
with string matchmsg.payload.meta.message
This is the message that will contain realtime bandwidth infodevice:sync
- Add the following function node to fetch the bandwidth data. You may need to correct according to your setup (wan1/wan2).
if(msg.payload.data[0].hasOwnProperty('wan1')) { var m = {} m.payload = {} m.payload.rx = (Number(msg.payload.data[0].wan1.rx_rate)/1000000).toFixed(1); m.payload.tx = (Number(msg.payload.data[0].wan1.tx_rate)/1000000).toFixed(1); return m; }
- Add an output node to publish to MQTT
Comments
Post a Comment