mirror of
https://github.com/home-assistant/core.git
synced 2025-04-24 17:27:52 +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."""
|
||||
from asyncio import run_coroutine_threadsafe
|
||||
import logging
|
||||
from typing import Any
|
||||
|
||||
from ondilo import Ondilo
|
||||
|
||||
@ -35,7 +36,7 @@ class OndiloClient(Ondilo):
|
||||
|
||||
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."""
|
||||
|
||||
pools = self.get_pools()
|
||||
|
@ -3,6 +3,7 @@ from __future__ import annotations
|
||||
|
||||
from datetime import timedelta
|
||||
import logging
|
||||
from typing import Any
|
||||
|
||||
from ondilo import OndiloError
|
||||
|
||||
@ -28,6 +29,7 @@ from homeassistant.helpers.update_coordinator import (
|
||||
UpdateFailed,
|
||||
)
|
||||
|
||||
from .api import OndiloClient
|
||||
from .const import DOMAIN
|
||||
|
||||
SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
|
||||
@ -91,9 +93,9 @@ async def async_setup_entry(
|
||||
) -> None:
|
||||
"""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.
|
||||
|
||||
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)
|
||||
|
||||
|
||||
class OndiloICO(CoordinatorEntity, SensorEntity):
|
||||
class OndiloICO(
|
||||
CoordinatorEntity[DataUpdateCoordinator[list[dict[str, Any]]]], SensorEntity
|
||||
):
|
||||
"""Representation of a Sensor."""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
coordinator: DataUpdateCoordinator,
|
||||
coordinator: DataUpdateCoordinator[list[dict[str, Any]]],
|
||||
poolidx: int,
|
||||
description: SensorEntityDescription,
|
||||
) -> None:
|
||||
|
Loading…
x
Reference in New Issue
Block a user