@@ -304,7 +304,10 @@ async def node_diagnostics(self, node_id: int) -> NodeDiagnostics:
304
304
thread_cluster : Clusters .ThreadNetworkDiagnostics = node .get_cluster (
305
305
0 , Clusters .ThreadNetworkDiagnostics
306
306
)
307
- network_name = thread_cluster .networkName
307
+ if isinstance (thread_cluster .networkName , bytes ):
308
+ network_name = thread_cluster .networkName .decode ("utf-8" )
309
+ else :
310
+ network_name = thread_cluster .networkName
308
311
# parse routing role to (diagnostics) node type
309
312
if (
310
313
thread_cluster .routingRole
@@ -322,12 +325,21 @@ async def node_diagnostics(self, node_id: int) -> NodeDiagnostics:
322
325
):
323
326
node_type = NodeType .END_DEVICE
324
327
elif network_type == NetworkType .WIFI :
325
- wifi_cluster : Clusters .WiFiNetworkDiagnostics = node .get_cluster (
326
- 0 , Clusters .WiFiNetworkDiagnostics
327
- )
328
- if wifi_cluster and wifi_cluster .bssid :
329
- network_name = wifi_cluster .bssid
330
328
node_type = NodeType .END_DEVICE
329
+ # use lastNetworkID from NetworkCommissioning cluster as fallback to get the network name
330
+ # this allows getting the SSID as the wifi diagnostics cluster only has the BSSID
331
+ last_network_id : bytes | str | None
332
+ if not network_name and (
333
+ last_network_id := node .get_attribute_value (
334
+ 0 ,
335
+ cluster = None ,
336
+ attribute = Clusters .NetworkCommissioning .Attributes .LastNetworkID ,
337
+ )
338
+ ):
339
+ if isinstance (last_network_id , bytes ):
340
+ network_name = last_network_id .decode ("utf-8" )
341
+ else :
342
+ network_name = last_network_id
331
343
# override node type if node is a bridge
332
344
if node .node_data .is_bridge :
333
345
node_type = NodeType .BRIDGE
0 commit comments