mirror of
https://github.com/home-assistant/core.git
synced 2025-04-26 02:07:54 +00:00
Add basic type hints to homekit_controller (#62880)
Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
parent
3a3a6ed464
commit
1f35ad08e2
@ -14,9 +14,12 @@ from aiohomekit.model.characteristics import (
|
|||||||
from aiohomekit.model.services import Service, ServicesTypes
|
from aiohomekit.model.services import Service, ServicesTypes
|
||||||
|
|
||||||
from homeassistant.components import zeroconf
|
from homeassistant.components import zeroconf
|
||||||
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import ATTR_VIA_DEVICE, EVENT_HOMEASSISTANT_STOP
|
from homeassistant.const import ATTR_VIA_DEVICE, EVENT_HOMEASSISTANT_STOP
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.exceptions import ConfigEntryNotReady
|
from homeassistant.exceptions import ConfigEntryNotReady
|
||||||
from homeassistant.helpers.entity import DeviceInfo, Entity
|
from homeassistant.helpers.entity import DeviceInfo, Entity
|
||||||
|
from homeassistant.helpers.typing import ConfigType
|
||||||
|
|
||||||
from .config_flow import normalize_hkid
|
from .config_flow import normalize_hkid
|
||||||
from .connection import HKDevice, valid_serial_number
|
from .connection import HKDevice, valid_serial_number
|
||||||
@ -227,7 +230,7 @@ class CharacteristicEntity(HomeKitEntity):
|
|||||||
return f"homekit-{serial}-aid:{self._aid}-sid:{self._char.service.iid}-cid:{self._char.iid}"
|
return f"homekit-{serial}-aid:{self._aid}-sid:{self._char.service.iid}-cid:{self._char.iid}"
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(hass, entry):
|
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||||
"""Set up a HomeKit connection on a config entry."""
|
"""Set up a HomeKit connection on a config entry."""
|
||||||
conn = HKDevice(hass, entry, entry.data)
|
conn = HKDevice(hass, entry, entry.data)
|
||||||
hass.data[KNOWN_DEVICES][conn.unique_id] = conn
|
hass.data[KNOWN_DEVICES][conn.unique_id] = conn
|
||||||
@ -245,7 +248,7 @@ async def async_setup_entry(hass, entry):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
async def async_setup(hass, config):
|
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||||
"""Set up for Homekit devices."""
|
"""Set up for Homekit devices."""
|
||||||
map_storage = hass.data[ENTITY_MAP] = EntityMapStorage(hass)
|
map_storage = hass.data[ENTITY_MAP] = EntityMapStorage(hass)
|
||||||
await map_storage.async_initialize()
|
await map_storage.async_initialize()
|
||||||
@ -270,7 +273,7 @@ async def async_setup(hass, config):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
async def async_unload_entry(hass, entry):
|
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||||
"""Disconnect from HomeKit devices before unloading entry."""
|
"""Disconnect from HomeKit devices before unloading entry."""
|
||||||
hkid = entry.data["AccessoryPairingID"]
|
hkid = entry.data["AccessoryPairingID"]
|
||||||
|
|
||||||
@ -281,7 +284,7 @@ async def async_unload_entry(hass, entry):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
async def async_remove_entry(hass, entry):
|
async def async_remove_entry(hass: HomeAssistant, entry: ConfigEntry) -> None:
|
||||||
"""Cleanup caches before removing config entry."""
|
"""Cleanup caches before removing config entry."""
|
||||||
hkid = entry.data["AccessoryPairingID"]
|
hkid = entry.data["AccessoryPairingID"]
|
||||||
hass.data[ENTITY_MAP].async_delete_map(hkid)
|
hass.data[ENTITY_MAP].async_delete_map(hkid)
|
||||||
|
@ -8,6 +8,7 @@ from homeassistant.components.alarm_control_panel.const import (
|
|||||||
SUPPORT_ALARM_ARM_HOME,
|
SUPPORT_ALARM_ARM_HOME,
|
||||||
SUPPORT_ALARM_ARM_NIGHT,
|
SUPPORT_ALARM_ARM_NIGHT,
|
||||||
)
|
)
|
||||||
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
ATTR_BATTERY_LEVEL,
|
ATTR_BATTERY_LEVEL,
|
||||||
STATE_ALARM_ARMED_AWAY,
|
STATE_ALARM_ARMED_AWAY,
|
||||||
@ -16,7 +17,8 @@ from homeassistant.const import (
|
|||||||
STATE_ALARM_DISARMED,
|
STATE_ALARM_DISARMED,
|
||||||
STATE_ALARM_TRIGGERED,
|
STATE_ALARM_TRIGGERED,
|
||||||
)
|
)
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from . import KNOWN_DEVICES, HomeKitEntity
|
from . import KNOWN_DEVICES, HomeKitEntity
|
||||||
|
|
||||||
@ -38,7 +40,11 @@ TARGET_STATE_MAP = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(hass, config_entry, async_add_entities):
|
async def async_setup_entry(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
config_entry: ConfigEntry,
|
||||||
|
async_add_entities: AddEntitiesCallback,
|
||||||
|
) -> None:
|
||||||
"""Set up Homekit alarm control panel."""
|
"""Set up Homekit alarm control panel."""
|
||||||
hkid = config_entry.data["AccessoryPairingID"]
|
hkid = config_entry.data["AccessoryPairingID"]
|
||||||
conn = hass.data[KNOWN_DEVICES][hkid]
|
conn = hass.data[KNOWN_DEVICES][hkid]
|
||||||
|
@ -6,7 +6,9 @@ from homeassistant.components.binary_sensor import (
|
|||||||
BinarySensorDeviceClass,
|
BinarySensorDeviceClass,
|
||||||
BinarySensorEntity,
|
BinarySensorEntity,
|
||||||
)
|
)
|
||||||
from homeassistant.core import callback
|
from homeassistant.config_entries import ConfigEntry
|
||||||
|
from homeassistant.core import HomeAssistant, callback
|
||||||
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from . import KNOWN_DEVICES, HomeKitEntity
|
from . import KNOWN_DEVICES, HomeKitEntity
|
||||||
|
|
||||||
@ -111,7 +113,11 @@ ENTITY_TYPES = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(hass, config_entry, async_add_entities):
|
async def async_setup_entry(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
config_entry: ConfigEntry,
|
||||||
|
async_add_entities: AddEntitiesCallback,
|
||||||
|
) -> None:
|
||||||
"""Set up Homekit lighting."""
|
"""Set up Homekit lighting."""
|
||||||
hkid = config_entry.data["AccessoryPairingID"]
|
hkid = config_entry.data["AccessoryPairingID"]
|
||||||
conn = hass.data[KNOWN_DEVICES][hkid]
|
conn = hass.data[KNOWN_DEVICES][hkid]
|
||||||
|
@ -15,8 +15,10 @@ from homeassistant.components.button import (
|
|||||||
ButtonEntity,
|
ButtonEntity,
|
||||||
ButtonEntityDescription,
|
ButtonEntityDescription,
|
||||||
)
|
)
|
||||||
from homeassistant.core import callback
|
from homeassistant.config_entries import ConfigEntry
|
||||||
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.helpers.entity import EntityCategory
|
from homeassistant.helpers.entity import EntityCategory
|
||||||
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from . import KNOWN_DEVICES, CharacteristicEntity
|
from . import KNOWN_DEVICES, CharacteristicEntity
|
||||||
|
|
||||||
@ -46,7 +48,11 @@ BUTTON_ENTITIES: dict[str, HomeKitButtonEntityDescription] = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(hass, config_entry, async_add_entities):
|
async def async_setup_entry(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
config_entry: ConfigEntry,
|
||||||
|
async_add_entities: AddEntitiesCallback,
|
||||||
|
) -> None:
|
||||||
"""Set up Homekit buttons."""
|
"""Set up Homekit buttons."""
|
||||||
hkid = config_entry.data["AccessoryPairingID"]
|
hkid = config_entry.data["AccessoryPairingID"]
|
||||||
conn = hass.data[KNOWN_DEVICES][hkid]
|
conn = hass.data[KNOWN_DEVICES][hkid]
|
||||||
|
@ -4,7 +4,9 @@ from __future__ import annotations
|
|||||||
from aiohomekit.model.services import ServicesTypes
|
from aiohomekit.model.services import ServicesTypes
|
||||||
|
|
||||||
from homeassistant.components.camera import Camera
|
from homeassistant.components.camera import Camera
|
||||||
from homeassistant.core import callback
|
from homeassistant.config_entries import ConfigEntry
|
||||||
|
from homeassistant.core import HomeAssistant, callback
|
||||||
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from . import KNOWN_DEVICES, AccessoryEntity
|
from . import KNOWN_DEVICES, AccessoryEntity
|
||||||
|
|
||||||
@ -29,7 +31,11 @@ class HomeKitCamera(AccessoryEntity, Camera):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(hass, config_entry, async_add_entities):
|
async def async_setup_entry(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
config_entry: ConfigEntry,
|
||||||
|
async_add_entities: AddEntitiesCallback,
|
||||||
|
) -> None:
|
||||||
"""Set up Homekit sensors."""
|
"""Set up Homekit sensors."""
|
||||||
hkid = config_entry.data["AccessoryPairingID"]
|
hkid = config_entry.data["AccessoryPairingID"]
|
||||||
conn = hass.data[KNOWN_DEVICES][hkid]
|
conn = hass.data[KNOWN_DEVICES][hkid]
|
||||||
|
@ -33,8 +33,10 @@ from homeassistant.components.climate.const import (
|
|||||||
SWING_OFF,
|
SWING_OFF,
|
||||||
SWING_VERTICAL,
|
SWING_VERTICAL,
|
||||||
)
|
)
|
||||||
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS
|
from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from . import KNOWN_DEVICES, HomeKitEntity
|
from . import KNOWN_DEVICES, HomeKitEntity
|
||||||
|
|
||||||
@ -82,7 +84,11 @@ TARGET_HEATER_COOLER_STATE_HASS_TO_HOMEKIT = {
|
|||||||
SWING_MODE_HASS_TO_HOMEKIT = {v: k for k, v in SWING_MODE_HOMEKIT_TO_HASS.items()}
|
SWING_MODE_HASS_TO_HOMEKIT = {v: k for k, v in SWING_MODE_HOMEKIT_TO_HASS.items()}
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(hass, config_entry, async_add_entities):
|
async def async_setup_entry(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
config_entry: ConfigEntry,
|
||||||
|
async_add_entities: AddEntitiesCallback,
|
||||||
|
) -> None:
|
||||||
"""Set up Homekit climate."""
|
"""Set up Homekit climate."""
|
||||||
hkid = config_entry.data["AccessoryPairingID"]
|
hkid = config_entry.data["AccessoryPairingID"]
|
||||||
conn = hass.data[KNOWN_DEVICES][hkid]
|
conn = hass.data[KNOWN_DEVICES][hkid]
|
||||||
|
@ -14,8 +14,10 @@ from homeassistant.components.cover import (
|
|||||||
SUPPORT_STOP,
|
SUPPORT_STOP,
|
||||||
CoverEntity,
|
CoverEntity,
|
||||||
)
|
)
|
||||||
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import STATE_CLOSED, STATE_CLOSING, STATE_OPEN, STATE_OPENING
|
from homeassistant.const import STATE_CLOSED, STATE_CLOSING, STATE_OPEN, STATE_OPENING
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from . import KNOWN_DEVICES, HomeKitEntity
|
from . import KNOWN_DEVICES, HomeKitEntity
|
||||||
|
|
||||||
@ -34,7 +36,11 @@ TARGET_GARAGE_STATE_MAP = {STATE_OPEN: 0, STATE_CLOSED: 1, STATE_STOPPED: 2}
|
|||||||
CURRENT_WINDOW_STATE_MAP = {0: STATE_CLOSING, 1: STATE_OPENING, 2: STATE_STOPPED}
|
CURRENT_WINDOW_STATE_MAP = {0: STATE_CLOSING, 1: STATE_OPENING, 2: STATE_STOPPED}
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(hass, config_entry, async_add_entities):
|
async def async_setup_entry(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
config_entry: ConfigEntry,
|
||||||
|
async_add_entities: AddEntitiesCallback,
|
||||||
|
) -> None:
|
||||||
"""Set up Homekit covers."""
|
"""Set up Homekit covers."""
|
||||||
hkid = config_entry.data["AccessoryPairingID"]
|
hkid = config_entry.data["AccessoryPairingID"]
|
||||||
conn = hass.data[KNOWN_DEVICES][hkid]
|
conn = hass.data[KNOWN_DEVICES][hkid]
|
||||||
|
@ -10,7 +10,9 @@ from homeassistant.components.fan import (
|
|||||||
SUPPORT_SET_SPEED,
|
SUPPORT_SET_SPEED,
|
||||||
FanEntity,
|
FanEntity,
|
||||||
)
|
)
|
||||||
from homeassistant.core import callback
|
from homeassistant.config_entries import ConfigEntry
|
||||||
|
from homeassistant.core import HomeAssistant, callback
|
||||||
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from . import KNOWN_DEVICES, HomeKitEntity
|
from . import KNOWN_DEVICES, HomeKitEntity
|
||||||
|
|
||||||
@ -147,7 +149,11 @@ ENTITY_TYPES = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(hass, config_entry, async_add_entities):
|
async def async_setup_entry(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
config_entry: ConfigEntry,
|
||||||
|
async_add_entities: AddEntitiesCallback,
|
||||||
|
) -> None:
|
||||||
"""Set up Homekit fans."""
|
"""Set up Homekit fans."""
|
||||||
hkid = config_entry.data["AccessoryPairingID"]
|
hkid = config_entry.data["AccessoryPairingID"]
|
||||||
conn = hass.data[KNOWN_DEVICES][hkid]
|
conn = hass.data[KNOWN_DEVICES][hkid]
|
||||||
|
@ -10,7 +10,9 @@ from homeassistant.components.humidifier.const import (
|
|||||||
MODE_NORMAL,
|
MODE_NORMAL,
|
||||||
SUPPORT_MODES,
|
SUPPORT_MODES,
|
||||||
)
|
)
|
||||||
from homeassistant.core import callback
|
from homeassistant.config_entries import ConfigEntry
|
||||||
|
from homeassistant.core import HomeAssistant, callback
|
||||||
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from . import KNOWN_DEVICES, HomeKitEntity
|
from . import KNOWN_DEVICES, HomeKitEntity
|
||||||
|
|
||||||
@ -239,7 +241,11 @@ class HomeKitDehumidifier(HomeKitEntity, HumidifierEntity):
|
|||||||
return f"homekit-{serial}-{self._iid}-{self.device_class}"
|
return f"homekit-{serial}-{self._iid}-{self.device_class}"
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(hass, config_entry, async_add_entities):
|
async def async_setup_entry(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
config_entry: ConfigEntry,
|
||||||
|
async_add_entities: AddEntitiesCallback,
|
||||||
|
) -> None:
|
||||||
"""Set up Homekit humidifer."""
|
"""Set up Homekit humidifer."""
|
||||||
hkid = config_entry.data["AccessoryPairingID"]
|
hkid = config_entry.data["AccessoryPairingID"]
|
||||||
conn = hass.data[KNOWN_DEVICES][hkid]
|
conn = hass.data[KNOWN_DEVICES][hkid]
|
||||||
|
@ -11,12 +11,18 @@ from homeassistant.components.light import (
|
|||||||
SUPPORT_COLOR_TEMP,
|
SUPPORT_COLOR_TEMP,
|
||||||
LightEntity,
|
LightEntity,
|
||||||
)
|
)
|
||||||
from homeassistant.core import callback
|
from homeassistant.config_entries import ConfigEntry
|
||||||
|
from homeassistant.core import HomeAssistant, callback
|
||||||
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from . import KNOWN_DEVICES, HomeKitEntity
|
from . import KNOWN_DEVICES, HomeKitEntity
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(hass, config_entry, async_add_entities):
|
async def async_setup_entry(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
config_entry: ConfigEntry,
|
||||||
|
async_add_entities: AddEntitiesCallback,
|
||||||
|
) -> None:
|
||||||
"""Set up Homekit lightbulb."""
|
"""Set up Homekit lightbulb."""
|
||||||
hkid = config_entry.data["AccessoryPairingID"]
|
hkid = config_entry.data["AccessoryPairingID"]
|
||||||
conn = hass.data[KNOWN_DEVICES][hkid]
|
conn = hass.data[KNOWN_DEVICES][hkid]
|
||||||
|
@ -3,13 +3,15 @@ from aiohomekit.model.characteristics import CharacteristicsTypes
|
|||||||
from aiohomekit.model.services import ServicesTypes
|
from aiohomekit.model.services import ServicesTypes
|
||||||
|
|
||||||
from homeassistant.components.lock import STATE_JAMMED, LockEntity
|
from homeassistant.components.lock import STATE_JAMMED, LockEntity
|
||||||
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
ATTR_BATTERY_LEVEL,
|
ATTR_BATTERY_LEVEL,
|
||||||
STATE_LOCKED,
|
STATE_LOCKED,
|
||||||
STATE_UNKNOWN,
|
STATE_UNKNOWN,
|
||||||
STATE_UNLOCKED,
|
STATE_UNLOCKED,
|
||||||
)
|
)
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from . import KNOWN_DEVICES, HomeKitEntity
|
from . import KNOWN_DEVICES, HomeKitEntity
|
||||||
|
|
||||||
@ -25,7 +27,11 @@ TARGET_STATE_MAP = {STATE_UNLOCKED: 0, STATE_LOCKED: 1}
|
|||||||
REVERSED_TARGET_STATE_MAP = {v: k for k, v in TARGET_STATE_MAP.items()}
|
REVERSED_TARGET_STATE_MAP = {v: k for k, v in TARGET_STATE_MAP.items()}
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(hass, config_entry, async_add_entities):
|
async def async_setup_entry(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
config_entry: ConfigEntry,
|
||||||
|
async_add_entities: AddEntitiesCallback,
|
||||||
|
) -> None:
|
||||||
"""Set up Homekit lock."""
|
"""Set up Homekit lock."""
|
||||||
hkid = config_entry.data["AccessoryPairingID"]
|
hkid = config_entry.data["AccessoryPairingID"]
|
||||||
conn = hass.data[KNOWN_DEVICES][hkid]
|
conn = hass.data[KNOWN_DEVICES][hkid]
|
||||||
|
@ -20,6 +20,7 @@ from homeassistant.components.media_player.const import (
|
|||||||
SUPPORT_SELECT_SOURCE,
|
SUPPORT_SELECT_SOURCE,
|
||||||
SUPPORT_STOP,
|
SUPPORT_STOP,
|
||||||
)
|
)
|
||||||
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
STATE_IDLE,
|
STATE_IDLE,
|
||||||
STATE_OK,
|
STATE_OK,
|
||||||
@ -27,7 +28,8 @@ from homeassistant.const import (
|
|||||||
STATE_PLAYING,
|
STATE_PLAYING,
|
||||||
STATE_PROBLEM,
|
STATE_PROBLEM,
|
||||||
)
|
)
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from . import KNOWN_DEVICES, HomeKitEntity
|
from . import KNOWN_DEVICES, HomeKitEntity
|
||||||
|
|
||||||
@ -41,7 +43,11 @@ HK_TO_HA_STATE = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(hass, config_entry, async_add_entities):
|
async def async_setup_entry(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
config_entry: ConfigEntry,
|
||||||
|
async_add_entities: AddEntitiesCallback,
|
||||||
|
) -> None:
|
||||||
"""Set up Homekit television."""
|
"""Set up Homekit television."""
|
||||||
hkid = config_entry.data["AccessoryPairingID"]
|
hkid = config_entry.data["AccessoryPairingID"]
|
||||||
conn = hass.data[KNOWN_DEVICES][hkid]
|
conn = hass.data[KNOWN_DEVICES][hkid]
|
||||||
|
@ -9,8 +9,10 @@ from __future__ import annotations
|
|||||||
from aiohomekit.model.characteristics import Characteristic, CharacteristicsTypes
|
from aiohomekit.model.characteristics import Characteristic, CharacteristicsTypes
|
||||||
|
|
||||||
from homeassistant.components.number import NumberEntity, NumberEntityDescription
|
from homeassistant.components.number import NumberEntity, NumberEntityDescription
|
||||||
from homeassistant.core import callback
|
from homeassistant.config_entries import ConfigEntry
|
||||||
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.helpers.entity import EntityCategory
|
from homeassistant.helpers.entity import EntityCategory
|
||||||
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from . import KNOWN_DEVICES, CharacteristicEntity
|
from . import KNOWN_DEVICES, CharacteristicEntity
|
||||||
|
|
||||||
@ -42,7 +44,11 @@ NUMBER_ENTITIES: dict[str, NumberEntityDescription] = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(hass, config_entry, async_add_entities):
|
async def async_setup_entry(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
config_entry: ConfigEntry,
|
||||||
|
async_add_entities: AddEntitiesCallback,
|
||||||
|
) -> None:
|
||||||
"""Set up Homekit numbers."""
|
"""Set up Homekit numbers."""
|
||||||
hkid = config_entry.data["AccessoryPairingID"]
|
hkid = config_entry.data["AccessoryPairingID"]
|
||||||
conn = hass.data[KNOWN_DEVICES][hkid]
|
conn = hass.data[KNOWN_DEVICES][hkid]
|
||||||
|
@ -13,6 +13,7 @@ from homeassistant.components.sensor import (
|
|||||||
SensorEntityDescription,
|
SensorEntityDescription,
|
||||||
SensorStateClass,
|
SensorStateClass,
|
||||||
)
|
)
|
||||||
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
|
CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
|
||||||
CONCENTRATION_PARTS_PER_MILLION,
|
CONCENTRATION_PARTS_PER_MILLION,
|
||||||
@ -24,7 +25,8 @@ from homeassistant.const import (
|
|||||||
PRESSURE_HPA,
|
PRESSURE_HPA,
|
||||||
TEMP_CELSIUS,
|
TEMP_CELSIUS,
|
||||||
)
|
)
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from . import KNOWN_DEVICES, CharacteristicEntity, HomeKitEntity
|
from . import KNOWN_DEVICES, CharacteristicEntity, HomeKitEntity
|
||||||
|
|
||||||
@ -373,7 +375,11 @@ ENTITY_TYPES = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(hass, config_entry, async_add_entities):
|
async def async_setup_entry(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
config_entry: ConfigEntry,
|
||||||
|
async_add_entities: AddEntitiesCallback,
|
||||||
|
) -> None:
|
||||||
"""Set up Homekit sensors."""
|
"""Set up Homekit sensors."""
|
||||||
hkid = config_entry.data["AccessoryPairingID"]
|
hkid = config_entry.data["AccessoryPairingID"]
|
||||||
conn = hass.data[KNOWN_DEVICES][hkid]
|
conn = hass.data[KNOWN_DEVICES][hkid]
|
||||||
|
@ -12,8 +12,10 @@ from aiohomekit.model.characteristics import (
|
|||||||
from aiohomekit.model.services import ServicesTypes
|
from aiohomekit.model.services import ServicesTypes
|
||||||
|
|
||||||
from homeassistant.components.switch import SwitchEntity, SwitchEntityDescription
|
from homeassistant.components.switch import SwitchEntity, SwitchEntityDescription
|
||||||
from homeassistant.core import callback
|
from homeassistant.config_entries import ConfigEntry
|
||||||
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.helpers.entity import EntityCategory
|
from homeassistant.helpers.entity import EntityCategory
|
||||||
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from . import KNOWN_DEVICES, CharacteristicEntity, HomeKitEntity
|
from . import KNOWN_DEVICES, CharacteristicEntity, HomeKitEntity
|
||||||
|
|
||||||
@ -176,7 +178,11 @@ ENTITY_TYPES = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(hass, config_entry, async_add_entities):
|
async def async_setup_entry(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
config_entry: ConfigEntry,
|
||||||
|
async_add_entities: AddEntitiesCallback,
|
||||||
|
) -> None:
|
||||||
"""Set up Homekit switches."""
|
"""Set up Homekit switches."""
|
||||||
hkid = config_entry.data["AccessoryPairingID"]
|
hkid = config_entry.data["AccessoryPairingID"]
|
||||||
conn = hass.data[KNOWN_DEVICES][hkid]
|
conn = hass.data[KNOWN_DEVICES][hkid]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user