Huawei B525 Python API

As mentioned in my last post I was tinkering with the Optus provided Huawei B525 router features.
I've now manged to implement a few commands and MAC filtering via a Python2 API.

So far I'm using it to:
  1. Monitor my usage (I have a 500 GB cap)
  2. Implement time scheduling for my kids devices
Here's my usage display in Grafana.
I run OpenHab and persist the data from the Router using the python API into an Influxdb database that Grafana uses. Here's my current Grafana display:



The API will work with the following model:
  • B525s-65a
And may work with these others:
  • B618s-22d
  • B715s-23c
So far I've got MAC filtering implemented and a few API's to get traffic and other information.

Currently supported calls:
GET Requests
----------
getInfo()       => api/device/information
getTraffic()    => api/monitoring/traffic-statistics
getStats()      => api/monitoring/month_statistics")
getClients()    => api/wlan/host-list
getAllClients() => api/lan/HostInfo
getSignal()     => api/device/signal
getMacFilter()  => api/security/mac-filter
getLanSettings()=> api/dhcp/settings
getStaticHosts()=> api/dhcp/static-addr-info

POST Requests
-------------
doReboot()
doPowerOff()
setDenyMacFilter(macs)
setAllowMacFilter(macs)
setMacFilterOff()
setDhcpOff()
setDhcpOn(startAddress, endAddress, leaseTime=86400)
setLanAddress(ipaddress, netmask='255.255.255.0', url='homerouter.cpe')
setManualDns(primaryDns, secondaryDns='')
setAutomaticDns()
setAllLanSettings(settings)
setStaticHosts(settings)
Example usage is as follows:
router = B525Router(router='192.168.8.1', username='admin', password='xxx')

#Get Router information, example result below.
router.getInfo()

#Set DNS to Google
router.setManualDns('8.8.8.8', '8.8.4.4')

#Deny macs
router.setDenyMacFilter(['xx:xx:xx:xx:xx:xx','yy:yy:yy:yy:yy:yy', ...])
Router information returned from getInfo():
<response>
    <DeviceName>B525s-65a</DeviceName>
    <SerialNumber>xxx</SerialNumber>
    <Imei>xxx</Imei>
    <Imsi>xxx</Imsi>
    <Iccid>xxx</Iccid>
    <Msisdn/>
    <HardwareVersion>WL2B520M</HardwareVersion>
    <SoftwareVersion>11.189.63.00.74</SoftwareVersion>
    <WebUIVersion>21.100.44.00.03</WebUIVersion>
    <MacAddress1>XX:XX:XX:XX:XX:XX</MacAddress1>
    <MacAddress2/>
    <WanIPAddress>99.99.99.99</WanIPAddress>
    <wan_dns_address>99.99.99.99,99.99.99.99</wan_dns_address>
    <WanIPv6Address/>
    <wan_ipv6_dns_address/>
    <ProductFamily>LTE</ProductFamily>
    <Classify>cpe</Classify>
    <supportmode>LTE|WCDMA|GSM</supportmode>
    <workmode>LTE</workmode>
    <submask>255.255.255.255</submask>
</response>

Comments

  1. This sounds fantastic! I would love to be able to keep tabs on internet usage amongst my family. I have the same router and I have a Raspberry Pi. Sounds like much to learn to do this though.

    ReplyDelete
  2. Hi, i need access to the Ethernet settings which i can't access with the Optus B525, would u know how i can do this the tab is mean't to be there just isn't because the device is with Optus.

    ReplyDelete
    Replies
    1. Hi JarJarBinkx,

      I've now added the ethernet settings to the Python API.

      In terms of the Modem web screens it doesn't look like the tab is easy to reenable, the html pages aren't available for me.
      - /html/ethernetsettings.html
      - /html/ethernetstatus.html

      Delete

Post a Comment

Popular posts from this blog

Experience with Optus 4G wireless broadband

Port Forwarding on Optus 4G B525 router