Skip to content

Commit

Permalink
refactor: improve type hinting and logging in EconetBinarySensor; red…
Browse files Browse the repository at this point in the history
…uce timeout in EconetDataCoordinator
  • Loading branch information
jontofront committed Dec 18, 2024
1 parent 91a34b6 commit b8059c7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions custom_components/econet300/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,13 @@ def __init__(
self.entity_description,
)

def _sync_state(self, value):
def _sync_state(self, value: bool):
"""Sync state."""
value = bool(value)
_LOGGER.debug("EconetBinarySensor _sync_state: %s", value)
self._attr_is_on = value
_LOGGER.debug(
"Updated Binary sensor _attr_is_on for %s: %s",
"Updated EconetBinarySensor _attr_is_on for %s: %s",
self.entity_description.key,
self._attr_is_on,
)
Expand Down Expand Up @@ -131,7 +132,7 @@ async def async_setup_entry(
entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> bool:
"""Set up the sensor platform."""
"""Set up the binary sensor platform."""
coordinator = hass.data[DOMAIN][entry.entry_id][SERVICE_COORDINATOR]
api = hass.data[DOMAIN][entry.entry_id][SERVICE_API]

Expand Down
2 changes: 1 addition & 1 deletion custom_components/econet300/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ async def _async_update_data(self):
try:
# Note: asyncio.TimeoutError and aiohttp.ClientError are already
# handled by the data update coordinator.
async with asyncio.timeout(20):
async with asyncio.timeout(10):
data = await self._api.fetch_sys_params()
reg_params = await self._api.fetch_reg_params()
params_edits = await self._api.fetch_param_edit_data()
Expand Down

0 comments on commit b8059c7

Please sign in to comment.