Get stats from MitraStar router GPT-2541GNAC


As UPnP integration of Home Assistant wasn’t working for MitraStar GPT-2541 GNAC router, I have created these scripts to get statistics from router directly using expect


I use expect (via pexpect in python) to connect to router and get lan & wan statistics for every interface of MitraStar GPT-2541GNAC (Bytes, Packets, Errors & Drops, Tx and Rx, LAN and WAN Interfaces).

It can be adapted to any other router that we can connect via ssh and get stats with similar commands to showlanstats or showwanstats used in this model.

Once I get statistics, I use another script to get individual values and write sensors in HA like this one:

   - platform: command_line
       name: WAN VoIP (veip0.2) KBytes tx
       command: 'python3 /config/python-scripts/getstats/ /config/python-scripts/getstats/lanwanstats.txt veip0.2 tx B'
       unit_of_measurement: "KBytes"
       value_template: '{{value|multiply (0.001)}}'

Repo in:

I’ve got the old version (doesn’t have fiber module) but it’s easy to adapt to this other model. I will try to adapt next weekend

Thanks for sharing.

You are welcome!
Good luck with adaption and let me know if it works for your router.