Skip to content

Commit dbd3626

Browse files
committed
Added PCI values in decimal as 3GPP specification suggest #26
modified: custom_components/zte_router/manifest.json modified: custom_components/zte_router/sensor.py
1 parent c8bfd37 commit dbd3626

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

custom_components/zte_router/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@
99
"iot_class": "local_polling",
1010
"issue_tracker": "https://github.com/Kajkac/ZTE-MC-Home-assistant-repo/issues",
1111
"requirements": ["aiohttp"],
12-
"version": "1.0.31"
12+
"version": "1.0.32"
1313
}

custom_components/zte_router/sensor.py

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -303,12 +303,29 @@ async def async_handle_coordinator_update(self):
303303
if self.coordinator.data:
304304
new_state = self.coordinator.data.get(self._key, None)
305305
if new_state is not None:
306+
if "pci" in self._key.lower():
307+
try:
308+
if isinstance(new_state, str):
309+
new_state = int(new_state, 16)
310+
_LOGGER.debug(
311+
f"Converted hex PCI value to decimal for key '{self._key}': {new_state}"
312+
)
313+
except (ValueError, TypeError):
314+
_LOGGER.warning(
315+
f"Failed to convert value for key '{self._key}' (expected hex string): {new_state}"
316+
)
306317
self._state = new_state
307-
_LOGGER.info(f"Sensor {self._name} updated. Old state: {old_state}, New state: {self._state}")
318+
_LOGGER.info(
319+
f"Sensor '{self._name}' updated. Old state: {old_state}, New state: {self._state}"
320+
)
308321
else:
309-
_LOGGER.warning(f"No new data for sensor {self._name}. Retaining last state: {self._state}")
322+
_LOGGER.debug(
323+
f"No value found for key '{self._key}' in coordinator data."
324+
)
310325
else:
311-
_LOGGER.warning(f"No data available from coordinator for sensor {self._name}. Retaining last state: {self._state}")
326+
_LOGGER.warning(
327+
f"No coordinator data available for sensor '{self._name}'. Retaining last state."
328+
)
312329
self.async_write_ha_state()
313330

314331
class LastSMSSensor(ZTERouterEntity):

0 commit comments

Comments
 (0)