Skip to content

Commit

Permalink
Change poll to push
Browse files Browse the repository at this point in the history
  • Loading branch information
Andre0512 committed Mar 25, 2024
1 parent 20d467a commit c461711
Show file tree
Hide file tree
Showing 14 changed files with 8 additions and 19 deletions.
1 change: 0 additions & 1 deletion custom_components/hon/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 0 additions & 2 deletions custom_components/hon/button.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down
1 change: 0 additions & 1 deletion custom_components/hon/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
1 change: 0 additions & 1 deletion custom_components/hon/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
)

DOMAIN: str = "hon"
UPDATE_INTERVAL: int = 60
MOBILE_ID: str = "homassistant"
CONF_REFRESH_TOKEN = "refresh_token"

Expand Down
1 change: 0 additions & 1 deletion custom_components/hon/fan.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
7 changes: 4 additions & 3 deletions custom_components/hon/hon.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
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__)
Expand Down Expand Up @@ -53,13 +53,13 @@ def __init__(self, hass: HomeAssistantType, device: HonAppliance):
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:
Expand All @@ -68,6 +68,7 @@ def info(self) -> HonInfo:

class HonEntity(CoordinatorEntity[HonCoordinator]):
_attr_has_entity_name = True
_attr_should_poll = False

def __init__(
self,
Expand Down
1 change: 0 additions & 1 deletion custom_components/hon/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
1 change: 0 additions & 1 deletion custom_components/hon/lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions custom_components/hon/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
1 change: 0 additions & 1 deletion custom_components/hon/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
1 change: 0 additions & 1 deletion custom_components/hon/select.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
1 change: 0 additions & 1 deletion custom_components/hon/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion custom_components/hon/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
pyhOn==0.16.0
pyhOn==0.17.0

0 comments on commit c461711

Please sign in to comment.