Get Mesh Signal/Noise dBm in a JSON file?

I've setup an OpenWRT BATMAN mesh using 6 x ASUS Lyra AC2200 nodes + 2 x Linksys EA8300 all running OpenWRT 24.10.1. It's early days, but so far everything seems to work well.

When I log into OpenWRT on any of the routers, it gives a System Status page including a list of "Associated Stations" of which I'm particularly interested in those which are part of my 'mesh' network. It shows the Signal/Noise values for each of the attached mesh node devices.

Is there a way I can generate a file (ideally in JSON format) that contains this data for each of the mesh nodes?

I've looked at iwinfo & batctl but couldn't really find anything to give me what I wanted (I'm still something of a novice with all this).

Ideally I'd like to periodically generate a JSON file with the data (does cron work on OpenWRT?) and then read it into my 'Home Assistant' setup running on Raspberry Pi.

Any clues as to what command will give me the Signal/Noise values per 'Associated Station' as is shown on the OpenWRT system status page??

ubus?

example:

ubus call iwinfo info '{"device":"phy0"}'
1 Like

Gosh, that was quick! I was just about to say

iwinfo phy0-mesh0 assoclist

seems to contain what I'm after, but is there a way to get this in JSON format?

I tried @4zims suggestion, but it doesnt seem to contain any Signal/Noise values & seems to only generate data for the node it's run on, rather than all the 'Associated Stations'

like this maybe?

ubus call iwinfo assoclist '{"device":"phy0-mesh0"}'

2 Likes

You're a genius sir! Just what I was after!

Any idea how I can create a cron job (or whatever the OpenWRT equivalent is) to run this every few minutes?

1 Like

there's cron* support..

Actually, in my 'Home Assistant' setup, I have an Automation that runs periodically this bit of Python:

import requests, urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) #disable insecure requests warnings

zyxelIP = "192.168.69.1"
zyxelUsername = "username"
zyxelPassword = "userpassword" # this is the 'Encrypted' version

values = {'Input_Account':zyxelUsername,'Input_Passwd':zyxelPassword}

s = requests.Session() #inititate a session
r = s.post(('https://'+zyxelIP+'/UserLogin'), json=values, verify = False) #login with the credentials

sessionkey = r.json()['sessionkey'] #store the session key to be able to logout at the end - doesn't like lots of simultaneous logged in sessions

cardpage_status = s.get(('https://'+zyxelIP+'/cgi-bin/DAL?oid=cardpage_status'), verify = False) #get the cardpage info

bitOfInfo = cardpage_status.json()['Object'][0]["CellIntfInfo"]["X_ZYXEL_RSRP"]

import json
with open('www/zyxel/data.json', 'w') as out_file:
     json.dump(cardpage_status.json(), out_file, sort_keys = True, indent = 4, ensure_ascii = False)

out = s.post(('https://'+zyxelIP+'/cgi-bin/UserLogout?sessionkey='+str(sessionkey)), verify = False) #logout

which gets the data that my Zyxel router spits out in JSON format when you open the 'cardpage_status' URL (after logging in).

Is this adaptable to do something similar to get the Signal/Noise data from an OpenWRT router? Presumably I can modify the login bit, but obviously OpenWRT doesn't have an equivalent 'cardpage_status' page, so how can I feed the JSON output from the ubus call into this Python script?

(sorry for the newbie questions)

Actually, if I can create a cron job to generate the JSON file, then I'm sure I can find a way to scp the file from the OpenWRT router to my 'Home Assistant' raspberry pi (I've no idea how to do the scp, but that seems like a much more surmountable problem).

It's not exactly what you want, but it's something like this. https://gist.github.com/AzimsTech/86da77ec0e5da6345ee0d266aef12844#file-populate-host-names-in-associated-stations-to-2nd-ap-md

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.