mirror of
https://github.com/Andre0512/hon.git
synced 2024-12-22 10:45:30 +00:00
Change poll to push
This commit is contained in:
parent
20d467a2d5
commit
c46171114f
|
@ -324,7 +324,6 @@ async def async_setup_entry(
|
||||||
if device.get(description.key) is None:
|
if device.get(description.key) is None:
|
||||||
continue
|
continue
|
||||||
entity = HonBinarySensorEntity(hass, entry, device, description)
|
entity = HonBinarySensorEntity(hass, entry, device, description)
|
||||||
await entity.coordinator.async_config_entry_first_refresh()
|
|
||||||
entities.append(entity)
|
entities.append(entity)
|
||||||
async_add_entities(entities)
|
async_add_entities(entities)
|
||||||
|
|
||||||
|
|
|
@ -64,11 +64,9 @@ async def async_setup_entry(
|
||||||
if not device.commands.get(description.key):
|
if not device.commands.get(description.key):
|
||||||
continue
|
continue
|
||||||
entity = HonButtonEntity(hass, entry, device, description)
|
entity = HonButtonEntity(hass, entry, device, description)
|
||||||
await entity.coordinator.async_config_entry_first_refresh()
|
|
||||||
entities.append(entity)
|
entities.append(entity)
|
||||||
entities.append(HonDeviceInfo(hass, entry, device))
|
entities.append(HonDeviceInfo(hass, entry, device))
|
||||||
entities.append(HonDataArchive(hass, entry, device))
|
entities.append(HonDataArchive(hass, entry, device))
|
||||||
await entities[-1].coordinator.async_config_entry_first_refresh()
|
|
||||||
async_add_entities(entities)
|
async_add_entities(entities)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -120,7 +120,6 @@ async def async_setup_entry(
|
||||||
entity = HonClimateEntity(hass, entry, device, description)
|
entity = HonClimateEntity(hass, entry, device, description)
|
||||||
else:
|
else:
|
||||||
continue # type: ignore[unreachable]
|
continue # type: ignore[unreachable]
|
||||||
await entity.coordinator.async_config_entry_first_refresh()
|
|
||||||
entities.append(entity)
|
entities.append(entity)
|
||||||
async_add_entities(entities)
|
async_add_entities(entities)
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,6 @@ from homeassistant.components.climate import (
|
||||||
)
|
)
|
||||||
|
|
||||||
DOMAIN: str = "hon"
|
DOMAIN: str = "hon"
|
||||||
UPDATE_INTERVAL: int = 60
|
|
||||||
MOBILE_ID: str = "homassistant"
|
MOBILE_ID: str = "homassistant"
|
||||||
CONF_REFRESH_TOKEN = "refresh_token"
|
CONF_REFRESH_TOKEN = "refresh_token"
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,6 @@ async def async_setup_entry(
|
||||||
):
|
):
|
||||||
continue
|
continue
|
||||||
entity = HonFanEntity(hass, entry, device, description)
|
entity = HonFanEntity(hass, entry, device, description)
|
||||||
await entity.coordinator.async_config_entry_first_refresh()
|
|
||||||
entities.append(entity)
|
entities.append(entity)
|
||||||
async_add_entities(entities)
|
async_add_entities(entities)
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
|
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
|
||||||
from pyhon.appliance import HonAppliance
|
from pyhon.appliance import HonAppliance
|
||||||
|
|
||||||
from .const import DOMAIN, UPDATE_INTERVAL
|
from .const import DOMAIN
|
||||||
from .typedefs import HonEntityDescription, HonOptionEntityDescription, T
|
from .typedefs import HonEntityDescription, HonOptionEntityDescription, T
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
@ -53,13 +53,13 @@ class HonCoordinator(DataUpdateCoordinator[None]):
|
||||||
hass,
|
hass,
|
||||||
_LOGGER,
|
_LOGGER,
|
||||||
name=device.unique_id,
|
name=device.unique_id,
|
||||||
update_interval=timedelta(seconds=UPDATE_INTERVAL),
|
|
||||||
)
|
)
|
||||||
self._device = device
|
self._device = device
|
||||||
self._info = HonInfo()
|
self._info = HonInfo()
|
||||||
|
self._device.subscribe(self.async_set_updated_data)
|
||||||
|
|
||||||
async def _async_update_data(self) -> None:
|
async def _async_update_data(self) -> None:
|
||||||
return await self._device.update()
|
return
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def info(self) -> HonInfo:
|
def info(self) -> HonInfo:
|
||||||
|
@ -68,6 +68,7 @@ class HonCoordinator(DataUpdateCoordinator[None]):
|
||||||
|
|
||||||
class HonEntity(CoordinatorEntity[HonCoordinator]):
|
class HonEntity(CoordinatorEntity[HonCoordinator]):
|
||||||
_attr_has_entity_name = True
|
_attr_has_entity_name = True
|
||||||
|
_attr_should_poll = False
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
|
|
|
@ -64,7 +64,6 @@ async def async_setup_entry(
|
||||||
):
|
):
|
||||||
continue
|
continue
|
||||||
entity = HonLightEntity(hass, entry, device, description)
|
entity = HonLightEntity(hass, entry, device, description)
|
||||||
await entity.coordinator.async_config_entry_first_refresh()
|
|
||||||
entities.append(entity)
|
entities.append(entity)
|
||||||
async_add_entities(entities)
|
async_add_entities(entities)
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,6 @@ async def async_setup_entry(
|
||||||
):
|
):
|
||||||
continue
|
continue
|
||||||
entity = HonLockEntity(hass, entry, device, description)
|
entity = HonLockEntity(hass, entry, device, description)
|
||||||
await entity.coordinator.async_config_entry_first_refresh()
|
|
||||||
entities.append(entity)
|
entities.append(entity)
|
||||||
|
|
||||||
async_add_entities(entities)
|
async_add_entities(entities)
|
||||||
|
|
|
@ -6,10 +6,10 @@
|
||||||
],
|
],
|
||||||
"config_flow": true,
|
"config_flow": true,
|
||||||
"documentation": "https://github.com/Andre0512/hon/",
|
"documentation": "https://github.com/Andre0512/hon/",
|
||||||
"iot_class": "cloud_polling",
|
"iot_class": "cloud_push",
|
||||||
"issue_tracker": "https://github.com/Andre0512/hon/issues",
|
"issue_tracker": "https://github.com/Andre0512/hon/issues",
|
||||||
"requirements": [
|
"requirements": [
|
||||||
"pyhOn==0.16.1"
|
"pyhOn==0.17.0"
|
||||||
],
|
],
|
||||||
"version": "0.14.0-beta.1"
|
"version": "0.14.0-beta.2"
|
||||||
}
|
}
|
||||||
|
|
|
@ -220,7 +220,6 @@ async def async_setup_entry(
|
||||||
entity = HonConfigNumberEntity(hass, entry, device, description)
|
entity = HonConfigNumberEntity(hass, entry, device, description)
|
||||||
else:
|
else:
|
||||||
continue
|
continue
|
||||||
await entity.coordinator.async_config_entry_first_refresh()
|
|
||||||
entities.append(entity)
|
entities.append(entity)
|
||||||
async_add_entities(entities)
|
async_add_entities(entities)
|
||||||
|
|
||||||
|
|
|
@ -224,7 +224,6 @@ async def async_setup_entry(
|
||||||
entity = HonConfigSelectEntity(hass, entry, device, description)
|
entity = HonConfigSelectEntity(hass, entry, device, description)
|
||||||
else:
|
else:
|
||||||
continue
|
continue
|
||||||
await entity.coordinator.async_config_entry_first_refresh()
|
|
||||||
entities.append(entity)
|
entities.append(entity)
|
||||||
async_add_entities(entities)
|
async_add_entities(entities)
|
||||||
|
|
||||||
|
|
|
@ -824,7 +824,6 @@ async def async_setup_entry(
|
||||||
entity = HonConfigSensorEntity(hass, entry, device, description)
|
entity = HonConfigSensorEntity(hass, entry, device, description)
|
||||||
else:
|
else:
|
||||||
continue
|
continue
|
||||||
await entity.coordinator.async_config_entry_first_refresh()
|
|
||||||
entities.append(entity)
|
entities.append(entity)
|
||||||
|
|
||||||
async_add_entities(entities)
|
async_add_entities(entities)
|
||||||
|
|
|
@ -426,7 +426,6 @@ async def async_setup_entry(
|
||||||
entity = HonSwitchEntity(hass, entry, device, description)
|
entity = HonSwitchEntity(hass, entry, device, description)
|
||||||
else:
|
else:
|
||||||
continue
|
continue
|
||||||
await entity.coordinator.async_config_entry_first_refresh()
|
|
||||||
entities.append(entity)
|
entities.append(entity)
|
||||||
|
|
||||||
async_add_entities(entities)
|
async_add_entities(entities)
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
pyhOn==0.16.0
|
pyhOn==0.17.0
|
||||||
|
|
Loading…
Reference in a new issue