@@ -69,7 +69,6 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry, async_add_e
69
69
monthly_rx_gb (coordinator ),
70
70
DataLeftSensor (coordinator ),
71
71
ConnectionUptimeSensor (coordinator ),
72
- ZTESessionDiagnosticsSensor (coordinator ),
73
72
])
74
73
handled_keys .update (["station_list" , "lan_station_list" , "all_devices" ])
75
74
@@ -299,78 +298,6 @@ def extra_state_attributes(self):
299
298
# Only return attributes if self._attributes is defined
300
299
return getattr (self , "_attributes" , {})
301
300
302
- class ZTESessionDiagnosticsSensor (ZTERouterEntity ):
303
- def __init__ (self , coordinator ):
304
- self .coordinator = coordinator
305
- self ._name = "Session Diagnostics"
306
- self ._state = None
307
- self ._attributes = {}
308
- self .entity_registry_enabled_default = True
309
- self ._attr_is_diagnostics = True
310
- self ._attr_should_poll = False
311
- self ._state = "Unavailable" if not self .coordinator .last_update_success else "OK"
312
- _LOGGER .info ("Initializing Session Diagnostics sensor" )
313
-
314
- @property
315
- def name (self ):
316
- return self ._name
317
-
318
- @property
319
- def state (self ):
320
- return self ._state or "Unknown"
321
-
322
- @property
323
- def unique_id (self ):
324
- return f"{ DOMAIN } _{ self .coordinator .ip_entry } _session_diagnostics"
325
-
326
- @property
327
- def device_info (self ):
328
- return {
329
- "identifiers" : {(DOMAIN , f"{ DOMAIN } _{ self .coordinator .ip_entry } " )},
330
- "name" : self .coordinator .ip_entry ,
331
- "manufacturer" : MANUFACTURER ,
332
- "model" : MODEL ,
333
- }
334
-
335
- @property
336
- def is_diagnostics (self ):
337
- return True
338
-
339
- @property
340
- def entity_category (self ):
341
- return EntityCategory .DIAGNOSTIC
342
-
343
- @property
344
- def extra_state_attributes (self ):
345
- return self ._attributes
346
-
347
- async def async_update (self ):
348
- _LOGGER .info ("Manual update requested for Session Diagnostics sensor" )
349
- await self .coordinator .async_request_refresh ()
350
-
351
- @guard_stale_data
352
- async def async_handle_coordinator_update (self ):
353
- output = await self .coordinator .hass .async_add_executor_job (
354
- self .coordinator .run_mc_script ,
355
- self .coordinator .ip_entry ,
356
- self .coordinator .password_entry ,
357
- self .coordinator .username_entry ,
358
- 99 # Your diagnostic command
359
- )
360
-
361
- try :
362
- data = json .loads (extract_json (output ))
363
- self ._state = "OK" if data else "Unavailable"
364
- self ._attributes = data
365
- _LOGGER .info (f"Session Diagnostics sensor updated: { data } " )
366
- except Exception as e :
367
- _LOGGER .warning (f"Failed to parse session diagnostics output: { e } " )
368
- self ._state = "Error"
369
- self ._attributes = {}
370
-
371
- self .async_write_ha_state ()
372
-
373
-
374
301
class ZTERouterSensor (ZTERouterEntity ):
375
302
def __init__ (self , coordinator , name , key , disabled_by_default = False ):
376
303
self .coordinator = coordinator
0 commit comments