Update typing 07 (#48057)
This commit is contained in:
parent
08db262972
commit
9e1a6610dc
32 changed files with 185 additions and 142 deletions
|
@ -1,6 +1,8 @@
|
|||
"""Platform for Garmin Connect integration."""
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
from typing import Any, Dict
|
||||
from typing import Any
|
||||
|
||||
from garminconnect import (
|
||||
GarminConnectAuthenticationError,
|
||||
|
@ -136,7 +138,7 @@ class GarminConnectSensor(Entity):
|
|||
return attributes
|
||||
|
||||
@property
|
||||
def device_info(self) -> Dict[str, Any]:
|
||||
def device_info(self) -> dict[str, Any]:
|
||||
"""Return device information."""
|
||||
return {
|
||||
"identifiers": {(DOMAIN, self._unique_id)},
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
"""Geolocation support for GDACS Feed."""
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
from typing import Optional
|
||||
|
||||
from homeassistant.components.geo_location import GeolocationEvent
|
||||
from homeassistant.const import (
|
||||
|
@ -169,7 +170,7 @@ class GdacsEvent(GeolocationEvent):
|
|||
self._version = feed_entry.version
|
||||
|
||||
@property
|
||||
def unique_id(self) -> Optional[str]:
|
||||
def unique_id(self) -> str | None:
|
||||
"""Return a unique ID containing latitude/longitude and external id."""
|
||||
return f"{self._integration_id}_{self._external_id}"
|
||||
|
||||
|
@ -186,22 +187,22 @@ class GdacsEvent(GeolocationEvent):
|
|||
return SOURCE
|
||||
|
||||
@property
|
||||
def name(self) -> Optional[str]:
|
||||
def name(self) -> str | None:
|
||||
"""Return the name of the entity."""
|
||||
return self._title
|
||||
|
||||
@property
|
||||
def distance(self) -> Optional[float]:
|
||||
def distance(self) -> float | None:
|
||||
"""Return distance value of this external event."""
|
||||
return self._distance
|
||||
|
||||
@property
|
||||
def latitude(self) -> Optional[float]:
|
||||
def latitude(self) -> float | None:
|
||||
"""Return latitude value of this external event."""
|
||||
return self._latitude
|
||||
|
||||
@property
|
||||
def longitude(self) -> Optional[float]:
|
||||
def longitude(self) -> float | None:
|
||||
"""Return longitude value of this external event."""
|
||||
return self._longitude
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
"""Feed Entity Manager Sensor support for GDACS Feed."""
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
from typing import Optional
|
||||
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
|
@ -109,12 +110,12 @@ class GdacsSensor(Entity):
|
|||
return self._total
|
||||
|
||||
@property
|
||||
def unique_id(self) -> Optional[str]:
|
||||
def unique_id(self) -> str | None:
|
||||
"""Return a unique ID containing latitude/longitude."""
|
||||
return self._config_unique_id
|
||||
|
||||
@property
|
||||
def name(self) -> Optional[str]:
|
||||
def name(self) -> str | None:
|
||||
"""Return the name of the entity."""
|
||||
return f"GDACS ({self._config_title})"
|
||||
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
"""Support for a Genius Hub system."""
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import timedelta
|
||||
import logging
|
||||
from typing import Any, Dict, Optional
|
||||
from typing import Any
|
||||
|
||||
import aiohttp
|
||||
from geniushubclient import GeniusHub
|
||||
|
@ -218,12 +220,12 @@ class GeniusEntity(Entity):
|
|||
"""Set up a listener when this entity is added to HA."""
|
||||
self.async_on_remove(async_dispatcher_connect(self.hass, DOMAIN, self._refresh))
|
||||
|
||||
async def _refresh(self, payload: Optional[dict] = None) -> None:
|
||||
async def _refresh(self, payload: dict | None = None) -> None:
|
||||
"""Process any signals."""
|
||||
self.async_schedule_update_ha_state(force_refresh=True)
|
||||
|
||||
@property
|
||||
def unique_id(self) -> Optional[str]:
|
||||
def unique_id(self) -> str | None:
|
||||
"""Return a unique ID."""
|
||||
return self._unique_id
|
||||
|
||||
|
@ -250,7 +252,7 @@ class GeniusDevice(GeniusEntity):
|
|||
self._last_comms = self._state_attr = None
|
||||
|
||||
@property
|
||||
def extra_state_attributes(self) -> Dict[str, Any]:
|
||||
def extra_state_attributes(self) -> dict[str, Any]:
|
||||
"""Return the device state attributes."""
|
||||
attrs = {}
|
||||
attrs["assigned_zone"] = self._device.data["assignedZones"][0]["name"]
|
||||
|
@ -285,7 +287,7 @@ class GeniusZone(GeniusEntity):
|
|||
self._zone = zone
|
||||
self._unique_id = f"{broker.hub_uid}_zone_{zone.id}"
|
||||
|
||||
async def _refresh(self, payload: Optional[dict] = None) -> None:
|
||||
async def _refresh(self, payload: dict | None = None) -> None:
|
||||
"""Process any signals."""
|
||||
if payload is None:
|
||||
self.async_schedule_update_ha_state(force_refresh=True)
|
||||
|
@ -317,7 +319,7 @@ class GeniusZone(GeniusEntity):
|
|||
return self._zone.name
|
||||
|
||||
@property
|
||||
def extra_state_attributes(self) -> Dict[str, Any]:
|
||||
def extra_state_attributes(self) -> dict[str, Any]:
|
||||
"""Return the device state attributes."""
|
||||
status = {k: v for k, v in self._zone.data.items() if k in GH_ZONE_ATTRS}
|
||||
return {"status": status}
|
||||
|
@ -333,7 +335,7 @@ class GeniusHeatingZone(GeniusZone):
|
|||
self._max_temp = self._min_temp = self._supported_features = None
|
||||
|
||||
@property
|
||||
def current_temperature(self) -> Optional[float]:
|
||||
def current_temperature(self) -> float | None:
|
||||
"""Return the current temperature."""
|
||||
return self._zone.data.get("temperature")
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
"""Support for Genius Hub climate devices."""
|
||||
from typing import List, Optional
|
||||
from __future__ import annotations
|
||||
|
||||
from homeassistant.components.climate import ClimateEntity
|
||||
from homeassistant.components.climate.const import (
|
||||
|
@ -67,12 +67,12 @@ class GeniusClimateZone(GeniusHeatingZone, ClimateEntity):
|
|||
return GH_HVAC_TO_HA.get(self._zone.data["mode"], HVAC_MODE_HEAT)
|
||||
|
||||
@property
|
||||
def hvac_modes(self) -> List[str]:
|
||||
def hvac_modes(self) -> list[str]:
|
||||
"""Return the list of available hvac operation modes."""
|
||||
return list(HA_HVAC_TO_GH)
|
||||
|
||||
@property
|
||||
def hvac_action(self) -> Optional[str]:
|
||||
def hvac_action(self) -> str | None:
|
||||
"""Return the current running hvac operation if supported."""
|
||||
if "_state" in self._zone.data: # only for v3 API
|
||||
if not self._zone.data["_state"].get("bIsActive"):
|
||||
|
@ -83,12 +83,12 @@ class GeniusClimateZone(GeniusHeatingZone, ClimateEntity):
|
|||
return None
|
||||
|
||||
@property
|
||||
def preset_mode(self) -> Optional[str]:
|
||||
def preset_mode(self) -> str | None:
|
||||
"""Return the current preset mode, e.g., home, away, temp."""
|
||||
return GH_PRESET_TO_HA.get(self._zone.data["mode"])
|
||||
|
||||
@property
|
||||
def preset_modes(self) -> Optional[List[str]]:
|
||||
def preset_modes(self) -> list[str] | None:
|
||||
"""Return a list of available preset modes."""
|
||||
if "occupied" in self._zone.data: # if has a movement sensor
|
||||
return [PRESET_ACTIVITY, PRESET_BOOST]
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
"""Support for Genius Hub sensor devices."""
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import timedelta
|
||||
from typing import Any, Dict
|
||||
from typing import Any
|
||||
|
||||
from homeassistant.const import DEVICE_CLASS_BATTERY, PERCENTAGE
|
||||
from homeassistant.helpers.typing import ConfigType, HomeAssistantType
|
||||
|
@ -106,7 +108,7 @@ class GeniusIssue(GeniusEntity):
|
|||
return len(self._issues)
|
||||
|
||||
@property
|
||||
def extra_state_attributes(self) -> Dict[str, Any]:
|
||||
def extra_state_attributes(self) -> dict[str, Any]:
|
||||
"""Return the device state attributes."""
|
||||
return {f"{self._level}_list": self._issues}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
"""Support for Genius Hub water_heater devices."""
|
||||
from typing import List
|
||||
from __future__ import annotations
|
||||
|
||||
from homeassistant.components.water_heater import (
|
||||
SUPPORT_OPERATION_MODE,
|
||||
|
@ -61,7 +61,7 @@ class GeniusWaterHeater(GeniusHeatingZone, WaterHeaterEntity):
|
|||
self._supported_features = SUPPORT_TARGET_TEMPERATURE | SUPPORT_OPERATION_MODE
|
||||
|
||||
@property
|
||||
def operation_list(self) -> List[str]:
|
||||
def operation_list(self) -> list[str]:
|
||||
"""Return the list of available operation modes."""
|
||||
return list(HA_OPMODE_TO_GH)
|
||||
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
"""Support for generic GeoJSON events."""
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import timedelta
|
||||
import logging
|
||||
from typing import Optional
|
||||
|
||||
from geojson_client.generic_feed import GenericFeedManager
|
||||
import voluptuous as vol
|
||||
|
@ -176,22 +177,22 @@ class GeoJsonLocationEvent(GeolocationEvent):
|
|||
return SOURCE
|
||||
|
||||
@property
|
||||
def name(self) -> Optional[str]:
|
||||
def name(self) -> str | None:
|
||||
"""Return the name of the entity."""
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def distance(self) -> Optional[float]:
|
||||
def distance(self) -> float | None:
|
||||
"""Return distance value of this external event."""
|
||||
return self._distance
|
||||
|
||||
@property
|
||||
def latitude(self) -> Optional[float]:
|
||||
def latitude(self) -> float | None:
|
||||
"""Return latitude value of this external event."""
|
||||
return self._latitude
|
||||
|
||||
@property
|
||||
def longitude(self) -> Optional[float]:
|
||||
def longitude(self) -> float | None:
|
||||
"""Return longitude value of this external event."""
|
||||
return self._longitude
|
||||
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
"""Support for Geolocation."""
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import timedelta
|
||||
import logging
|
||||
from typing import Optional
|
||||
|
||||
from homeassistant.const import ATTR_LATITUDE, ATTR_LONGITUDE
|
||||
from homeassistant.helpers.config_validation import ( # noqa: F401
|
||||
|
@ -60,17 +61,17 @@ class GeolocationEvent(Entity):
|
|||
raise NotImplementedError
|
||||
|
||||
@property
|
||||
def distance(self) -> Optional[float]:
|
||||
def distance(self) -> float | None:
|
||||
"""Return distance value of this external event."""
|
||||
return None
|
||||
|
||||
@property
|
||||
def latitude(self) -> Optional[float]:
|
||||
def latitude(self) -> float | None:
|
||||
"""Return latitude value of this external event."""
|
||||
return None
|
||||
|
||||
@property
|
||||
def longitude(self) -> Optional[float]:
|
||||
def longitude(self) -> float | None:
|
||||
"""Return longitude value of this external event."""
|
||||
return None
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
"""Geolocation support for GeoNet NZ Quakes Feeds."""
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
from typing import Optional
|
||||
|
||||
from homeassistant.components.geo_location import GeolocationEvent
|
||||
from homeassistant.const import (
|
||||
|
@ -142,7 +143,7 @@ class GeonetnzQuakesEvent(GeolocationEvent):
|
|||
self._time = feed_entry.time
|
||||
|
||||
@property
|
||||
def unique_id(self) -> Optional[str]:
|
||||
def unique_id(self) -> str | None:
|
||||
"""Return a unique ID containing latitude/longitude and external id."""
|
||||
return f"{self._integration_id}_{self._external_id}"
|
||||
|
||||
|
@ -157,22 +158,22 @@ class GeonetnzQuakesEvent(GeolocationEvent):
|
|||
return SOURCE
|
||||
|
||||
@property
|
||||
def name(self) -> Optional[str]:
|
||||
def name(self) -> str | None:
|
||||
"""Return the name of the entity."""
|
||||
return self._title
|
||||
|
||||
@property
|
||||
def distance(self) -> Optional[float]:
|
||||
def distance(self) -> float | None:
|
||||
"""Return distance value of this external event."""
|
||||
return self._distance
|
||||
|
||||
@property
|
||||
def latitude(self) -> Optional[float]:
|
||||
def latitude(self) -> float | None:
|
||||
"""Return latitude value of this external event."""
|
||||
return self._latitude
|
||||
|
||||
@property
|
||||
def longitude(self) -> Optional[float]:
|
||||
def longitude(self) -> float | None:
|
||||
"""Return longitude value of this external event."""
|
||||
return self._longitude
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
"""Feed Entity Manager Sensor support for GeoNet NZ Quakes Feeds."""
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
from typing import Optional
|
||||
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
|
@ -115,7 +116,7 @@ class GeonetnzQuakesSensor(Entity):
|
|||
return self._config_unique_id
|
||||
|
||||
@property
|
||||
def name(self) -> Optional[str]:
|
||||
def name(self) -> str | None:
|
||||
"""Return the name of the entity."""
|
||||
return f"GeoNet NZ Quakes ({self._config_title})"
|
||||
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
"""The GeoNet NZ Volcano integration."""
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
from datetime import datetime, timedelta
|
||||
import logging
|
||||
from typing import Optional
|
||||
|
||||
from aio_geojson_geonetnz_volcano import GeonetnzVolcanoFeedManager
|
||||
import voluptuous as vol
|
||||
|
@ -172,11 +173,11 @@ class GeonetnzVolcanoFeedEntityManager:
|
|||
"""Get feed entry by external id."""
|
||||
return self._feed_manager.feed_entries.get(external_id)
|
||||
|
||||
def last_update(self) -> Optional[datetime]:
|
||||
def last_update(self) -> datetime | None:
|
||||
"""Return the last update of this feed."""
|
||||
return self._feed_manager.last_update
|
||||
|
||||
def last_update_successful(self) -> Optional[datetime]:
|
||||
def last_update_successful(self) -> datetime | None:
|
||||
"""Return the last successful update of this feed."""
|
||||
return self._feed_manager.last_update_successful
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
"""Feed Entity Manager Sensor support for GeoNet NZ Volcano Feeds."""
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
from typing import Optional
|
||||
|
||||
from homeassistant.const import (
|
||||
ATTR_ATTRIBUTION,
|
||||
|
@ -139,7 +140,7 @@ class GeonetnzVolcanoSensor(Entity):
|
|||
return DEFAULT_ICON
|
||||
|
||||
@property
|
||||
def name(self) -> Optional[str]:
|
||||
def name(self) -> str | None:
|
||||
"""Return the name of the entity."""
|
||||
return f"Volcano {self._title}"
|
||||
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
"""Common code for GogoGate2 component."""
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import timedelta
|
||||
import logging
|
||||
from typing import Awaitable, Callable, NamedTuple, Optional
|
||||
from typing import Awaitable, Callable, NamedTuple
|
||||
|
||||
from gogogate2_api import AbstractGateApi, GogoGate2Api, ISmartGateApi
|
||||
from gogogate2_api.common import AbstractDoor, get_door_by_id
|
||||
|
@ -30,8 +32,8 @@ class StateData(NamedTuple):
|
|||
"""State data for a cover entity."""
|
||||
|
||||
config_unique_id: str
|
||||
unique_id: Optional[str]
|
||||
door: Optional[AbstractDoor]
|
||||
unique_id: str | None
|
||||
door: AbstractDoor | None
|
||||
|
||||
|
||||
class DeviceDataUpdateCoordinator(DataUpdateCoordinator):
|
||||
|
@ -45,8 +47,8 @@ class DeviceDataUpdateCoordinator(DataUpdateCoordinator):
|
|||
*,
|
||||
name: str,
|
||||
update_interval: timedelta,
|
||||
update_method: Optional[Callable[[], Awaitable]] = None,
|
||||
request_refresh_debouncer: Optional[Debouncer] = None,
|
||||
update_method: Callable[[], Awaitable] | None = None,
|
||||
request_refresh_debouncer: Debouncer | None = None,
|
||||
):
|
||||
"""Initialize the data update coordinator."""
|
||||
DataUpdateCoordinator.__init__(
|
||||
|
@ -78,7 +80,7 @@ class GoGoGate2Entity(CoordinatorEntity):
|
|||
self._unique_id = unique_id
|
||||
|
||||
@property
|
||||
def unique_id(self) -> Optional[str]:
|
||||
def unique_id(self) -> str | None:
|
||||
"""Return a unique ID."""
|
||||
return self._unique_id
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
"""Support for Gogogate2 garage Doors."""
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
from typing import Callable, List, Optional
|
||||
from typing import Callable
|
||||
|
||||
from gogogate2_api.common import AbstractDoor, DoorStatus, get_configured_doors
|
||||
|
||||
|
@ -44,7 +46,7 @@ async def async_setup_platform(
|
|||
async def async_setup_entry(
|
||||
hass: HomeAssistant,
|
||||
config_entry: ConfigEntry,
|
||||
async_add_entities: Callable[[List[Entity], Optional[bool]], None],
|
||||
async_add_entities: Callable[[list[Entity], bool | None], None],
|
||||
) -> None:
|
||||
"""Set up the config entry."""
|
||||
data_update_coordinator = get_data_update_coordinator(hass, config_entry)
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
"""Support for Gogogate2 garage Doors."""
|
||||
from __future__ import annotations
|
||||
|
||||
from itertools import chain
|
||||
from typing import Callable, List, Optional
|
||||
from typing import Callable
|
||||
|
||||
from gogogate2_api.common import AbstractDoor, get_configured_doors
|
||||
|
||||
|
@ -26,7 +28,7 @@ SENSOR_ID_WIRED = "WIRE"
|
|||
async def async_setup_entry(
|
||||
hass: HomeAssistant,
|
||||
config_entry: ConfigEntry,
|
||||
async_add_entities: Callable[[List[Entity], Optional[bool]], None],
|
||||
async_add_entities: Callable[[list[Entity], bool | None], None],
|
||||
) -> None:
|
||||
"""Set up the config entry."""
|
||||
data_update_coordinator = get_data_update_coordinator(hass, config_entry)
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
"""Support for Actions on Google Assistant Smart Home Control."""
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
from typing import Any, Dict
|
||||
from typing import Any
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
|
@ -87,7 +89,7 @@ GOOGLE_ASSISTANT_SCHEMA = vol.All(
|
|||
CONFIG_SCHEMA = vol.Schema({DOMAIN: GOOGLE_ASSISTANT_SCHEMA}, extra=vol.ALLOW_EXTRA)
|
||||
|
||||
|
||||
async def async_setup(hass: HomeAssistant, yaml_config: Dict[str, Any]):
|
||||
async def async_setup(hass: HomeAssistant, yaml_config: dict[str, Any]):
|
||||
"""Activate Google Actions component."""
|
||||
config = yaml_config.get(DOMAIN, {})
|
||||
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
"""Helper classes for Google Assistant integration."""
|
||||
from __future__ import annotations
|
||||
|
||||
from abc import ABC, abstractmethod
|
||||
from asyncio import gather
|
||||
from collections.abc import Mapping
|
||||
import logging
|
||||
import pprint
|
||||
from typing import Dict, List, Optional, Tuple
|
||||
|
||||
from aiohttp.web import json_response
|
||||
|
||||
|
@ -44,7 +45,7 @@ _LOGGER = logging.getLogger(__name__)
|
|||
|
||||
async def _get_entity_and_device(
|
||||
hass, entity_id
|
||||
) -> Optional[Tuple[RegistryEntry, DeviceEntry]]:
|
||||
) -> tuple[RegistryEntry, DeviceEntry] | None:
|
||||
"""Fetch the entity and device entries for a entity_id."""
|
||||
dev_reg, ent_reg = await gather(
|
||||
hass.helpers.device_registry.async_get_registry(),
|
||||
|
@ -58,7 +59,7 @@ async def _get_entity_and_device(
|
|||
return entity_entry, device_entry
|
||||
|
||||
|
||||
async def _get_area(hass, entity_entry, device_entry) -> Optional[AreaEntry]:
|
||||
async def _get_area(hass, entity_entry, device_entry) -> AreaEntry | None:
|
||||
"""Calculate the area for an entity."""
|
||||
if entity_entry and entity_entry.area_id:
|
||||
area_id = entity_entry.area_id
|
||||
|
@ -71,7 +72,7 @@ async def _get_area(hass, entity_entry, device_entry) -> Optional[AreaEntry]:
|
|||
return area_reg.areas.get(area_id)
|
||||
|
||||
|
||||
async def _get_device_info(device_entry) -> Optional[Dict[str, str]]:
|
||||
async def _get_device_info(device_entry) -> dict[str, str] | None:
|
||||
"""Retrieve the device info for a device."""
|
||||
if not device_entry:
|
||||
return None
|
||||
|
@ -344,7 +345,7 @@ class RequestData:
|
|||
user_id: str,
|
||||
source: str,
|
||||
request_id: str,
|
||||
devices: Optional[List[dict]],
|
||||
devices: list[dict] | None,
|
||||
):
|
||||
"""Initialize the request data."""
|
||||
self.config = config
|
||||
|
@ -578,7 +579,7 @@ def deep_update(target, source):
|
|||
|
||||
|
||||
@callback
|
||||
def async_get_entities(hass, config) -> List[GoogleEntity]:
|
||||
def async_get_entities(hass, config) -> list[GoogleEntity]:
|
||||
"""Return all entities that are supported by Google."""
|
||||
entities = []
|
||||
for state in hass.states.async_all():
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
"""Implement the Google Smart Home traits."""
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
from typing import List, Optional
|
||||
|
||||
from homeassistant.components import (
|
||||
alarm_control_panel,
|
||||
|
@ -153,7 +154,7 @@ def _google_temp_unit(units):
|
|||
return "C"
|
||||
|
||||
|
||||
def _next_selected(items: List[str], selected: Optional[str]) -> Optional[str]:
|
||||
def _next_selected(items: list[str], selected: str | None) -> str | None:
|
||||
"""Return the next item in a item list starting at given value.
|
||||
|
||||
If selected is missing in items, None is returned
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
"""Support for Google Cloud Pub/Sub."""
|
||||
from __future__ import annotations
|
||||
|
||||
import datetime
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
from typing import Any, Dict
|
||||
from typing import Any
|
||||
|
||||
from google.cloud import pubsub_v1
|
||||
import voluptuous as vol
|
||||
|
@ -37,7 +39,7 @@ CONFIG_SCHEMA = vol.Schema(
|
|||
)
|
||||
|
||||
|
||||
def setup(hass: HomeAssistant, yaml_config: Dict[str, Any]):
|
||||
def setup(hass: HomeAssistant, yaml_config: dict[str, Any]):
|
||||
"""Activate Google Pub/Sub component."""
|
||||
|
||||
config = yaml_config[DOMAIN]
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
"""Helper and wrapper classes for Gree module."""
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import timedelta
|
||||
import logging
|
||||
from typing import List
|
||||
|
||||
from greeclimate.device import Device, DeviceInfo
|
||||
from greeclimate.discovery import Discovery
|
||||
|
@ -86,7 +87,7 @@ class DeviceHelper:
|
|||
return device
|
||||
|
||||
@staticmethod
|
||||
async def find_devices() -> List[DeviceInfo]:
|
||||
async def find_devices() -> list[DeviceInfo]:
|
||||
"""Gather a list of device infos from the local network."""
|
||||
return await Discovery.search_devices()
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
"""Support for interface with a Gree climate systems."""
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
from typing import List
|
||||
|
||||
from greeclimate.device import (
|
||||
FanSpeed,
|
||||
|
@ -234,7 +235,7 @@ class GreeClimateEntity(CoordinatorEntity, ClimateEntity):
|
|||
self.async_write_ha_state()
|
||||
|
||||
@property
|
||||
def hvac_modes(self) -> List[str]:
|
||||
def hvac_modes(self) -> list[str]:
|
||||
"""Return the HVAC modes support by the device."""
|
||||
modes = [*HVAC_MODES_REVERSE]
|
||||
modes.append(HVAC_MODE_OFF)
|
||||
|
@ -282,7 +283,7 @@ class GreeClimateEntity(CoordinatorEntity, ClimateEntity):
|
|||
self.async_write_ha_state()
|
||||
|
||||
@property
|
||||
def preset_modes(self) -> List[str]:
|
||||
def preset_modes(self) -> list[str]:
|
||||
"""Return the preset modes support by the device."""
|
||||
return PRESET_MODES
|
||||
|
||||
|
@ -302,7 +303,7 @@ class GreeClimateEntity(CoordinatorEntity, ClimateEntity):
|
|||
self.async_write_ha_state()
|
||||
|
||||
@property
|
||||
def fan_modes(self) -> List[str]:
|
||||
def fan_modes(self) -> list[str]:
|
||||
"""Return the fan modes support by the device."""
|
||||
return [*FAN_MODES_REVERSE]
|
||||
|
||||
|
@ -342,7 +343,7 @@ class GreeClimateEntity(CoordinatorEntity, ClimateEntity):
|
|||
self.async_write_ha_state()
|
||||
|
||||
@property
|
||||
def swing_modes(self) -> List[str]:
|
||||
def swing_modes(self) -> list[str]:
|
||||
"""Return the swing modes currently supported for this device."""
|
||||
return SWING_MODES
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
"""Support for interface with a Gree climate systems."""
|
||||
from typing import Optional
|
||||
from __future__ import annotations
|
||||
|
||||
from homeassistant.components.switch import DEVICE_CLASS_SWITCH, SwitchEntity
|
||||
from homeassistant.helpers.device_registry import CONNECTION_NETWORK_MAC
|
||||
|
@ -38,7 +38,7 @@ class GreeSwitchEntity(CoordinatorEntity, SwitchEntity):
|
|||
return f"{self._mac}-panel-light"
|
||||
|
||||
@property
|
||||
def icon(self) -> Optional[str]:
|
||||
def icon(self) -> str | None:
|
||||
"""Return the icon for the device."""
|
||||
return "mdi:lightbulb"
|
||||
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
"""Provide the functionality to group entities."""
|
||||
from __future__ import annotations
|
||||
|
||||
from abc import abstractmethod
|
||||
import asyncio
|
||||
from contextvars import ContextVar
|
||||
import logging
|
||||
from typing import Any, Dict, Iterable, List, Optional, Set, cast
|
||||
from typing import Any, Iterable, List, cast
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
|
@ -91,16 +93,16 @@ CONFIG_SCHEMA = vol.Schema(
|
|||
class GroupIntegrationRegistry:
|
||||
"""Class to hold a registry of integrations."""
|
||||
|
||||
on_off_mapping: Dict[str, str] = {STATE_ON: STATE_OFF}
|
||||
off_on_mapping: Dict[str, str] = {STATE_OFF: STATE_ON}
|
||||
on_states_by_domain: Dict[str, Set] = {}
|
||||
exclude_domains: Set = set()
|
||||
on_off_mapping: dict[str, str] = {STATE_ON: STATE_OFF}
|
||||
off_on_mapping: dict[str, str] = {STATE_OFF: STATE_ON}
|
||||
on_states_by_domain: dict[str, set] = {}
|
||||
exclude_domains: set = set()
|
||||
|
||||
def exclude_domain(self) -> None:
|
||||
"""Exclude the current domain."""
|
||||
self.exclude_domains.add(current_domain.get())
|
||||
|
||||
def on_off_states(self, on_states: Set, off_state: str) -> None:
|
||||
def on_off_states(self, on_states: set, off_state: str) -> None:
|
||||
"""Register on and off states for the current domain."""
|
||||
for on_state in on_states:
|
||||
if on_state not in self.on_off_mapping:
|
||||
|
@ -128,12 +130,12 @@ def is_on(hass, entity_id):
|
|||
|
||||
|
||||
@bind_hass
|
||||
def expand_entity_ids(hass: HomeAssistantType, entity_ids: Iterable[Any]) -> List[str]:
|
||||
def expand_entity_ids(hass: HomeAssistantType, entity_ids: Iterable[Any]) -> list[str]:
|
||||
"""Return entity_ids with group entity ids replaced by their members.
|
||||
|
||||
Async friendly.
|
||||
"""
|
||||
found_ids: List[str] = []
|
||||
found_ids: list[str] = []
|
||||
for entity_id in entity_ids:
|
||||
if not isinstance(entity_id, str) or entity_id in (
|
||||
ENTITY_MATCH_NONE,
|
||||
|
@ -171,8 +173,8 @@ def expand_entity_ids(hass: HomeAssistantType, entity_ids: Iterable[Any]) -> Lis
|
|||
|
||||
@bind_hass
|
||||
def get_entity_ids(
|
||||
hass: HomeAssistantType, entity_id: str, domain_filter: Optional[str] = None
|
||||
) -> List[str]:
|
||||
hass: HomeAssistantType, entity_id: str, domain_filter: str | None = None
|
||||
) -> list[str]:
|
||||
"""Get members of this group.
|
||||
|
||||
Async friendly.
|
||||
|
@ -192,7 +194,7 @@ def get_entity_ids(
|
|||
|
||||
|
||||
@bind_hass
|
||||
def groups_with_entity(hass: HomeAssistantType, entity_id: str) -> List[str]:
|
||||
def groups_with_entity(hass: HomeAssistantType, entity_id: str) -> list[str]:
|
||||
"""Get all groups that contain this entity.
|
||||
|
||||
Async friendly.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
"""This platform allows several cover to be grouped into one cover."""
|
||||
from typing import Dict, Optional, Set
|
||||
from __future__ import annotations
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
|
@ -76,18 +76,18 @@ class CoverGroup(GroupEntity, CoverEntity):
|
|||
self._is_closed = False
|
||||
self._is_closing = False
|
||||
self._is_opening = False
|
||||
self._cover_position: Optional[int] = 100
|
||||
self._cover_position: int | None = 100
|
||||
self._tilt_position = None
|
||||
self._supported_features = 0
|
||||
self._assumed_state = True
|
||||
|
||||
self._entities = entities
|
||||
self._covers: Dict[str, Set[str]] = {
|
||||
self._covers: dict[str, set[str]] = {
|
||||
KEY_OPEN_CLOSE: set(),
|
||||
KEY_STOP: set(),
|
||||
KEY_POSITION: set(),
|
||||
}
|
||||
self._tilts: Dict[str, Set[str]] = {
|
||||
self._tilts: dict[str, set[str]] = {
|
||||
KEY_OPEN_CLOSE: set(),
|
||||
KEY_STOP: set(),
|
||||
KEY_POSITION: set(),
|
||||
|
@ -102,7 +102,7 @@ class CoverGroup(GroupEntity, CoverEntity):
|
|||
async def async_update_supported_features(
|
||||
self,
|
||||
entity_id: str,
|
||||
new_state: Optional[State],
|
||||
new_state: State | None,
|
||||
update_state: bool = True,
|
||||
) -> None:
|
||||
"""Update dictionaries with supported features."""
|
||||
|
@ -197,7 +197,7 @@ class CoverGroup(GroupEntity, CoverEntity):
|
|||
return self._is_closing
|
||||
|
||||
@property
|
||||
def current_cover_position(self) -> Optional[int]:
|
||||
def current_cover_position(self) -> int | None:
|
||||
"""Return current position for all covers."""
|
||||
return self._cover_position
|
||||
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
"""This platform allows several lights to be grouped into one light."""
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
from collections import Counter
|
||||
import itertools
|
||||
from typing import Any, Callable, Iterator, List, Optional, Tuple, cast
|
||||
from typing import Any, Callable, Iterator, cast
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
|
@ -78,21 +80,21 @@ async def async_setup_platform(
|
|||
class LightGroup(GroupEntity, light.LightEntity):
|
||||
"""Representation of a light group."""
|
||||
|
||||
def __init__(self, name: str, entity_ids: List[str]) -> None:
|
||||
def __init__(self, name: str, entity_ids: list[str]) -> None:
|
||||
"""Initialize a light group."""
|
||||
self._name = name
|
||||
self._entity_ids = entity_ids
|
||||
self._is_on = False
|
||||
self._available = False
|
||||
self._icon = "mdi:lightbulb-group"
|
||||
self._brightness: Optional[int] = None
|
||||
self._hs_color: Optional[Tuple[float, float]] = None
|
||||
self._color_temp: Optional[int] = None
|
||||
self._brightness: int | None = None
|
||||
self._hs_color: tuple[float, float] | None = None
|
||||
self._color_temp: int | None = None
|
||||
self._min_mireds: int = 154
|
||||
self._max_mireds: int = 500
|
||||
self._white_value: Optional[int] = None
|
||||
self._effect_list: Optional[List[str]] = None
|
||||
self._effect: Optional[str] = None
|
||||
self._white_value: int | None = None
|
||||
self._effect_list: list[str] | None = None
|
||||
self._effect: str | None = None
|
||||
self._supported_features: int = 0
|
||||
|
||||
async def async_added_to_hass(self) -> None:
|
||||
|
@ -136,17 +138,17 @@ class LightGroup(GroupEntity, light.LightEntity):
|
|||
return self._icon
|
||||
|
||||
@property
|
||||
def brightness(self) -> Optional[int]:
|
||||
def brightness(self) -> int | None:
|
||||
"""Return the brightness of this light group between 0..255."""
|
||||
return self._brightness
|
||||
|
||||
@property
|
||||
def hs_color(self) -> Optional[Tuple[float, float]]:
|
||||
def hs_color(self) -> tuple[float, float] | None:
|
||||
"""Return the HS color value [float, float]."""
|
||||
return self._hs_color
|
||||
|
||||
@property
|
||||
def color_temp(self) -> Optional[int]:
|
||||
def color_temp(self) -> int | None:
|
||||
"""Return the CT color value in mireds."""
|
||||
return self._color_temp
|
||||
|
||||
|
@ -161,17 +163,17 @@ class LightGroup(GroupEntity, light.LightEntity):
|
|||
return self._max_mireds
|
||||
|
||||
@property
|
||||
def white_value(self) -> Optional[int]:
|
||||
def white_value(self) -> int | None:
|
||||
"""Return the white value of this light group between 0..255."""
|
||||
return self._white_value
|
||||
|
||||
@property
|
||||
def effect_list(self) -> Optional[List[str]]:
|
||||
def effect_list(self) -> list[str] | None:
|
||||
"""Return the list of supported effects."""
|
||||
return self._effect_list
|
||||
|
||||
@property
|
||||
def effect(self) -> Optional[str]:
|
||||
def effect(self) -> str | None:
|
||||
"""Return the current effect."""
|
||||
return self._effect
|
||||
|
||||
|
@ -288,7 +290,7 @@ class LightGroup(GroupEntity, light.LightEntity):
|
|||
async def async_update(self):
|
||||
"""Query all members and determine the light group state."""
|
||||
all_states = [self.hass.states.get(x) for x in self._entity_ids]
|
||||
states: List[State] = list(filter(None, all_states))
|
||||
states: list[State] = list(filter(None, all_states))
|
||||
on_states = [state for state in states if state.state == STATE_ON]
|
||||
|
||||
self._is_on = len(on_states) > 0
|
||||
|
@ -331,7 +333,7 @@ class LightGroup(GroupEntity, light.LightEntity):
|
|||
self._supported_features &= SUPPORT_GROUP_LIGHT
|
||||
|
||||
|
||||
def _find_state_attributes(states: List[State], key: str) -> Iterator[Any]:
|
||||
def _find_state_attributes(states: list[State], key: str) -> Iterator[Any]:
|
||||
"""Find attributes with matching key from states."""
|
||||
for state in states:
|
||||
value = state.attributes.get(key)
|
||||
|
@ -350,9 +352,9 @@ def _mean_tuple(*args):
|
|||
|
||||
|
||||
def _reduce_attribute(
|
||||
states: List[State],
|
||||
states: list[State],
|
||||
key: str,
|
||||
default: Optional[Any] = None,
|
||||
default: Any | None = None,
|
||||
reduce: Callable[..., Any] = _mean_int,
|
||||
) -> Any:
|
||||
"""Find the first attribute matching key from states.
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
"""Module that groups code required to handle state restore for component."""
|
||||
from typing import Any, Dict, Iterable, Optional
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any, Iterable
|
||||
|
||||
from homeassistant.core import Context, State
|
||||
from homeassistant.helpers.state import async_reproduce_state
|
||||
|
@ -12,8 +14,8 @@ async def async_reproduce_states(
|
|||
hass: HomeAssistantType,
|
||||
states: Iterable[State],
|
||||
*,
|
||||
context: Optional[Context] = None,
|
||||
reproduce_options: Optional[Dict[str, Any]] = None,
|
||||
context: Context | None = None,
|
||||
reproduce_options: dict[str, Any] | None = None,
|
||||
) -> None:
|
||||
"""Reproduce component states."""
|
||||
states_copy = []
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
"""Support for GTFS (Google/General Transport Format Schema)."""
|
||||
from __future__ import annotations
|
||||
|
||||
import datetime
|
||||
import logging
|
||||
import os
|
||||
import threading
|
||||
from typing import Any, Callable, Optional
|
||||
from typing import Any, Callable
|
||||
|
||||
import pygtfs
|
||||
from sqlalchemy.sql import text
|
||||
|
@ -484,7 +486,7 @@ def setup_platform(
|
|||
hass: HomeAssistantType,
|
||||
config: ConfigType,
|
||||
add_entities: Callable[[list], None],
|
||||
discovery_info: Optional[DiscoveryInfoType] = None,
|
||||
discovery_info: DiscoveryInfoType | None = None,
|
||||
) -> None:
|
||||
"""Set up the GTFS sensor."""
|
||||
gtfs_dir = hass.config.path(DEFAULT_PATH)
|
||||
|
@ -523,7 +525,7 @@ class GTFSDepartureSensor(Entity):
|
|||
def __init__(
|
||||
self,
|
||||
gtfs: Any,
|
||||
name: Optional[Any],
|
||||
name: Any | None,
|
||||
origin: Any,
|
||||
destination: Any,
|
||||
offset: cv.time_period,
|
||||
|
@ -540,7 +542,7 @@ class GTFSDepartureSensor(Entity):
|
|||
self._available = False
|
||||
self._icon = ICON
|
||||
self._name = ""
|
||||
self._state: Optional[str] = None
|
||||
self._state: str | None = None
|
||||
self._attributes = {}
|
||||
|
||||
self._agency = None
|
||||
|
@ -559,7 +561,7 @@ class GTFSDepartureSensor(Entity):
|
|||
return self._name
|
||||
|
||||
@property
|
||||
def state(self) -> Optional[str]: # type: ignore
|
||||
def state(self) -> str | None: # type: ignore
|
||||
"""Return the state of the sensor."""
|
||||
return self._state
|
||||
|
||||
|
@ -811,7 +813,7 @@ class GTFSDepartureSensor(Entity):
|
|||
col: getattr(resource, col) for col in resource.__table__.columns.keys()
|
||||
}
|
||||
|
||||
def append_keys(self, resource: dict, prefix: Optional[str] = None) -> None:
|
||||
def append_keys(self, resource: dict, prefix: str | None = None) -> None:
|
||||
"""Properly format key val pairs to append to attributes."""
|
||||
for attr, val in resource.items():
|
||||
if val == "" or val is None or attr == "feed_id":
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
"""The Elexa Guardian integration."""
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
from typing import Dict
|
||||
|
||||
from aioguardian import Client
|
||||
|
||||
|
@ -314,7 +315,7 @@ class ValveControllerEntity(GuardianEntity):
|
|||
def __init__(
|
||||
self,
|
||||
entry: ConfigEntry,
|
||||
coordinators: Dict[str, DataUpdateCoordinator],
|
||||
coordinators: dict[str, DataUpdateCoordinator],
|
||||
kind: str,
|
||||
name: str,
|
||||
device_class: str,
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
"""Binary sensors for the Elexa Guardian integration."""
|
||||
from typing import Callable, Dict, Optional
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Callable
|
||||
|
||||
from homeassistant.components.binary_sensor import (
|
||||
DEVICE_CLASS_CONNECTIVITY,
|
||||
|
@ -122,8 +124,8 @@ class PairedSensorBinarySensor(PairedSensorEntity, BinarySensorEntity):
|
|||
coordinator: DataUpdateCoordinator,
|
||||
kind: str,
|
||||
name: str,
|
||||
device_class: Optional[str],
|
||||
icon: Optional[str],
|
||||
device_class: str | None,
|
||||
icon: str | None,
|
||||
) -> None:
|
||||
"""Initialize."""
|
||||
super().__init__(entry, coordinator, kind, name, device_class, icon)
|
||||
|
@ -155,11 +157,11 @@ class ValveControllerBinarySensor(ValveControllerEntity, BinarySensorEntity):
|
|||
def __init__(
|
||||
self,
|
||||
entry: ConfigEntry,
|
||||
coordinators: Dict[str, DataUpdateCoordinator],
|
||||
coordinators: dict[str, DataUpdateCoordinator],
|
||||
kind: str,
|
||||
name: str,
|
||||
device_class: Optional[str],
|
||||
icon: Optional[str],
|
||||
device_class: str | None,
|
||||
icon: str | None,
|
||||
) -> None:
|
||||
"""Initialize."""
|
||||
super().__init__(entry, coordinators, kind, name, device_class, icon)
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
"""Sensors for the Elexa Guardian integration."""
|
||||
from typing import Callable, Dict, Optional
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Callable
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import (
|
||||
|
@ -117,9 +119,9 @@ class PairedSensorSensor(PairedSensorEntity):
|
|||
coordinator: DataUpdateCoordinator,
|
||||
kind: str,
|
||||
name: str,
|
||||
device_class: Optional[str],
|
||||
icon: Optional[str],
|
||||
unit: Optional[str],
|
||||
device_class: str | None,
|
||||
icon: str | None,
|
||||
unit: str | None,
|
||||
) -> None:
|
||||
"""Initialize."""
|
||||
super().__init__(entry, coordinator, kind, name, device_class, icon)
|
||||
|
@ -157,12 +159,12 @@ class ValveControllerSensor(ValveControllerEntity):
|
|||
def __init__(
|
||||
self,
|
||||
entry: ConfigEntry,
|
||||
coordinators: Dict[str, DataUpdateCoordinator],
|
||||
coordinators: dict[str, DataUpdateCoordinator],
|
||||
kind: str,
|
||||
name: str,
|
||||
device_class: Optional[str],
|
||||
icon: Optional[str],
|
||||
unit: Optional[str],
|
||||
device_class: str | None,
|
||||
icon: str | None,
|
||||
unit: str | None,
|
||||
) -> None:
|
||||
"""Initialize."""
|
||||
super().__init__(entry, coordinators, kind, name, device_class, icon)
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
"""Switches for the Elexa Guardian integration."""
|
||||
from typing import Callable, Dict
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Callable
|
||||
|
||||
from aioguardian import Client
|
||||
from aioguardian.errors import GuardianError
|
||||
|
@ -84,7 +86,7 @@ class ValveControllerSwitch(ValveControllerEntity, SwitchEntity):
|
|||
self,
|
||||
entry: ConfigEntry,
|
||||
client: Client,
|
||||
coordinators: Dict[str, DataUpdateCoordinator],
|
||||
coordinators: dict[str, DataUpdateCoordinator],
|
||||
):
|
||||
"""Initialize."""
|
||||
super().__init__(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue