Skip to content

Commit

Permalink
Fix a few errors during updates
Browse files Browse the repository at this point in the history
  • Loading branch information
TheHolyRoger committed May 21, 2023
1 parent 17c08be commit fd67a1c
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 12 deletions.
3 changes: 2 additions & 1 deletion Version
Original file line number Diff line number Diff line change
Expand Up @@ -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.
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.
2 changes: 1 addition & 1 deletion custom_components/cryptoinfo_advanced/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.3.2"
__version__ = "0.3.3"
14 changes: 7 additions & 7 deletions custom_components/cryptoinfo_advanced/crypto_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -678,18 +678,18 @@ 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,
}

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

Expand Down Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions custom_components/cryptoinfo_advanced/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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))

Expand Down
2 changes: 1 addition & 1 deletion custom_components/cryptoinfo_advanced/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

0 comments on commit fd67a1c

Please sign in to comment.