Skip to content

Commit 1dbff6c

Browse files
committed
Small bug fixes.
1 parent 0e9db78 commit 1dbff6c

2 files changed

Lines changed: 11 additions & 6 deletions

File tree

custom_components/rohlikcz/sensor.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff 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)

custom_components/rohlikcz/services.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import logging
66
import voluptuous as vol
7-
from homeassistant.core import HomeAssistant, ServiceCall
7+
from homeassistant.core import HomeAssistant, ServiceCall, SupportsResponse
88
from homeassistant.exceptions import HomeAssistantError
99
from 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
)

0 commit comments

Comments
 (0)