@@ -79,6 +79,7 @@ def _update_sensors():
7979 if show_accounts :
8080 account_sensors = [
8181 GhostfolioAccountValueSensor (coordinator , config_entry , account ),
82+ GhostfolioAccountNetWorthSensor (coordinator , config_entry , account ), # <--- NEW SENSOR ADDED HERE
8283 GhostfolioAccountCostSensor (coordinator , config_entry , account ),
8384 GhostfolioAccountPerformanceSensor (coordinator , config_entry , account ),
8485 GhostfolioAccountTWRSensor (coordinator , config_entry , account ),
@@ -411,12 +412,22 @@ def native_value(self) -> float | None:
411412 return None
412413 return self .account_performance_data .get ("currentValueInBaseCurrency" )
413414
415+ class GhostfolioAccountNetWorthSensor (GhostfolioAccountBaseSensor ):
416+ """Sensor for Account Net Worth (Invested + Cash)."""
417+ _attr_device_class = SensorDeviceClass .MONETARY
418+ _attr_state_class = SensorStateClass .TOTAL
419+ _attr_suggested_display_precision = 2
420+
421+ def __init__ (self , coordinator , config_entry , account_data ):
422+ super ().__init__ (coordinator , config_entry , account_data )
423+ self ._attr_unique_id = f"ghostfolio_account_net_worth_{ self .account_id } _{ config_entry .entry_id } "
424+ self ._attr_name = f"{ self .account_name } Net Worth"
425+
414426 @property
415- def extra_state_attributes (self ) -> dict [str , Any ] | None :
416- """Return the account net worth (Value + Cash)."""
417- if not self .coordinator .data :
427+ def native_value (self ) -> float | None :
428+ if not self .is_account_healthy :
418429 return None
419- return { "current_net_worth" : self .account_performance_data .get ("currentNetWorth" )}
430+ return self .account_performance_data .get ("currentNetWorth" )
420431
421432class GhostfolioAccountCostSensor (GhostfolioAccountBaseSensor ):
422433 _attr_device_class = SensorDeviceClass .MONETARY
0 commit comments