Skip to content

Commit 66f9f37

Browse files
committed
fix: issues with helium stats and improve error handling
1 parent 64c2d8a commit 66f9f37

File tree

7 files changed

+30
-12
lines changed

7 files changed

+30
-12
lines changed

custom_components/helium_solana/sensor.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -103,17 +103,17 @@ async def get_sensors(wallets, prices):
103103
for price in prices:
104104
sensors.append(PriceSensor(price))
105105

106-
sensors.append(HeliumStats(heliumStatsAPI, 'IOT', 'total_hotspots', 'Total Hotspots', ['data', 'helium_iot', 'total_hotspots'], 'mdi:router-wireless', 'Hotspots'))
107-
sensors.append(HeliumStats(heliumStatsAPI, 'IOT', 'active_hotspots', 'Active Hotspots', ['data', 'helium_iot', 'active_hotspots'], 'mdi:router-wireless', 'Hotspots'))
108-
sensors.append(HeliumStats(heliumStatsAPI, 'IOT', 'total_cities', 'Total Cities', ['data', 'helium_iot', 'total_cities'],'mdi:city', 'Cities'))
109-
sensors.append(HeliumStats(heliumStatsAPI, 'IOT', 'total_countries', 'Total Countries', ['data', 'helium_iot', 'total_countries'], 'mdi:earth', 'Countries'))
110-
sensors.append(HeliumStats(heliumStatsAPI, 'IOT', 'daily_average_rewards', 'Daily Average Rewards', ['data', 'helium_iot', 'daily_average_rewards'], 'mdi:hand-coin-outline', 'IOT', 'float'))
111-
112-
sensors.append(HeliumStats(heliumStatsAPI, 'MOBILE', 'total_hotspots', 'Total Hotspots', ['data', 'helium_mobile', 'total_hotspots'],'mdi:router-wireless', 'Hotspots'))
113-
sensors.append(HeliumStats(heliumStatsAPI, 'MOBILE', 'active_hotspots', 'Active Hotspots', ['data', 'helium_mobile', 'active_hotspots'],'mdi:router-wireless', 'Hotspots'))
114-
sensors.append(HeliumStats(heliumStatsAPI, 'MOBILE', 'total_cities', 'Total Cities', ['data', 'helium_mobile', 'total_cities'], 'mdi:city', 'Cities'))
115-
sensors.append(HeliumStats(heliumStatsAPI, 'MOBILE', 'total_countries', 'Total Countries', ['data', 'helium_mobile', 'total_countries'], 'mdi:earth', 'Countries'))
116-
sensors.append(HeliumStats(heliumStatsAPI, 'MOBILE', 'daily_average_rewards', 'Daily Average Rewards', ['data', 'helium_mobile', 'daily_average_rewards'], 'mdi:hand-coin-outline', 'MOBILE' ,'float'))
106+
sensors.append(HeliumStats(api_backend, 'IOT', 'total_hotspots', 'Total Hotspots', ['stats', 'iot', 'total_hotspots'], 'mdi:router-wireless', 'Hotspots'))
107+
sensors.append(HeliumStats(api_backend, 'IOT', 'active_hotspots', 'Active Hotspots', ['stats', 'iot', 'active_hotspots'], 'mdi:router-wireless', 'Hotspots'))
108+
sensors.append(HeliumStats(api_backend, 'IOT', 'total_cities', 'Total Cities', ['stats', 'iot', 'total_cities'],'mdi:city', 'Cities'))
109+
sensors.append(HeliumStats(api_backend, 'IOT', 'total_countries', 'Total Countries', ['stats', 'iot', 'total_countries'], 'mdi:earth', 'Countries'))
110+
sensors.append(HeliumStats(api_backend, 'IOT', 'daily_average_rewards', 'Daily Average Rewards', ['stats', 'iot', 'daily_average_rewards'], 'mdi:hand-coin-outline', 'IOT', 'float'))
111+
112+
sensors.append(HeliumStats(api_backend, 'MOBILE', 'total_hotspots', 'Total Hotspots', ['stats', 'mobile', 'total_hotspots'],'mdi:router-wireless', 'Hotspots'))
113+
sensors.append(HeliumStats(api_backend, 'MOBILE', 'active_hotspots', 'Active Hotspots', ['stats', 'mobile', 'active_hotspots'],'mdi:router-wireless', 'Hotspots'))
114+
sensors.append(HeliumStats(api_backend, 'MOBILE', 'total_cities', 'Total Cities', ['stats', 'mobile', 'total_cities'], 'mdi:city', 'Cities'))
115+
sensors.append(HeliumStats(api_backend, 'MOBILE', 'total_countries', 'Total Countries', ['stats', 'mobile', 'total_countries'], 'mdi:earth', 'Countries'))
116+
sensors.append(HeliumStats(api_backend, 'MOBILE', 'daily_average_rewards', 'Daily Average Rewards', ['stats', 'mobile', 'daily_average_rewards'], 'mdi:hand-coin-outline', 'MOBILE' ,'float'))
117117

118118
for wallet in wallets:
119119
len_wallet = len(wallet)

custom_components/helium_solana/sensors/HeliumStats.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
from typing import Any, Callable, Dict, Optional
23
from homeassistant.helpers.entity import (
34
Entity,
@@ -8,6 +9,9 @@
89
DOMAIN
910
)
1011

12+
import logging
13+
_LOGGER = logging.getLogger(__name__)
14+
1115

1216
class HeliumStats(Entity):
1317
"""Helium Stats"""
@@ -71,7 +75,7 @@ async def async_update(self):
7175
try:
7276

7377

74-
response = await self.api.get_data()
78+
response = await self.api.get_data('heliumstats')
7579

7680
if response.status_code != 200:
7781
return

custom_components/helium_solana/sensors/HotspotReward.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
DOMAIN
1010
)
1111

12+
import logging
13+
_LOGGER = logging.getLogger(__name__)
14+
1215
class HotspotReward(Entity):
1316
"""Hotspot Reward"""
1417
def __init__(self, api, wallet, identifier, path, label, uom, icon):

custom_components/helium_solana/sensors/PriceSensor.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
)
1212
import asyncio
1313

14+
import logging
15+
_LOGGER = logging.getLogger(__name__)
1416

1517
class PriceSensor(Entity):
1618
"""Price Sensor for Solana tokens"""

custom_components/helium_solana/sensors/StakingRewardsPosition.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
DOMAIN
99
)
1010

11+
import logging
12+
_LOGGER = logging.getLogger(__name__)
13+
1114
class StakingRewardsPosition(Entity):
1215
"""Staking Reward"""
1316
def __init__(self, api, wallet, delegated_position_key, data, icon):

custom_components/helium_solana/sensors/StakingRewardsToken.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
DOMAIN
99
)
1010

11+
import logging
12+
_LOGGER = logging.getLogger(__name__)
13+
1114
class StakingRewardsToken(Entity):
1215
"""Staking Reward"""
1316
def __init__(self, api, wallet, token, icon):

custom_components/helium_solana/sensors/WalletBalance.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
)
1010

1111

12+
import logging
13+
_LOGGER = logging.getLogger(__name__)
14+
1215
class WalletBalance(Entity):
1316
"""Wallet Balance"""
1417
def __init__(self, api, address, key, path, uom, icon):

0 commit comments

Comments
 (0)