@@ -487,7 +487,7 @@ async def async_added_to_hass(self) -> None:
487487 self ._check_and_reset_month ()
488488 self ._process_new_orders ()
489489
490- self ._rohlik_account .register_callback (self ._handle_coordinator_update )
490+ self ._rohlik_account .register_callback (self .async_write_ha_state )
491491
492492 def _check_and_reset_month (self ) -> None :
493493 """Reset total if month changed."""
@@ -554,15 +554,11 @@ def _process_new_orders(self) -> None:
554554 if new_orders_count > 0 :
555555 _LOGGER .info (f"Processed { new_orders_count } new order(s). Monthly total: { self ._monthly_total } CZK" )
556556
557- async def _handle_coordinator_update (self ) -> None :
558- """Handle coordinator updates by processing new orders and updating state."""
559- self ._check_and_reset_month ()
560- self ._process_new_orders ()
561- await self .async_write_ha_state ()
562-
563557 @property
564558 def native_value (self ) -> float | None :
565559 """Returns amount spent in current month."""
560+ self ._check_and_reset_month ()
561+ self ._process_new_orders ()
566562 return self ._monthly_total if self ._monthly_total > 0 else 0.0
567563
568564 @property
@@ -581,7 +577,7 @@ def icon(self) -> str:
581577 return ICON_MONTHLY_SPENT
582578
583579 async def async_will_remove_from_hass (self ) -> None :
584- self ._rohlik_account .remove_callback (self ._handle_coordinator_update )
580+ self ._rohlik_account .remove_callback (self .async_write_ha_state )
585581
586582
587583class NoLimitOrders (BaseEntity , SensorEntity ):
0 commit comments