mirror of
https://github.com/home-assistant/core.git
synced 2025-04-25 01:38:02 +00:00
Improve ondilo_ico
generic typing (#84738)
This commit is contained in:
parent
b8a4399078
commit
c4b45fb110
@ -1,6 +1,7 @@
|
|||||||
"""API for Ondilo ICO bound to Home Assistant OAuth."""
|
"""API for Ondilo ICO bound to Home Assistant OAuth."""
|
||||||
from asyncio import run_coroutine_threadsafe
|
from asyncio import run_coroutine_threadsafe
|
||||||
import logging
|
import logging
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
from ondilo import Ondilo
|
from ondilo import Ondilo
|
||||||
|
|
||||||
@ -35,7 +36,7 @@ class OndiloClient(Ondilo):
|
|||||||
|
|
||||||
return self.session.token
|
return self.session.token
|
||||||
|
|
||||||
def get_all_pools_data(self) -> dict:
|
def get_all_pools_data(self) -> list[dict[str, Any]]:
|
||||||
"""Fetch pools and add pool details and last measures to pool data."""
|
"""Fetch pools and add pool details and last measures to pool data."""
|
||||||
|
|
||||||
pools = self.get_pools()
|
pools = self.get_pools()
|
||||||
|
@ -3,6 +3,7 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
from ondilo import OndiloError
|
from ondilo import OndiloError
|
||||||
|
|
||||||
@ -28,6 +29,7 @@ from homeassistant.helpers.update_coordinator import (
|
|||||||
UpdateFailed,
|
UpdateFailed,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
from .api import OndiloClient
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
|
|
||||||
SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
|
SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
|
||||||
@ -91,9 +93,9 @@ async def async_setup_entry(
|
|||||||
) -> None:
|
) -> None:
|
||||||
"""Set up the Ondilo ICO sensors."""
|
"""Set up the Ondilo ICO sensors."""
|
||||||
|
|
||||||
api = hass.data[DOMAIN][entry.entry_id]
|
api: OndiloClient = hass.data[DOMAIN][entry.entry_id]
|
||||||
|
|
||||||
async def async_update_data():
|
async def async_update_data() -> list[dict[str, Any]]:
|
||||||
"""Fetch data from API endpoint.
|
"""Fetch data from API endpoint.
|
||||||
|
|
||||||
This is the place to pre-process the data to lookup tables
|
This is the place to pre-process the data to lookup tables
|
||||||
@ -132,12 +134,14 @@ async def async_setup_entry(
|
|||||||
async_add_entities(entities)
|
async_add_entities(entities)
|
||||||
|
|
||||||
|
|
||||||
class OndiloICO(CoordinatorEntity, SensorEntity):
|
class OndiloICO(
|
||||||
|
CoordinatorEntity[DataUpdateCoordinator[list[dict[str, Any]]]], SensorEntity
|
||||||
|
):
|
||||||
"""Representation of a Sensor."""
|
"""Representation of a Sensor."""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
coordinator: DataUpdateCoordinator,
|
coordinator: DataUpdateCoordinator[list[dict[str, Any]]],
|
||||||
poolidx: int,
|
poolidx: int,
|
||||||
description: SensorEntityDescription,
|
description: SensorEntityDescription,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user