Skip to content

Commit 93e19dd

Browse files
authored
Bug fix
1 parent f00578c commit 93e19dd

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

custom_components/ghostfolio/sensor.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ async def async_setup_entry(
5858
GhostfolioSimpleGainPercentSensor(coordinator, config_entry),
5959
]
6060
async_add_entities(global_sensors)
61-
# Mark globals as known (using their property logic)
61+
# Mark globals as known
6262
for s in global_sensors:
6363
known_ids.add(s.unique_id)
6464

@@ -97,9 +97,8 @@ def _update_sensors():
9797
holdings_list = holdings_map.get(account_id, [])
9898

9999
for holding in holdings_list:
100-
# Ensure valid holding with quantity (ignore fully sold positions if quantity is 0)
100+
# Ensure valid holding with quantity
101101
if float(holding.get("quantity") or 0) > 0:
102-
# Construct ID manually to check against known_ids before creating object
103102
symbol = holding.get("symbol")
104103
safe_symbol = slugify(symbol)
105104
unique_id = f"ghostfolio_holding_{account_id}_{safe_symbol}_{config_entry.entry_id}"
@@ -114,7 +113,6 @@ def _update_sensors():
114113
watchlist_items = coordinator.data.get("watchlist", [])
115114
for item in watchlist_items:
116115
symbol = item.get("symbol")
117-
# Construct ID manually
118116
safe_symbol = slugify(symbol)
119117
unique_id = f"ghostfolio_watchlist_{safe_symbol}_{config_entry.entry_id}"
120118

@@ -128,10 +126,9 @@ def _update_sensors():
128126
async_add_entities(new_entities)
129127

130128
# 2. Register the listener
131-
# This ensures _update_sensors runs every time the coordinator fetches new data
132129
config_entry.async_on_unload(coordinator.async_add_listener(_update_sensors))
133130

134-
# 3. Run it immediately to load initial data
131+
# 3. Run it immediately
135132
_update_sensors()
136133

137134

@@ -354,7 +351,7 @@ class GhostfolioAccountBaseSensor(GhostfolioBaseSensor):
354351
"""Base class for Account-specific sensors."""
355352

356353
def __init__(self, coordinator, config_entry, account_data):
357-
super().__init__(coordinator, config_entry, account_data)
354+
super().__init__(coordinator, config_entry) # <--- FIXED HERE (Removed account_data)
358355
self.account_id = account_data["id"]
359356
self.account_name = account_data["name"]
360357

0 commit comments

Comments
 (0)