diff --git a/custom_components/hon/binary_sensor.py b/custom_components/hon/binary_sensor.py index 45774c1..7e861eb 100644 --- a/custom_components/hon/binary_sensor.py +++ b/custom_components/hon/binary_sensor.py @@ -324,7 +324,6 @@ async def async_setup_entry( if device.get(description.key) is None: continue entity = HonBinarySensorEntity(hass, entry, device, description) - await entity.coordinator.async_config_entry_first_refresh() entities.append(entity) async_add_entities(entities) diff --git a/custom_components/hon/button.py b/custom_components/hon/button.py index 7a5cf24..0d4b4b8 100644 --- a/custom_components/hon/button.py +++ b/custom_components/hon/button.py @@ -64,11 +64,9 @@ async def async_setup_entry( if not device.commands.get(description.key): continue entity = HonButtonEntity(hass, entry, device, description) - await entity.coordinator.async_config_entry_first_refresh() entities.append(entity) entities.append(HonDeviceInfo(hass, entry, device)) entities.append(HonDataArchive(hass, entry, device)) - await entities[-1].coordinator.async_config_entry_first_refresh() async_add_entities(entities) diff --git a/custom_components/hon/climate.py b/custom_components/hon/climate.py index 0d1a2ac..9f26171 100644 --- a/custom_components/hon/climate.py +++ b/custom_components/hon/climate.py @@ -120,7 +120,6 @@ async def async_setup_entry( entity = HonClimateEntity(hass, entry, device, description) else: continue # type: ignore[unreachable] - await entity.coordinator.async_config_entry_first_refresh() entities.append(entity) async_add_entities(entities) diff --git a/custom_components/hon/const.py b/custom_components/hon/const.py index 8ca9b07..69ba158 100644 --- a/custom_components/hon/const.py +++ b/custom_components/hon/const.py @@ -7,7 +7,6 @@ from homeassistant.components.climate import ( ) DOMAIN: str = "hon" -UPDATE_INTERVAL: int = 60 MOBILE_ID: str = "homassistant" CONF_REFRESH_TOKEN = "refresh_token" diff --git a/custom_components/hon/fan.py b/custom_components/hon/fan.py index f51edc8..02e6673 100644 --- a/custom_components/hon/fan.py +++ b/custom_components/hon/fan.py @@ -47,7 +47,6 @@ async def async_setup_entry( ): continue entity = HonFanEntity(hass, entry, device, description) - await entity.coordinator.async_config_entry_first_refresh() entities.append(entity) async_add_entities(entities) diff --git a/custom_components/hon/hon.py b/custom_components/hon/hon.py index 4b88aa6..e873f32 100644 --- a/custom_components/hon/hon.py +++ b/custom_components/hon/hon.py @@ -14,7 +14,7 @@ from homeassistant.helpers.update_coordinator import CoordinatorEntity from homeassistant.helpers.update_coordinator import DataUpdateCoordinator from pyhon.appliance import HonAppliance -from .const import DOMAIN, UPDATE_INTERVAL +from .const import DOMAIN from .typedefs import HonEntityDescription, HonOptionEntityDescription, T _LOGGER = logging.getLogger(__name__) @@ -53,13 +53,13 @@ class HonCoordinator(DataUpdateCoordinator[None]): hass, _LOGGER, name=device.unique_id, - update_interval=timedelta(seconds=UPDATE_INTERVAL), ) self._device = device self._info = HonInfo() + self._device.subscribe(self.async_set_updated_data) async def _async_update_data(self) -> None: - return await self._device.update() + return @property def info(self) -> HonInfo: @@ -68,6 +68,7 @@ class HonCoordinator(DataUpdateCoordinator[None]): class HonEntity(CoordinatorEntity[HonCoordinator]): _attr_has_entity_name = True + _attr_should_poll = False def __init__( self, diff --git a/custom_components/hon/light.py b/custom_components/hon/light.py index ef64a98..e54956d 100644 --- a/custom_components/hon/light.py +++ b/custom_components/hon/light.py @@ -64,7 +64,6 @@ async def async_setup_entry( ): continue entity = HonLightEntity(hass, entry, device, description) - await entity.coordinator.async_config_entry_first_refresh() entities.append(entity) async_add_entities(entities) diff --git a/custom_components/hon/lock.py b/custom_components/hon/lock.py index 4e7d526..97c3b58 100644 --- a/custom_components/hon/lock.py +++ b/custom_components/hon/lock.py @@ -37,7 +37,6 @@ async def async_setup_entry( ): continue entity = HonLockEntity(hass, entry, device, description) - await entity.coordinator.async_config_entry_first_refresh() entities.append(entity) async_add_entities(entities) diff --git a/custom_components/hon/manifest.json b/custom_components/hon/manifest.json index ffe7d27..562cc0a 100644 --- a/custom_components/hon/manifest.json +++ b/custom_components/hon/manifest.json @@ -6,10 +6,10 @@ ], "config_flow": true, "documentation": "https://github.com/Andre0512/hon/", - "iot_class": "cloud_polling", + "iot_class": "cloud_push", "issue_tracker": "https://github.com/Andre0512/hon/issues", "requirements": [ - "pyhOn==0.16.1" + "pyhOn==0.17.0" ], - "version": "0.14.0-beta.1" + "version": "0.14.0-beta.2" } diff --git a/custom_components/hon/number.py b/custom_components/hon/number.py index 9d92184..e5e84dd 100644 --- a/custom_components/hon/number.py +++ b/custom_components/hon/number.py @@ -220,7 +220,6 @@ async def async_setup_entry( entity = HonConfigNumberEntity(hass, entry, device, description) else: continue - await entity.coordinator.async_config_entry_first_refresh() entities.append(entity) async_add_entities(entities) diff --git a/custom_components/hon/select.py b/custom_components/hon/select.py index 901ee15..650698f 100644 --- a/custom_components/hon/select.py +++ b/custom_components/hon/select.py @@ -224,7 +224,6 @@ async def async_setup_entry( entity = HonConfigSelectEntity(hass, entry, device, description) else: continue - await entity.coordinator.async_config_entry_first_refresh() entities.append(entity) async_add_entities(entities) diff --git a/custom_components/hon/sensor.py b/custom_components/hon/sensor.py index 6d3ed76..6b5355c 100644 --- a/custom_components/hon/sensor.py +++ b/custom_components/hon/sensor.py @@ -824,7 +824,6 @@ async def async_setup_entry( entity = HonConfigSensorEntity(hass, entry, device, description) else: continue - await entity.coordinator.async_config_entry_first_refresh() entities.append(entity) async_add_entities(entities) diff --git a/custom_components/hon/switch.py b/custom_components/hon/switch.py index 44480c5..8b68d21 100644 --- a/custom_components/hon/switch.py +++ b/custom_components/hon/switch.py @@ -426,7 +426,6 @@ async def async_setup_entry( entity = HonSwitchEntity(hass, entry, device, description) else: continue - await entity.coordinator.async_config_entry_first_refresh() entities.append(entity) async_add_entities(entities) diff --git a/requirements.txt b/requirements.txt index 74037b1..22a82d9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1 @@ -pyhOn==0.16.0 +pyhOn==0.17.0