From fd67a1c08dd956e9ff84288b28724233bab0f848 Mon Sep 17 00:00:00 2001 From: TheHolyRoger Date: Sun, 21 May 2023 22:57:20 +0100 Subject: [PATCH] Fix a few errors during updates --- Version | 3 ++- custom_components/cryptoinfo_advanced/__init__.py | 2 +- .../cryptoinfo_advanced/crypto_sensor.py | 14 +++++++------- custom_components/cryptoinfo_advanced/manager.py | 4 ++-- .../cryptoinfo_advanced/manifest.json | 2 +- 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/Version b/Version index f851970..69f62ea 100644 --- a/Version +++ b/Version @@ -28,4 +28,5 @@ Version: 0.2.5 20230425 - Switch to asyncio platform setup/aiohttp, add reload s Version: 0.2.6 20230425 - Add mempool avg fee per TX child sensor Version: 0.3.0 20230426 - Rename to Cryptoinfo Advanced Version: 0.3.1 20230426 - Fixes for HACS/HASS requirements -Version: 0.3.2 20230507 - Add total unknown hash control sensor to chain control, mempool total fee calculated. \ No newline at end of file +Version: 0.3.2 20230507 - Add total unknown hash control sensor to chain control, mempool total fee calculated. +Version: 0.3.3 20230521 - Fix a few errors during updates. \ No newline at end of file diff --git a/custom_components/cryptoinfo_advanced/__init__.py b/custom_components/cryptoinfo_advanced/__init__.py index f9aa3e1..e19434e 100644 --- a/custom_components/cryptoinfo_advanced/__init__.py +++ b/custom_components/cryptoinfo_advanced/__init__.py @@ -1 +1 @@ -__version__ = "0.3.2" +__version__ = "0.3.3" diff --git a/custom_components/cryptoinfo_advanced/crypto_sensor.py b/custom_components/cryptoinfo_advanced/crypto_sensor.py index 25cac15..8ff1b42 100644 --- a/custom_components/cryptoinfo_advanced/crypto_sensor.py +++ b/custom_components/cryptoinfo_advanced/crypto_sensor.py @@ -666,7 +666,7 @@ def _extract_data_chain_summary_full(self, json_data): def _extract_data_chain_control_primary(self, api_data): return True - def _extract_data_chain_control_special(self, json_data): + def _extract_data_chain_control_special(self, json_data, ignore_not_found=True): pool_data = None data_100_blk = 0 data_1000_blk = 0 @@ -678,9 +678,9 @@ def _extract_data_chain_control_special(self, json_data): data_100_blk += pool["nb100"] data_1000_blk += pool["nb1000"] - if pool_data is not None: + if ignore_not_found or pool_data is not None: return { - **pool_data, + **(pool_data if pool_data is not None else {}), "nb100": data_100_blk, "nb1000": data_1000_blk, } @@ -688,8 +688,8 @@ def _extract_data_chain_control_special(self, json_data): return None def _extract_data_chain_control_full(self, json_data): - if self._extract_data_chain_control_special(json_data) is None: - raise ValueError(f"Pool Prefixes {self.pool_prefixes} not found") + if self._extract_data_chain_control_special(json_data, ignore_not_found=False) is None: + _LOGGER.debug(f"Pool Prefixes {self.pool_prefixes} not found") return json_data @@ -896,9 +896,9 @@ async def _fetch_chain_block_time(self, api_data=None): block_height = CryptoInfoAdvEntityManager.instance().get_last_diff(self.cryptocurrency_name) if block_height_arg is not None: - _LOGGER.error("Error fetching " + self.name + " - Invalid block height arg supplied.") + _LOGGER.warning("Error fetching " + self.name + " - Invalid block height arg supplied.") elif block_height is None: - _LOGGER.error("Error fetching " + self.name + " - No data from Chain Summary sensor.") + _LOGGER.warning("Error fetching " + self.name + " - No data from Chain Summary sensor.") if block_height is None: raise ValueError() diff --git a/custom_components/cryptoinfo_advanced/manager.py b/custom_components/cryptoinfo_advanced/manager.py index 186ae28..283c4f7 100644 --- a/custom_components/cryptoinfo_advanced/manager.py +++ b/custom_components/cryptoinfo_advanced/manager.py @@ -225,7 +225,7 @@ def get_fetch_frequency(self, fetch_type): def get_remaining_hash_control(self, cryptocurrency_name): if cryptocurrency_name not in self._hash_control_sources: - return None + return (None, None) sensor_found = False known_hash_control_100 = 0 @@ -245,7 +245,7 @@ def get_remaining_hash_control(self, cryptocurrency_name): known_hash_control_1000 += int(source._pool_control_1000b) if not sensor_found: - return None + return (None, None) return (int(100 - known_hash_control_100), int(1000 - known_hash_control_1000)) diff --git a/custom_components/cryptoinfo_advanced/manifest.json b/custom_components/cryptoinfo_advanced/manifest.json index 01bcdd9..ff42eeb 100644 --- a/custom_components/cryptoinfo_advanced/manifest.json +++ b/custom_components/cryptoinfo_advanced/manifest.json @@ -10,5 +10,5 @@ "iot_class": "cloud_polling", "issue_tracker": "https://github.com/TheHolyRoger/hass-cryptoinfo/issues", "requirements": [], - "version": "0.3.2" + "version": "0.3.3" } \ No newline at end of file