kid control to monitor dynamic devices, optimisations/fixes

This commit is contained in:
Arseniy Kuznetsov
2024-04-02 08:12:00 +02:00
parent f65c692700
commit 6ced8428d2
10 changed files with 55 additions and 106 deletions

View File

@@ -20,16 +20,16 @@ class KidDeviceMetricsDataSource:
"""
@staticmethod
def metric_records(router_entry, *, metric_labels=None):
def metric_records(router_entry, *, metric_labels=None, translation_table = None):
if metric_labels is None:
metric_labels = []
try:
device_records = []
records = router_entry.api_connection.router_api().get_resource('/ip/kid-control/device').get()
for record in records:
if record.get('user'):
if record.get('user') or router_entry.config_entry.kid_control_dynamic:
device_records.append(record)
return BaseDSProcessor.trimmed_records(router_entry, router_records=device_records, metric_labels=metric_labels)
return BaseDSProcessor.trimmed_records(router_entry, router_records=device_records, metric_labels=metric_labels, translation_table=translation_table)
except Exception as exc:
print(
f'Error getting Kid-control device info from router{router_entry.router_name}@{router_entry.config_entry.hostname}: {exc}')