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).


  1. Install this Node-RED plugin: node-red-contrib-unifi-os
  2. Add the new node to your flow. Enter configuration for the node. Add an "Controller" with your ip & credentials
  3. Use this endpoint:
    /proxy/network/wss/s/default/events
  4. Add a switch node that switches
    msg.payload.meta.message 
    with string match
    device:sync
    This is the message that will contain realtime bandwidth info
  5. 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;
    }
    
  6. Add an output node to publish to MQTT


This shows the complete flow, really simple!

Comments

Popular posts from this blog

Annke C800 / I91BD still image URL

Send inline image attchment in Node-RED pushover message