mirror of
https://github.com/tomaae/homeassistant-mikrotik_router.git
synced 2025-06-24 01:38:49 +02:00
Removed redundant get_dhcp call from update method. Removed unnecessary calls to Mikrotik API for accounting hosts build, reusing new hosts dict. Removed unnecessary variables from mikrotik_controller.py. Reused new dhcp-networks dict. Simplified accounting throughput calculation. Added accounting 'available' and 'local_enabled' parameters for each host. Implemented new parameters on sensor availability.
This commit is contained in:
parent
eee634cfc8
commit
32b93cc8cc
2 changed files with 52 additions and 97 deletions
|
@ -378,6 +378,16 @@ class MikrotikAccountingSensor(MikrotikControllerSensor):
|
|||
"""Return a unique_id for this entity."""
|
||||
return f"{self._inst.lower()}-{self._sensor.lower()}-{self._data['mac-address'].lower()}"
|
||||
|
||||
@property
|
||||
def available(self) -> bool:
|
||||
"""Return if controller and accounting feature in Mikrotik is available.
|
||||
Additional check for lan-tx/rx sensors
|
||||
"""
|
||||
if self._sensor in ['lan-tx, lan-rx']:
|
||||
return self._ctrl.connected() and self._data['available'] and self._data['local_accounting']
|
||||
else:
|
||||
return self._ctrl.connected() and self._data['available']
|
||||
|
||||
@property
|
||||
def device_info(self):
|
||||
"""Return a accounting description for device registry."""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue