File tree Expand file tree Collapse file tree
custom_components/rohlikcz Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -688,11 +688,16 @@ class UpdateSensor(BaseEntity, SensorEntity):
688688 _attr_icon = ICON_UPDATE
689689 _attr_device_class = SensorDeviceClass .TIMESTAMP
690690
691- def __init__ ( self , rohlik_account : RohlikAccount ) -> None :
692- super (). __init__ ( rohlik_account )
693- self . _attr_native_value = datetime .now (tz = ZoneInfo ("Europe/Prague" ))
691+ @ property
692+ def native_value ( self ) -> datetime :
693+ return datetime .now (tz = ZoneInfo ("Europe/Prague" ))
694694
695695 async def async_update (self ) -> None :
696696 """Calls regular update of data from API."""
697697 await self ._rohlik_account .async_update ()
698- self ._attr_native_value = datetime .now (tz = ZoneInfo ("Europe/Prague" ))
698+
699+ async def async_added_to_hass (self ) -> None :
700+ self ._rohlik_account .register_callback (self .async_write_ha_state )
701+
702+ async def async_will_remove_from_hass (self ) -> None :
703+ self ._rohlik_account .remove_callback (self .async_write_ha_state )
Original file line number Diff line number Diff line change 44
55import logging
66import voluptuous as vol
7- from homeassistant .core import HomeAssistant , ServiceCall
7+ from homeassistant .core import HomeAssistant , ServiceCall , SupportsResponse
88from homeassistant .exceptions import HomeAssistantError
99from homeassistant .helpers import config_validation as cv
1010
@@ -198,5 +198,5 @@ async def async_update_data(call: ServiceCall) -> None:
198198 schema = vol .Schema ({
199199 vol .Required (ATTR_CONFIG_ENTRY_ID ): cv .string
200200 }),
201- supports_response = False
201+ supports_response = SupportsResponse . NONE
202202 )
You can’t perform that action at this time.
0 commit comments