From aebb5a045632dc15c8e060fff6ee20ac973e4814 Mon Sep 17 00:00:00 2001 From: Gleb Tcivie Date: Tue, 25 Jun 2024 23:09:06 +0300 Subject: [PATCH] Fixed bug with the names of the devices not being decoded --- .env | 2 +- exporter/registry.py | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/.env b/.env index 4d4e224..568c4ae 100644 --- a/.env +++ b/.env @@ -27,4 +27,4 @@ MESH_HIDE_DESTINATION_DATA=false ## Filtered ports in the exporter (default: 1, can be a comma-separated list of ports) FILTERED_PORTS=0 ## Hide message content in the TEXT_MESSAGE_APP packets (default: true) (Currently we only log message length, if we hide then all messages would have the same length) -HIDE_MESSAGE=true \ No newline at end of file +HIDE_MESSAGE=false \ No newline at end of file diff --git a/exporter/registry.py b/exporter/registry.py index d30b438..b4ff0da 100644 --- a/exporter/registry.py +++ b/exporter/registry.py @@ -361,15 +361,17 @@ class ClientDetails: self.role: Config.DeviceConfig.Role = role def get_role_name_from_role(self): - for name, value in Config.DeviceConfig.Role.__dict__.items(): - if isinstance(value, int) and value == self.role: - return name + descriptor = Config.DeviceConfig.Role.DESCRIPTOR + for enum_value in descriptor.values: + if enum_value.number == self.role: + return enum_value.name return 'UNKNOWN_ROLE' def get_hardware_model_name_from_code(self): - for name, value in HardwareModel.__dict__.items(): - if isinstance(value, int) and value == self.hardware_model: - return name + descriptor = HardwareModel.DESCRIPTOR + for enum_value in descriptor.values: + if enum_value.number == self.hardware_model: + return enum_value.name return 'UNKNOWN_HARDWARE_MODEL' def to_dict(self):