Does zabbix-extra-wifi work for you?

Homehub 5a running 23.05.3. Originally I had this problem on 19.07 and upgraded but it made no difference.

The package zabbix-extra-wifi installs /etc/zabbix_agentd.conf.d/wifi which provides some additional parameters for Zabbix agent, eg:

wifi.iwinfo.channel[*]

which calls:

lua -l iwinfo -e "print(iwinfo[iwinfo.type('$1')].channel('$1'))"

where $1 is replaced with an interface like phy0-ap0, and this works:

$ zabbix_get -k wifi.iwinfo.channel[phy0-ap0] -s loftap
48
$ zabbix_get -k wifi.iwinfo.nbusers[phy0-ap0] -s loftap
1

Zabbix needs the discovery item wifi.ifdiscovery to work for this to be of any practical use.
From the Zabbix server, the expected output from the agent on loftap would be a list of interfaces:

$ zabbix_get -k wifi.ifdiscovery -s loftap
lua: (command line):1: bad argument #1 to 'type' (string expected, got nil)
stack traceback:
        [C]: in function 'type'
        (command line):1: in main chunk
        [C]: ?

This is the code for the discovery but I don't know what about it is wrong:

UserParameter=wifi.ifdiscovery, lua -l ubus -l iwinfo -e 'u=ubus.connect();list="{\"data\":[";stat=u:call("network.wireless", "status", {});for dev, dev_table in pairs(stat) do for i, iface in pairs(dev_table["interfaces"]) do c=iface["config"];i=iface["ifname"];t=iwinfo.type(i);iw=iwinfo[t];e = iw.encryption(i);e = e and e.description or "None";n = table.concat(c["network"]," ");list=list.."{\"{#IF}\":\""..i.."\", \"{#MODE}\":\""..iw.mode(i).."\", \"{#SSID}\":\""..c["ssid"].."\", \"{#NET}\":\""..n.."\", \"{#DEV}\":\""..dev.."\", \"{#ENC}\":\""..e.."\", \"{#TYPE}\":\""..t.."\", \"{#HWMODE}\":\"".."?".."\", \"{#CHANNEL}\":\""..iw.channel(i).."\", \"{#BSSID}\":\""..iw.bssid(i).."\"},";end;end;list=string.gsub(list,",$","");print(list.."]}")'

I tried to run that lua 1-liner through an un-minifier but the output isn't readable. I think the 1-liner has some escapes in it that either the shell or the Zabbix agent requires, which confuses the un-minifier.

This looks like an attempt to fix this

but the fix is from 6 years ago and I can't believe that it would have stayed broken for this long!

This is somehow a model-specific issue. The one it doesn't work on is a Homehub 5a. I have installed 23.05.3 on a UAP-AC-Lite, and the discovery script works fine! Not sure what would explain this.