mirror of
https://github.com/home-assistant/core.git
synced 2025-07-28 07:37:34 +00:00
Use runtime_data in homematicip_cloud (#144892)
This commit is contained in:
parent
3b9d8e00bc
commit
34c7c3f384
@ -3,7 +3,6 @@
|
|||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import config_entries
|
from homeassistant import config_entries
|
||||||
from homeassistant.config_entries import ConfigEntry
|
|
||||||
from homeassistant.const import CONF_NAME, EVENT_HOMEASSISTANT_STOP
|
from homeassistant.const import CONF_NAME, EVENT_HOMEASSISTANT_STOP
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.helpers import (
|
from homeassistant.helpers import (
|
||||||
@ -21,7 +20,7 @@ from .const import (
|
|||||||
HMIPC_HAPID,
|
HMIPC_HAPID,
|
||||||
HMIPC_NAME,
|
HMIPC_NAME,
|
||||||
)
|
)
|
||||||
from .hap import HomematicipHAP
|
from .hap import HomematicIPConfigEntry, HomematicipHAP
|
||||||
from .services import async_setup_services, async_unload_services
|
from .services import async_setup_services, async_unload_services
|
||||||
|
|
||||||
CONFIG_SCHEMA = vol.Schema(
|
CONFIG_SCHEMA = vol.Schema(
|
||||||
@ -45,8 +44,6 @@ CONFIG_SCHEMA = vol.Schema(
|
|||||||
|
|
||||||
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||||
"""Set up the HomematicIP Cloud component."""
|
"""Set up the HomematicIP Cloud component."""
|
||||||
hass.data[DOMAIN] = {}
|
|
||||||
|
|
||||||
accesspoints = config.get(DOMAIN, [])
|
accesspoints = config.get(DOMAIN, [])
|
||||||
|
|
||||||
for conf in accesspoints:
|
for conf in accesspoints:
|
||||||
@ -69,7 +66,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
async def async_setup_entry(hass: HomeAssistant, entry: HomematicIPConfigEntry) -> bool:
|
||||||
"""Set up an access point from a config entry."""
|
"""Set up an access point from a config entry."""
|
||||||
|
|
||||||
# 0.104 introduced config entry unique id, this makes upgrading possible
|
# 0.104 introduced config entry unique id, this makes upgrading possible
|
||||||
@ -81,8 +78,8 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
)
|
)
|
||||||
|
|
||||||
hap = HomematicipHAP(hass, entry)
|
hap = HomematicipHAP(hass, entry)
|
||||||
hass.data[DOMAIN][entry.unique_id] = hap
|
|
||||||
|
|
||||||
|
entry.runtime_data = hap
|
||||||
if not await hap.async_setup():
|
if not await hap.async_setup():
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@ -110,9 +107,12 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
async def async_unload_entry(
|
||||||
|
hass: HomeAssistant, entry: HomematicIPConfigEntry
|
||||||
|
) -> bool:
|
||||||
"""Unload a config entry."""
|
"""Unload a config entry."""
|
||||||
hap = hass.data[DOMAIN].pop(entry.unique_id)
|
hap = entry.runtime_data
|
||||||
|
assert hap.reset_connection_listener is not None
|
||||||
hap.reset_connection_listener()
|
hap.reset_connection_listener()
|
||||||
|
|
||||||
await async_unload_services(hass)
|
await async_unload_services(hass)
|
||||||
@ -122,7 +122,7 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
|
|
||||||
@callback
|
@callback
|
||||||
def _async_remove_obsolete_entities(
|
def _async_remove_obsolete_entities(
|
||||||
hass: HomeAssistant, entry: ConfigEntry, hap: HomematicipHAP
|
hass: HomeAssistant, entry: HomematicIPConfigEntry, hap: HomematicipHAP
|
||||||
):
|
):
|
||||||
"""Remove obsolete entities from entity registry."""
|
"""Remove obsolete entities from entity registry."""
|
||||||
|
|
||||||
|
@ -11,13 +11,12 @@ from homeassistant.components.alarm_control_panel import (
|
|||||||
AlarmControlPanelEntityFeature,
|
AlarmControlPanelEntityFeature,
|
||||||
AlarmControlPanelState,
|
AlarmControlPanelState,
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import ConfigEntry
|
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.helpers.device_registry import DeviceInfo
|
from homeassistant.helpers.device_registry import DeviceInfo
|
||||||
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
from .hap import AsyncHome, HomematicipHAP
|
from .hap import AsyncHome, HomematicIPConfigEntry, HomematicipHAP
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -26,11 +25,11 @@ CONST_ALARM_CONTROL_PANEL_NAME = "HmIP Alarm Control Panel"
|
|||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
config_entry: ConfigEntry,
|
config_entry: HomematicIPConfigEntry,
|
||||||
async_add_entities: AddConfigEntryEntitiesCallback,
|
async_add_entities: AddConfigEntryEntitiesCallback,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Set up the HomematicIP alrm control panel from a config entry."""
|
"""Set up the HomematicIP alrm control panel from a config entry."""
|
||||||
hap = hass.data[DOMAIN][config_entry.unique_id]
|
hap = config_entry.runtime_data
|
||||||
async_add_entities([HomematicipAlarmControlPanelEntity(hap)])
|
async_add_entities([HomematicipAlarmControlPanelEntity(hap)])
|
||||||
|
|
||||||
|
|
||||||
|
@ -34,14 +34,13 @@ from homeassistant.components.binary_sensor import (
|
|||||||
BinarySensorDeviceClass,
|
BinarySensorDeviceClass,
|
||||||
BinarySensorEntity,
|
BinarySensorEntity,
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import ConfigEntry
|
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.device_registry import DeviceInfo
|
from homeassistant.helpers.device_registry import DeviceInfo
|
||||||
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
from .entity import HomematicipGenericEntity
|
from .entity import HomematicipGenericEntity
|
||||||
from .hap import HomematicipHAP
|
from .hap import HomematicIPConfigEntry, HomematicipHAP
|
||||||
|
|
||||||
ATTR_ACCELERATION_SENSOR_MODE = "acceleration_sensor_mode"
|
ATTR_ACCELERATION_SENSOR_MODE = "acceleration_sensor_mode"
|
||||||
ATTR_ACCELERATION_SENSOR_NEUTRAL_POSITION = "acceleration_sensor_neutral_position"
|
ATTR_ACCELERATION_SENSOR_NEUTRAL_POSITION = "acceleration_sensor_neutral_position"
|
||||||
@ -75,11 +74,11 @@ SAM_DEVICE_ATTRIBUTES = {
|
|||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
config_entry: ConfigEntry,
|
config_entry: HomematicIPConfigEntry,
|
||||||
async_add_entities: AddConfigEntryEntitiesCallback,
|
async_add_entities: AddConfigEntryEntitiesCallback,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Set up the HomematicIP Cloud binary sensor from a config entry."""
|
"""Set up the HomematicIP Cloud binary sensor from a config entry."""
|
||||||
hap = hass.data[DOMAIN][config_entry.unique_id]
|
hap = config_entry.runtime_data
|
||||||
entities: list[HomematicipGenericEntity] = [HomematicipCloudConnectionSensor(hap)]
|
entities: list[HomematicipGenericEntity] = [HomematicipCloudConnectionSensor(hap)]
|
||||||
for device in hap.home.devices:
|
for device in hap.home.devices:
|
||||||
if isinstance(device, AccelerationSensor):
|
if isinstance(device, AccelerationSensor):
|
||||||
|
@ -5,22 +5,20 @@ from __future__ import annotations
|
|||||||
from homematicip.device import WallMountedGarageDoorController
|
from homematicip.device import WallMountedGarageDoorController
|
||||||
|
|
||||||
from homeassistant.components.button import ButtonEntity
|
from homeassistant.components.button import ButtonEntity
|
||||||
from homeassistant.config_entries import ConfigEntry
|
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
||||||
|
|
||||||
from .const import DOMAIN
|
|
||||||
from .entity import HomematicipGenericEntity
|
from .entity import HomematicipGenericEntity
|
||||||
from .hap import HomematicipHAP
|
from .hap import HomematicIPConfigEntry, HomematicipHAP
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
config_entry: ConfigEntry,
|
config_entry: HomematicIPConfigEntry,
|
||||||
async_add_entities: AddConfigEntryEntitiesCallback,
|
async_add_entities: AddConfigEntryEntitiesCallback,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Set up the HomematicIP button from a config entry."""
|
"""Set up the HomematicIP button from a config entry."""
|
||||||
hap = hass.data[DOMAIN][config_entry.unique_id]
|
hap = config_entry.runtime_data
|
||||||
|
|
||||||
async_add_entities(
|
async_add_entities(
|
||||||
HomematicipGarageDoorControllerButton(hap, device)
|
HomematicipGarageDoorControllerButton(hap, device)
|
||||||
|
@ -24,7 +24,6 @@ from homeassistant.components.climate import (
|
|||||||
HVACAction,
|
HVACAction,
|
||||||
HVACMode,
|
HVACMode,
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import ConfigEntry
|
|
||||||
from homeassistant.const import ATTR_TEMPERATURE, UnitOfTemperature
|
from homeassistant.const import ATTR_TEMPERATURE, UnitOfTemperature
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.device_registry import DeviceInfo
|
from homeassistant.helpers.device_registry import DeviceInfo
|
||||||
@ -32,7 +31,7 @@ from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
|||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
from .entity import HomematicipGenericEntity
|
from .entity import HomematicipGenericEntity
|
||||||
from .hap import HomematicipHAP
|
from .hap import HomematicIPConfigEntry, HomematicipHAP
|
||||||
|
|
||||||
HEATING_PROFILES = {"PROFILE_1": 0, "PROFILE_2": 1, "PROFILE_3": 2}
|
HEATING_PROFILES = {"PROFILE_1": 0, "PROFILE_2": 1, "PROFILE_3": 2}
|
||||||
COOLING_PROFILES = {"PROFILE_4": 3, "PROFILE_5": 4, "PROFILE_6": 5}
|
COOLING_PROFILES = {"PROFILE_4": 3, "PROFILE_5": 4, "PROFILE_6": 5}
|
||||||
@ -55,11 +54,11 @@ HMIP_ECO_CM = "ECO"
|
|||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
config_entry: ConfigEntry,
|
config_entry: HomematicIPConfigEntry,
|
||||||
async_add_entities: AddConfigEntryEntitiesCallback,
|
async_add_entities: AddConfigEntryEntitiesCallback,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Set up the HomematicIP climate from a config entry."""
|
"""Set up the HomematicIP climate from a config entry."""
|
||||||
hap = hass.data[DOMAIN][config_entry.unique_id]
|
hap = config_entry.runtime_data
|
||||||
|
|
||||||
async_add_entities(
|
async_add_entities(
|
||||||
HomematicipHeatingGroup(hap, device)
|
HomematicipHeatingGroup(hap, device)
|
||||||
|
@ -21,13 +21,11 @@ from homeassistant.components.cover import (
|
|||||||
CoverDeviceClass,
|
CoverDeviceClass,
|
||||||
CoverEntity,
|
CoverEntity,
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import ConfigEntry
|
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
||||||
|
|
||||||
from .const import DOMAIN
|
|
||||||
from .entity import HomematicipGenericEntity
|
from .entity import HomematicipGenericEntity
|
||||||
from .hap import HomematicipHAP
|
from .hap import HomematicIPConfigEntry, HomematicipHAP
|
||||||
|
|
||||||
HMIP_COVER_OPEN = 0
|
HMIP_COVER_OPEN = 0
|
||||||
HMIP_COVER_CLOSED = 1
|
HMIP_COVER_CLOSED = 1
|
||||||
@ -37,11 +35,11 @@ HMIP_SLATS_CLOSED = 1
|
|||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
config_entry: ConfigEntry,
|
config_entry: HomematicIPConfigEntry,
|
||||||
async_add_entities: AddConfigEntryEntitiesCallback,
|
async_add_entities: AddConfigEntryEntitiesCallback,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Set up the HomematicIP cover from a config entry."""
|
"""Set up the HomematicIP cover from a config entry."""
|
||||||
hap = hass.data[DOMAIN][config_entry.unique_id]
|
hap = config_entry.runtime_data
|
||||||
entities: list[HomematicipGenericEntity] = [
|
entities: list[HomematicipGenericEntity] = [
|
||||||
HomematicipCoverShutterGroup(hap, group)
|
HomematicipCoverShutterGroup(hap, group)
|
||||||
for group in hap.home.groups
|
for group in hap.home.groups
|
||||||
|
@ -13,13 +13,11 @@ from homeassistant.components.event import (
|
|||||||
EventEntity,
|
EventEntity,
|
||||||
EventEntityDescription,
|
EventEntityDescription,
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import ConfigEntry
|
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
||||||
|
|
||||||
from .const import DOMAIN
|
|
||||||
from .entity import HomematicipGenericEntity
|
from .entity import HomematicipGenericEntity
|
||||||
from .hap import HomematicipHAP
|
from .hap import HomematicIPConfigEntry, HomematicipHAP
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True, kw_only=True)
|
@dataclass(frozen=True, kw_only=True)
|
||||||
@ -44,11 +42,11 @@ EVENT_DESCRIPTIONS = {
|
|||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
config_entry: ConfigEntry,
|
config_entry: HomematicIPConfigEntry,
|
||||||
async_add_entities: AddConfigEntryEntitiesCallback,
|
async_add_entities: AddConfigEntryEntitiesCallback,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Set up the HomematicIP cover from a config entry."""
|
"""Set up the HomematicIP cover from a config entry."""
|
||||||
hap = hass.data[DOMAIN][config_entry.unique_id]
|
hap = config_entry.runtime_data
|
||||||
entities: list[HomematicipGenericEntity] = []
|
entities: list[HomematicipGenericEntity] = []
|
||||||
|
|
||||||
entities.extend(
|
entities.extend(
|
||||||
|
@ -25,6 +25,8 @@ from .errors import HmipcConnectionError
|
|||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
type HomematicIPConfigEntry = ConfigEntry[HomematicipHAP]
|
||||||
|
|
||||||
|
|
||||||
async def build_context_async(
|
async def build_context_async(
|
||||||
hass: HomeAssistant, hapid: str | None, authtoken: str | None
|
hass: HomeAssistant, hapid: str | None, authtoken: str | None
|
||||||
@ -102,7 +104,9 @@ class HomematicipHAP:
|
|||||||
|
|
||||||
home: AsyncHome
|
home: AsyncHome
|
||||||
|
|
||||||
def __init__(self, hass: HomeAssistant, config_entry: ConfigEntry) -> None:
|
def __init__(
|
||||||
|
self, hass: HomeAssistant, config_entry: HomematicIPConfigEntry
|
||||||
|
) -> None:
|
||||||
"""Initialize HomematicIP Cloud connection."""
|
"""Initialize HomematicIP Cloud connection."""
|
||||||
self.hass = hass
|
self.hass = hass
|
||||||
self.config_entry = config_entry
|
self.config_entry = config_entry
|
||||||
|
@ -28,22 +28,20 @@ from homeassistant.components.light import (
|
|||||||
LightEntity,
|
LightEntity,
|
||||||
LightEntityFeature,
|
LightEntityFeature,
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import ConfigEntry
|
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
||||||
|
|
||||||
from .const import DOMAIN
|
|
||||||
from .entity import HomematicipGenericEntity
|
from .entity import HomematicipGenericEntity
|
||||||
from .hap import HomematicipHAP
|
from .hap import HomematicIPConfigEntry, HomematicipHAP
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
config_entry: ConfigEntry,
|
config_entry: HomematicIPConfigEntry,
|
||||||
async_add_entities: AddConfigEntryEntitiesCallback,
|
async_add_entities: AddConfigEntryEntitiesCallback,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Set up the HomematicIP Cloud lights from a config entry."""
|
"""Set up the HomematicIP Cloud lights from a config entry."""
|
||||||
hap = hass.data[DOMAIN][config_entry.unique_id]
|
hap = config_entry.runtime_data
|
||||||
entities: list[HomematicipGenericEntity] = []
|
entities: list[HomematicipGenericEntity] = []
|
||||||
for device in hap.home.devices:
|
for device in hap.home.devices:
|
||||||
if isinstance(device, BrandSwitchMeasuring):
|
if isinstance(device, BrandSwitchMeasuring):
|
||||||
|
@ -9,12 +9,11 @@ from homematicip.base.enums import LockState, MotorState
|
|||||||
from homematicip.device import DoorLockDrive
|
from homematicip.device import DoorLockDrive
|
||||||
|
|
||||||
from homeassistant.components.lock import LockEntity, LockEntityFeature
|
from homeassistant.components.lock import LockEntity, LockEntityFeature
|
||||||
from homeassistant.config_entries import ConfigEntry
|
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
||||||
|
|
||||||
from .const import DOMAIN
|
|
||||||
from .entity import HomematicipGenericEntity
|
from .entity import HomematicipGenericEntity
|
||||||
|
from .hap import HomematicIPConfigEntry
|
||||||
from .helpers import handle_errors
|
from .helpers import handle_errors
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
@ -36,11 +35,11 @@ DEVICE_DLD_ATTRIBUTES = {
|
|||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
config_entry: ConfigEntry,
|
config_entry: HomematicIPConfigEntry,
|
||||||
async_add_entities: AddConfigEntryEntitiesCallback,
|
async_add_entities: AddConfigEntryEntitiesCallback,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Set up the HomematicIP locks from a config entry."""
|
"""Set up the HomematicIP locks from a config entry."""
|
||||||
hap = hass.data[DOMAIN][config_entry.unique_id]
|
hap = config_entry.runtime_data
|
||||||
|
|
||||||
async_add_entities(
|
async_add_entities(
|
||||||
HomematicipDoorLockDrive(hap, device)
|
HomematicipDoorLockDrive(hap, device)
|
||||||
|
@ -44,7 +44,6 @@ from homeassistant.components.sensor import (
|
|||||||
SensorEntity,
|
SensorEntity,
|
||||||
SensorStateClass,
|
SensorStateClass,
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import ConfigEntry
|
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONCENTRATION_MILLIGRAMS_PER_CUBIC_METER,
|
CONCENTRATION_MILLIGRAMS_PER_CUBIC_METER,
|
||||||
LIGHT_LUX,
|
LIGHT_LUX,
|
||||||
@ -61,9 +60,8 @@ from homeassistant.core import HomeAssistant
|
|||||||
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
||||||
from homeassistant.helpers.typing import StateType
|
from homeassistant.helpers.typing import StateType
|
||||||
|
|
||||||
from .const import DOMAIN
|
|
||||||
from .entity import HomematicipGenericEntity
|
from .entity import HomematicipGenericEntity
|
||||||
from .hap import HomematicipHAP
|
from .hap import HomematicIPConfigEntry, HomematicipHAP
|
||||||
from .helpers import get_channels_from_device
|
from .helpers import get_channels_from_device
|
||||||
|
|
||||||
ATTR_CURRENT_ILLUMINATION = "current_illumination"
|
ATTR_CURRENT_ILLUMINATION = "current_illumination"
|
||||||
@ -96,11 +94,11 @@ ILLUMINATION_DEVICE_ATTRIBUTES = {
|
|||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
config_entry: ConfigEntry,
|
config_entry: HomematicIPConfigEntry,
|
||||||
async_add_entities: AddConfigEntryEntitiesCallback,
|
async_add_entities: AddConfigEntryEntitiesCallback,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Set up the HomematicIP Cloud sensors from a config entry."""
|
"""Set up the HomematicIP Cloud sensors from a config entry."""
|
||||||
hap = hass.data[DOMAIN][config_entry.unique_id]
|
hap = config_entry.runtime_data
|
||||||
entities: list[HomematicipGenericEntity] = []
|
entities: list[HomematicipGenericEntity] = []
|
||||||
for device in hap.home.devices:
|
for device in hap.home.devices:
|
||||||
if isinstance(device, HomeControlAccessPoint):
|
if isinstance(device, HomeControlAccessPoint):
|
||||||
|
@ -22,6 +22,7 @@ from homeassistant.helpers.service import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
|
from .hap import HomematicIPConfigEntry
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -218,7 +219,7 @@ async def async_setup_services(hass: HomeAssistant) -> None:
|
|||||||
|
|
||||||
async def async_unload_services(hass: HomeAssistant):
|
async def async_unload_services(hass: HomeAssistant):
|
||||||
"""Unload HomematicIP Cloud services."""
|
"""Unload HomematicIP Cloud services."""
|
||||||
if hass.data[DOMAIN]:
|
if hass.config_entries.async_loaded_entries(DOMAIN):
|
||||||
return
|
return
|
||||||
|
|
||||||
for hmipc_service in HMIPC_SERVICES:
|
for hmipc_service in HMIPC_SERVICES:
|
||||||
@ -235,8 +236,9 @@ async def _async_activate_eco_mode_with_duration(
|
|||||||
if home := _get_home(hass, hapid):
|
if home := _get_home(hass, hapid):
|
||||||
await home.activate_absence_with_duration_async(duration)
|
await home.activate_absence_with_duration_async(duration)
|
||||||
else:
|
else:
|
||||||
for hap in hass.data[DOMAIN].values():
|
entry: HomematicIPConfigEntry
|
||||||
await hap.home.activate_absence_with_duration_async(duration)
|
for entry in hass.config_entries.async_loaded_entries(DOMAIN):
|
||||||
|
await entry.runtime_data.home.activate_absence_with_duration_async(duration)
|
||||||
|
|
||||||
|
|
||||||
async def _async_activate_eco_mode_with_period(
|
async def _async_activate_eco_mode_with_period(
|
||||||
@ -249,8 +251,9 @@ async def _async_activate_eco_mode_with_period(
|
|||||||
if home := _get_home(hass, hapid):
|
if home := _get_home(hass, hapid):
|
||||||
await home.activate_absence_with_period_async(endtime)
|
await home.activate_absence_with_period_async(endtime)
|
||||||
else:
|
else:
|
||||||
for hap in hass.data[DOMAIN].values():
|
entry: HomematicIPConfigEntry
|
||||||
await hap.home.activate_absence_with_period_async(endtime)
|
for entry in hass.config_entries.async_loaded_entries(DOMAIN):
|
||||||
|
await entry.runtime_data.home.activate_absence_with_period_async(endtime)
|
||||||
|
|
||||||
|
|
||||||
async def _async_activate_vacation(hass: HomeAssistant, service: ServiceCall) -> None:
|
async def _async_activate_vacation(hass: HomeAssistant, service: ServiceCall) -> None:
|
||||||
@ -262,8 +265,9 @@ async def _async_activate_vacation(hass: HomeAssistant, service: ServiceCall) ->
|
|||||||
if home := _get_home(hass, hapid):
|
if home := _get_home(hass, hapid):
|
||||||
await home.activate_vacation_async(endtime, temperature)
|
await home.activate_vacation_async(endtime, temperature)
|
||||||
else:
|
else:
|
||||||
for hap in hass.data[DOMAIN].values():
|
entry: HomematicIPConfigEntry
|
||||||
await hap.home.activate_vacation_async(endtime, temperature)
|
for entry in hass.config_entries.async_loaded_entries(DOMAIN):
|
||||||
|
await entry.runtime_data.home.activate_vacation_async(endtime, temperature)
|
||||||
|
|
||||||
|
|
||||||
async def _async_deactivate_eco_mode(hass: HomeAssistant, service: ServiceCall) -> None:
|
async def _async_deactivate_eco_mode(hass: HomeAssistant, service: ServiceCall) -> None:
|
||||||
@ -272,8 +276,9 @@ async def _async_deactivate_eco_mode(hass: HomeAssistant, service: ServiceCall)
|
|||||||
if home := _get_home(hass, hapid):
|
if home := _get_home(hass, hapid):
|
||||||
await home.deactivate_absence_async()
|
await home.deactivate_absence_async()
|
||||||
else:
|
else:
|
||||||
for hap in hass.data[DOMAIN].values():
|
entry: HomematicIPConfigEntry
|
||||||
await hap.home.deactivate_absence_async()
|
for entry in hass.config_entries.async_loaded_entries(DOMAIN):
|
||||||
|
await entry.runtime_data.home.deactivate_absence_async()
|
||||||
|
|
||||||
|
|
||||||
async def _async_deactivate_vacation(hass: HomeAssistant, service: ServiceCall) -> None:
|
async def _async_deactivate_vacation(hass: HomeAssistant, service: ServiceCall) -> None:
|
||||||
@ -282,8 +287,9 @@ async def _async_deactivate_vacation(hass: HomeAssistant, service: ServiceCall)
|
|||||||
if home := _get_home(hass, hapid):
|
if home := _get_home(hass, hapid):
|
||||||
await home.deactivate_vacation_async()
|
await home.deactivate_vacation_async()
|
||||||
else:
|
else:
|
||||||
for hap in hass.data[DOMAIN].values():
|
entry: HomematicIPConfigEntry
|
||||||
await hap.home.deactivate_vacation_async()
|
for entry in hass.config_entries.async_loaded_entries(DOMAIN):
|
||||||
|
await entry.runtime_data.home.deactivate_vacation_async()
|
||||||
|
|
||||||
|
|
||||||
async def _set_active_climate_profile(
|
async def _set_active_climate_profile(
|
||||||
@ -293,14 +299,15 @@ async def _set_active_climate_profile(
|
|||||||
entity_id_list = service.data[ATTR_ENTITY_ID]
|
entity_id_list = service.data[ATTR_ENTITY_ID]
|
||||||
climate_profile_index = service.data[ATTR_CLIMATE_PROFILE_INDEX] - 1
|
climate_profile_index = service.data[ATTR_CLIMATE_PROFILE_INDEX] - 1
|
||||||
|
|
||||||
for hap in hass.data[DOMAIN].values():
|
entry: HomematicIPConfigEntry
|
||||||
|
for entry in hass.config_entries.async_loaded_entries(DOMAIN):
|
||||||
if entity_id_list != "all":
|
if entity_id_list != "all":
|
||||||
for entity_id in entity_id_list:
|
for entity_id in entity_id_list:
|
||||||
group = hap.hmip_device_by_entity_id.get(entity_id)
|
group = entry.runtime_data.hmip_device_by_entity_id.get(entity_id)
|
||||||
if group and isinstance(group, HeatingGroup):
|
if group and isinstance(group, HeatingGroup):
|
||||||
await group.set_active_profile_async(climate_profile_index)
|
await group.set_active_profile_async(climate_profile_index)
|
||||||
else:
|
else:
|
||||||
for group in hap.home.groups:
|
for group in entry.runtime_data.home.groups:
|
||||||
if isinstance(group, HeatingGroup):
|
if isinstance(group, HeatingGroup):
|
||||||
await group.set_active_profile_async(climate_profile_index)
|
await group.set_active_profile_async(climate_profile_index)
|
||||||
|
|
||||||
@ -313,8 +320,10 @@ async def _async_dump_hap_config(hass: HomeAssistant, service: ServiceCall) -> N
|
|||||||
config_file_prefix = service.data[ATTR_CONFIG_OUTPUT_FILE_PREFIX]
|
config_file_prefix = service.data[ATTR_CONFIG_OUTPUT_FILE_PREFIX]
|
||||||
anonymize = service.data[ATTR_ANONYMIZE]
|
anonymize = service.data[ATTR_ANONYMIZE]
|
||||||
|
|
||||||
for hap in hass.data[DOMAIN].values():
|
entry: HomematicIPConfigEntry
|
||||||
hap_sgtin = hap.config_entry.unique_id
|
for entry in hass.config_entries.async_loaded_entries(DOMAIN):
|
||||||
|
hap_sgtin = entry.unique_id
|
||||||
|
assert hap_sgtin is not None
|
||||||
|
|
||||||
if anonymize:
|
if anonymize:
|
||||||
hap_sgtin = hap_sgtin[-4:]
|
hap_sgtin = hap_sgtin[-4:]
|
||||||
@ -323,7 +332,7 @@ async def _async_dump_hap_config(hass: HomeAssistant, service: ServiceCall) -> N
|
|||||||
path = Path(config_path)
|
path = Path(config_path)
|
||||||
config_file = path / file_name
|
config_file = path / file_name
|
||||||
|
|
||||||
json_state = await hap.home.download_configuration_async()
|
json_state = await entry.runtime_data.home.download_configuration_async()
|
||||||
json_state = handle_config(json_state, anonymize)
|
json_state = handle_config(json_state, anonymize)
|
||||||
|
|
||||||
config_file.write_text(json_state, encoding="utf8")
|
config_file.write_text(json_state, encoding="utf8")
|
||||||
@ -333,14 +342,15 @@ async def _async_reset_energy_counter(hass: HomeAssistant, service: ServiceCall)
|
|||||||
"""Service to reset the energy counter."""
|
"""Service to reset the energy counter."""
|
||||||
entity_id_list = service.data[ATTR_ENTITY_ID]
|
entity_id_list = service.data[ATTR_ENTITY_ID]
|
||||||
|
|
||||||
for hap in hass.data[DOMAIN].values():
|
entry: HomematicIPConfigEntry
|
||||||
|
for entry in hass.config_entries.async_loaded_entries(DOMAIN):
|
||||||
if entity_id_list != "all":
|
if entity_id_list != "all":
|
||||||
for entity_id in entity_id_list:
|
for entity_id in entity_id_list:
|
||||||
device = hap.hmip_device_by_entity_id.get(entity_id)
|
device = entry.runtime_data.hmip_device_by_entity_id.get(entity_id)
|
||||||
if device and isinstance(device, SwitchMeasuring):
|
if device and isinstance(device, SwitchMeasuring):
|
||||||
await device.reset_energy_counter_async()
|
await device.reset_energy_counter_async()
|
||||||
else:
|
else:
|
||||||
for device in hap.home.devices:
|
for device in entry.runtime_data.home.devices:
|
||||||
if isinstance(device, SwitchMeasuring):
|
if isinstance(device, SwitchMeasuring):
|
||||||
await device.reset_energy_counter_async()
|
await device.reset_energy_counter_async()
|
||||||
|
|
||||||
@ -353,14 +363,17 @@ async def _async_set_home_cooling_mode(hass: HomeAssistant, service: ServiceCall
|
|||||||
if home := _get_home(hass, hapid):
|
if home := _get_home(hass, hapid):
|
||||||
await home.set_cooling_async(cooling)
|
await home.set_cooling_async(cooling)
|
||||||
else:
|
else:
|
||||||
for hap in hass.data[DOMAIN].values():
|
entry: HomematicIPConfigEntry
|
||||||
await hap.home.set_cooling_async(cooling)
|
for entry in hass.config_entries.async_loaded_entries(DOMAIN):
|
||||||
|
await entry.runtime_data.home.set_cooling_async(cooling)
|
||||||
|
|
||||||
|
|
||||||
def _get_home(hass: HomeAssistant, hapid: str) -> AsyncHome | None:
|
def _get_home(hass: HomeAssistant, hapid: str) -> AsyncHome | None:
|
||||||
"""Return a HmIP home."""
|
"""Return a HmIP home."""
|
||||||
if hap := hass.data[DOMAIN].get(hapid):
|
entry: HomematicIPConfigEntry
|
||||||
return hap.home
|
for entry in hass.config_entries.async_loaded_entries(DOMAIN):
|
||||||
|
if entry.unique_id == hapid:
|
||||||
|
return entry.runtime_data.home
|
||||||
|
|
||||||
raise ServiceValidationError(
|
raise ServiceValidationError(
|
||||||
translation_domain=DOMAIN,
|
translation_domain=DOMAIN,
|
||||||
|
@ -23,22 +23,20 @@ from homematicip.device import (
|
|||||||
from homematicip.group import ExtendedLinkedSwitchingGroup, SwitchingGroup
|
from homematicip.group import ExtendedLinkedSwitchingGroup, SwitchingGroup
|
||||||
|
|
||||||
from homeassistant.components.switch import SwitchEntity
|
from homeassistant.components.switch import SwitchEntity
|
||||||
from homeassistant.config_entries import ConfigEntry
|
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
||||||
|
|
||||||
from .const import DOMAIN
|
|
||||||
from .entity import ATTR_GROUP_MEMBER_UNREACHABLE, HomematicipGenericEntity
|
from .entity import ATTR_GROUP_MEMBER_UNREACHABLE, HomematicipGenericEntity
|
||||||
from .hap import HomematicipHAP
|
from .hap import HomematicIPConfigEntry, HomematicipHAP
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
config_entry: ConfigEntry,
|
config_entry: HomematicIPConfigEntry,
|
||||||
async_add_entities: AddConfigEntryEntitiesCallback,
|
async_add_entities: AddConfigEntryEntitiesCallback,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Set up the HomematicIP switch from a config entry."""
|
"""Set up the HomematicIP switch from a config entry."""
|
||||||
hap = hass.data[DOMAIN][config_entry.unique_id]
|
hap = config_entry.runtime_data
|
||||||
entities: list[HomematicipGenericEntity] = [
|
entities: list[HomematicipGenericEntity] = [
|
||||||
HomematicipGroupSwitch(hap, group)
|
HomematicipGroupSwitch(hap, group)
|
||||||
for group in hap.home.groups
|
for group in hap.home.groups
|
||||||
|
@ -18,14 +18,12 @@ from homeassistant.components.weather import (
|
|||||||
ATTR_CONDITION_WINDY,
|
ATTR_CONDITION_WINDY,
|
||||||
WeatherEntity,
|
WeatherEntity,
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import ConfigEntry
|
|
||||||
from homeassistant.const import UnitOfSpeed, UnitOfTemperature
|
from homeassistant.const import UnitOfSpeed, UnitOfTemperature
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
||||||
|
|
||||||
from .const import DOMAIN
|
|
||||||
from .entity import HomematicipGenericEntity
|
from .entity import HomematicipGenericEntity
|
||||||
from .hap import HomematicipHAP
|
from .hap import HomematicIPConfigEntry, HomematicipHAP
|
||||||
|
|
||||||
HOME_WEATHER_CONDITION = {
|
HOME_WEATHER_CONDITION = {
|
||||||
WeatherCondition.CLEAR: ATTR_CONDITION_SUNNY,
|
WeatherCondition.CLEAR: ATTR_CONDITION_SUNNY,
|
||||||
@ -48,11 +46,11 @@ HOME_WEATHER_CONDITION = {
|
|||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
config_entry: ConfigEntry,
|
config_entry: HomematicIPConfigEntry,
|
||||||
async_add_entities: AddConfigEntryEntitiesCallback,
|
async_add_entities: AddConfigEntryEntitiesCallback,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Set up the HomematicIP weather sensor from a config entry."""
|
"""Set up the HomematicIP weather sensor from a config entry."""
|
||||||
hap = hass.data[DOMAIN][config_entry.unique_id]
|
hap = config_entry.runtime_data
|
||||||
entities: list[HomematicipGenericEntity] = []
|
entities: list[HomematicipGenericEntity] = []
|
||||||
for device in hap.home.devices:
|
for device in hap.home.devices:
|
||||||
if isinstance(device, WeatherSensorPro):
|
if isinstance(device, WeatherSensorPro):
|
||||||
|
@ -97,7 +97,8 @@ async def mock_hap_with_service_fixture(
|
|||||||
mock_hap = await default_mock_hap_factory.async_get_mock_hap()
|
mock_hap = await default_mock_hap_factory.async_get_mock_hap()
|
||||||
await hmip_async_setup(hass, dummy_config)
|
await hmip_async_setup(hass, dummy_config)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
hass.data[HMIPC_DOMAIN] = {HAPID: mock_hap}
|
entry = hass.config_entries.async_entries(HMIPC_DOMAIN)[0]
|
||||||
|
entry.runtime_data = mock_hap
|
||||||
return mock_hap
|
return mock_hap
|
||||||
|
|
||||||
|
|
||||||
|
@ -120,7 +120,7 @@ class HomeFactory:
|
|||||||
|
|
||||||
await self.hass.async_block_till_done()
|
await self.hass.async_block_till_done()
|
||||||
|
|
||||||
hap = self.hass.data[HMIPC_DOMAIN][HAPID]
|
hap = self.hmip_config_entry.runtime_data
|
||||||
mock_home.on_update(hap.async_update)
|
mock_home.on_update(hap.async_update)
|
||||||
mock_home.on_create(hap.async_create_entity)
|
mock_home.on_create(hap.async_create_entity)
|
||||||
return hap
|
return hap
|
||||||
|
@ -2,13 +2,8 @@
|
|||||||
|
|
||||||
from homematicip.async_home import AsyncHome
|
from homematicip.async_home import AsyncHome
|
||||||
|
|
||||||
from homeassistant.components.alarm_control_panel import (
|
from homeassistant.components.alarm_control_panel import AlarmControlPanelState
|
||||||
DOMAIN as ALARM_CONTROL_PANEL_DOMAIN,
|
|
||||||
AlarmControlPanelState,
|
|
||||||
)
|
|
||||||
from homeassistant.components.homematicip_cloud import DOMAIN as HMIPC_DOMAIN
|
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.setup import async_setup_component
|
|
||||||
|
|
||||||
from .helper import HomeFactory, get_and_check_entity_basics
|
from .helper import HomeFactory, get_and_check_entity_basics
|
||||||
|
|
||||||
@ -39,17 +34,6 @@ async def _async_manipulate_security_zones(
|
|||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
|
|
||||||
async def test_manually_configured_platform(hass: HomeAssistant) -> None:
|
|
||||||
"""Test that we do not set up an access point."""
|
|
||||||
assert await async_setup_component(
|
|
||||||
hass,
|
|
||||||
ALARM_CONTROL_PANEL_DOMAIN,
|
|
||||||
{ALARM_CONTROL_PANEL_DOMAIN: {"platform": HMIPC_DOMAIN}},
|
|
||||||
)
|
|
||||||
|
|
||||||
assert not hass.data.get(HMIPC_DOMAIN)
|
|
||||||
|
|
||||||
|
|
||||||
async def test_hmip_alarm_control_panel(
|
async def test_hmip_alarm_control_panel(
|
||||||
hass: HomeAssistant, default_mock_hap_factory: HomeFactory
|
hass: HomeAssistant, default_mock_hap_factory: HomeFactory
|
||||||
) -> None:
|
) -> None:
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
|
|
||||||
from homematicip.base.enums import SmokeDetectorAlarmType, WindowState
|
from homematicip.base.enums import SmokeDetectorAlarmType, WindowState
|
||||||
|
|
||||||
from homeassistant.components.binary_sensor import DOMAIN as BINARY_SENSOR_DOMAIN
|
|
||||||
from homeassistant.components.homematicip_cloud import DOMAIN as HMIPC_DOMAIN
|
|
||||||
from homeassistant.components.homematicip_cloud.binary_sensor import (
|
from homeassistant.components.homematicip_cloud.binary_sensor import (
|
||||||
ATTR_ACCELERATION_SENSOR_MODE,
|
ATTR_ACCELERATION_SENSOR_MODE,
|
||||||
ATTR_ACCELERATION_SENSOR_NEUTRAL_POSITION,
|
ATTR_ACCELERATION_SENSOR_NEUTRAL_POSITION,
|
||||||
@ -25,21 +23,10 @@ from homeassistant.components.homematicip_cloud.entity import (
|
|||||||
)
|
)
|
||||||
from homeassistant.const import STATE_OFF, STATE_ON, STATE_UNKNOWN
|
from homeassistant.const import STATE_OFF, STATE_ON, STATE_UNKNOWN
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.setup import async_setup_component
|
|
||||||
|
|
||||||
from .helper import HomeFactory, async_manipulate_test_data, get_and_check_entity_basics
|
from .helper import HomeFactory, async_manipulate_test_data, get_and_check_entity_basics
|
||||||
|
|
||||||
|
|
||||||
async def test_manually_configured_platform(hass: HomeAssistant) -> None:
|
|
||||||
"""Test that we do not set up an access point."""
|
|
||||||
assert await async_setup_component(
|
|
||||||
hass,
|
|
||||||
BINARY_SENSOR_DOMAIN,
|
|
||||||
{BINARY_SENSOR_DOMAIN: {"platform": HMIPC_DOMAIN}},
|
|
||||||
)
|
|
||||||
assert not hass.data.get(HMIPC_DOMAIN)
|
|
||||||
|
|
||||||
|
|
||||||
async def test_hmip_home_cloud_connection_sensor(
|
async def test_hmip_home_cloud_connection_sensor(
|
||||||
hass: HomeAssistant, default_mock_hap_factory: HomeFactory
|
hass: HomeAssistant, default_mock_hap_factory: HomeFactory
|
||||||
) -> None:
|
) -> None:
|
||||||
|
@ -12,7 +12,6 @@ from homeassistant.components.climate import (
|
|||||||
ATTR_HVAC_ACTION,
|
ATTR_HVAC_ACTION,
|
||||||
ATTR_PRESET_MODE,
|
ATTR_PRESET_MODE,
|
||||||
ATTR_PRESET_MODES,
|
ATTR_PRESET_MODES,
|
||||||
DOMAIN as CLIMATE_DOMAIN,
|
|
||||||
PRESET_AWAY,
|
PRESET_AWAY,
|
||||||
PRESET_BOOST,
|
PRESET_BOOST,
|
||||||
PRESET_ECO,
|
PRESET_ECO,
|
||||||
@ -26,7 +25,6 @@ from homeassistant.components.homematicip_cloud.climate import (
|
|||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.exceptions import ServiceValidationError
|
from homeassistant.exceptions import ServiceValidationError
|
||||||
from homeassistant.setup import async_setup_component
|
|
||||||
|
|
||||||
from .helper import (
|
from .helper import (
|
||||||
HAPID,
|
HAPID,
|
||||||
@ -36,14 +34,6 @@ from .helper import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
async def test_manually_configured_platform(hass: HomeAssistant) -> None:
|
|
||||||
"""Test that we do not set up an access point."""
|
|
||||||
assert await async_setup_component(
|
|
||||||
hass, CLIMATE_DOMAIN, {CLIMATE_DOMAIN: {"platform": HMIPC_DOMAIN}}
|
|
||||||
)
|
|
||||||
assert not hass.data.get(HMIPC_DOMAIN)
|
|
||||||
|
|
||||||
|
|
||||||
async def test_hmip_heating_group_heat(
|
async def test_hmip_heating_group_heat(
|
||||||
hass: HomeAssistant, default_mock_hap_factory: HomeFactory
|
hass: HomeAssistant, default_mock_hap_factory: HomeFactory
|
||||||
) -> None:
|
) -> None:
|
||||||
|
@ -5,25 +5,14 @@ from homematicip.base.enums import DoorCommand, DoorState
|
|||||||
from homeassistant.components.cover import (
|
from homeassistant.components.cover import (
|
||||||
ATTR_CURRENT_POSITION,
|
ATTR_CURRENT_POSITION,
|
||||||
ATTR_CURRENT_TILT_POSITION,
|
ATTR_CURRENT_TILT_POSITION,
|
||||||
DOMAIN as COVER_DOMAIN,
|
|
||||||
CoverState,
|
CoverState,
|
||||||
)
|
)
|
||||||
from homeassistant.components.homematicip_cloud import DOMAIN as HMIPC_DOMAIN
|
|
||||||
from homeassistant.const import STATE_UNKNOWN
|
from homeassistant.const import STATE_UNKNOWN
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.setup import async_setup_component
|
|
||||||
|
|
||||||
from .helper import HomeFactory, async_manipulate_test_data, get_and_check_entity_basics
|
from .helper import HomeFactory, async_manipulate_test_data, get_and_check_entity_basics
|
||||||
|
|
||||||
|
|
||||||
async def test_manually_configured_platform(hass: HomeAssistant) -> None:
|
|
||||||
"""Test that we do not set up an access point."""
|
|
||||||
assert await async_setup_component(
|
|
||||||
hass, COVER_DOMAIN, {COVER_DOMAIN: {"platform": HMIPC_DOMAIN}}
|
|
||||||
)
|
|
||||||
assert not hass.data.get(HMIPC_DOMAIN)
|
|
||||||
|
|
||||||
|
|
||||||
async def test_hmip_cover_shutter(
|
async def test_hmip_cover_shutter(
|
||||||
hass: HomeAssistant, default_mock_hap_factory: HomeFactory
|
hass: HomeAssistant, default_mock_hap_factory: HomeFactory
|
||||||
) -> None:
|
) -> None:
|
||||||
|
@ -4,18 +4,12 @@ from unittest.mock import patch
|
|||||||
|
|
||||||
from homematicip.base.enums import EventType
|
from homematicip.base.enums import EventType
|
||||||
|
|
||||||
from homeassistant.components.homematicip_cloud import DOMAIN as HMIPC_DOMAIN
|
|
||||||
from homeassistant.components.homematicip_cloud.hap import HomematicipHAP
|
from homeassistant.components.homematicip_cloud.hap import HomematicipHAP
|
||||||
from homeassistant.const import STATE_ON, STATE_UNAVAILABLE
|
from homeassistant.const import STATE_ON, STATE_UNAVAILABLE
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
||||||
|
|
||||||
from .helper import (
|
from .helper import HomeFactory, async_manipulate_test_data, get_and_check_entity_basics
|
||||||
HAPID,
|
|
||||||
HomeFactory,
|
|
||||||
async_manipulate_test_data,
|
|
||||||
get_and_check_entity_basics,
|
|
||||||
)
|
|
||||||
|
|
||||||
from tests.common import MockConfigEntry
|
from tests.common import MockConfigEntry
|
||||||
|
|
||||||
@ -115,7 +109,7 @@ async def test_hmip_add_device(
|
|||||||
|
|
||||||
assert len(device_registry.devices) == pre_device_count
|
assert len(device_registry.devices) == pre_device_count
|
||||||
assert len(entity_registry.entities) == pre_entity_count
|
assert len(entity_registry.entities) == pre_entity_count
|
||||||
new_hap = hass.data[HMIPC_DOMAIN][HAPID]
|
new_hap = hmip_config_entry.runtime_data
|
||||||
assert len(new_hap.hmip_device_by_entity_id) == pre_mapping_count
|
assert len(new_hap.hmip_device_by_entity_id) == pre_mapping_count
|
||||||
|
|
||||||
|
|
||||||
|
@ -119,14 +119,13 @@ async def test_hap_reset_unloads_entry_if_setup(
|
|||||||
) -> None:
|
) -> None:
|
||||||
"""Test calling reset while the entry has been setup."""
|
"""Test calling reset while the entry has been setup."""
|
||||||
mock_hap = await default_mock_hap_factory.async_get_mock_hap()
|
mock_hap = await default_mock_hap_factory.async_get_mock_hap()
|
||||||
assert hass.data[HMIPC_DOMAIN][HAPID] == mock_hap
|
|
||||||
config_entries = hass.config_entries.async_entries(HMIPC_DOMAIN)
|
config_entries = hass.config_entries.async_entries(HMIPC_DOMAIN)
|
||||||
assert len(config_entries) == 1
|
assert len(config_entries) == 1
|
||||||
|
assert config_entries[0].runtime_data == mock_hap
|
||||||
# hap_reset is called during unload
|
# hap_reset is called during unload
|
||||||
await hass.config_entries.async_unload(config_entries[0].entry_id)
|
await hass.config_entries.async_unload(config_entries[0].entry_id)
|
||||||
# entry is unloaded
|
# entry is unloaded
|
||||||
assert config_entries[0].state is ConfigEntryState.NOT_LOADED
|
assert config_entries[0].state is ConfigEntryState.NOT_LOADED
|
||||||
assert hass.data[HMIPC_DOMAIN] == {}
|
|
||||||
|
|
||||||
|
|
||||||
async def test_hap_create(
|
async def test_hap_create(
|
||||||
|
@ -34,8 +34,6 @@ async def test_config_with_accesspoint_passed_to_config_entry(
|
|||||||
}
|
}
|
||||||
# no config_entry exists
|
# no config_entry exists
|
||||||
assert len(hass.config_entries.async_entries(HMIPC_DOMAIN)) == 0
|
assert len(hass.config_entries.async_entries(HMIPC_DOMAIN)) == 0
|
||||||
# no acccesspoint exists
|
|
||||||
assert not hass.data.get(HMIPC_DOMAIN)
|
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.homematicip_cloud.hap.HomematicipHAP.async_connect",
|
"homeassistant.components.homematicip_cloud.hap.HomematicipHAP.async_connect",
|
||||||
@ -53,7 +51,7 @@ async def test_config_with_accesspoint_passed_to_config_entry(
|
|||||||
"name": "name",
|
"name": "name",
|
||||||
}
|
}
|
||||||
# defined access_point created for config_entry
|
# defined access_point created for config_entry
|
||||||
assert isinstance(hass.data[HMIPC_DOMAIN]["ABC123"], HomematicipHAP)
|
assert isinstance(config_entries[0].runtime_data, HomematicipHAP)
|
||||||
|
|
||||||
|
|
||||||
async def test_config_already_registered_not_passed_to_config_entry(
|
async def test_config_already_registered_not_passed_to_config_entry(
|
||||||
@ -118,7 +116,7 @@ async def test_load_entry_fails_due_to_connection_error(
|
|||||||
):
|
):
|
||||||
assert await async_setup_component(hass, HMIPC_DOMAIN, {})
|
assert await async_setup_component(hass, HMIPC_DOMAIN, {})
|
||||||
|
|
||||||
assert hass.data[HMIPC_DOMAIN][hmip_config_entry.unique_id]
|
assert hmip_config_entry.runtime_data
|
||||||
assert hmip_config_entry.state is ConfigEntryState.SETUP_RETRY
|
assert hmip_config_entry.state is ConfigEntryState.SETUP_RETRY
|
||||||
|
|
||||||
|
|
||||||
@ -136,7 +134,7 @@ async def test_load_entry_fails_due_to_generic_exception(
|
|||||||
):
|
):
|
||||||
assert await async_setup_component(hass, HMIPC_DOMAIN, {})
|
assert await async_setup_component(hass, HMIPC_DOMAIN, {})
|
||||||
|
|
||||||
assert hass.data[HMIPC_DOMAIN][hmip_config_entry.unique_id]
|
assert hmip_config_entry.runtime_data
|
||||||
assert hmip_config_entry.state is ConfigEntryState.SETUP_ERROR
|
assert hmip_config_entry.state is ConfigEntryState.SETUP_ERROR
|
||||||
|
|
||||||
|
|
||||||
@ -159,14 +157,12 @@ async def test_unload_entry(hass: HomeAssistant) -> None:
|
|||||||
|
|
||||||
assert mock_hap.return_value.mock_calls[0][0] == "async_setup"
|
assert mock_hap.return_value.mock_calls[0][0] == "async_setup"
|
||||||
|
|
||||||
assert hass.data[HMIPC_DOMAIN]["ABC123"]
|
|
||||||
config_entries = hass.config_entries.async_entries(HMIPC_DOMAIN)
|
config_entries = hass.config_entries.async_entries(HMIPC_DOMAIN)
|
||||||
assert len(config_entries) == 1
|
assert len(config_entries) == 1
|
||||||
|
assert config_entries[0].runtime_data
|
||||||
assert config_entries[0].state is ConfigEntryState.LOADED
|
assert config_entries[0].state is ConfigEntryState.LOADED
|
||||||
await hass.config_entries.async_unload(config_entries[0].entry_id)
|
await hass.config_entries.async_unload(config_entries[0].entry_id)
|
||||||
assert config_entries[0].state is ConfigEntryState.NOT_LOADED
|
assert config_entries[0].state is ConfigEntryState.NOT_LOADED
|
||||||
# entry is unloaded
|
|
||||||
assert hass.data[HMIPC_DOMAIN] == {}
|
|
||||||
|
|
||||||
|
|
||||||
async def test_hmip_dump_hap_config_services(
|
async def test_hmip_dump_hap_config_services(
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
from homematicip.base.enums import OpticalSignalBehaviour, RGBColorState
|
from homematicip.base.enums import OpticalSignalBehaviour, RGBColorState
|
||||||
|
|
||||||
from homeassistant.components.homematicip_cloud import DOMAIN as HMIPC_DOMAIN
|
|
||||||
from homeassistant.components.light import (
|
from homeassistant.components.light import (
|
||||||
ATTR_BRIGHTNESS,
|
ATTR_BRIGHTNESS,
|
||||||
ATTR_COLOR_MODE,
|
ATTR_COLOR_MODE,
|
||||||
@ -10,25 +9,15 @@ from homeassistant.components.light import (
|
|||||||
ATTR_EFFECT,
|
ATTR_EFFECT,
|
||||||
ATTR_HS_COLOR,
|
ATTR_HS_COLOR,
|
||||||
ATTR_SUPPORTED_COLOR_MODES,
|
ATTR_SUPPORTED_COLOR_MODES,
|
||||||
DOMAIN as LIGHT_DOMAIN,
|
|
||||||
ColorMode,
|
ColorMode,
|
||||||
LightEntityFeature,
|
LightEntityFeature,
|
||||||
)
|
)
|
||||||
from homeassistant.const import ATTR_SUPPORTED_FEATURES, STATE_OFF, STATE_ON
|
from homeassistant.const import ATTR_SUPPORTED_FEATURES, STATE_OFF, STATE_ON
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.setup import async_setup_component
|
|
||||||
|
|
||||||
from .helper import HomeFactory, async_manipulate_test_data, get_and_check_entity_basics
|
from .helper import HomeFactory, async_manipulate_test_data, get_and_check_entity_basics
|
||||||
|
|
||||||
|
|
||||||
async def test_manually_configured_platform(hass: HomeAssistant) -> None:
|
|
||||||
"""Test that we do not set up an access point."""
|
|
||||||
assert await async_setup_component(
|
|
||||||
hass, LIGHT_DOMAIN, {LIGHT_DOMAIN: {"platform": HMIPC_DOMAIN}}
|
|
||||||
)
|
|
||||||
assert not hass.data.get(HMIPC_DOMAIN)
|
|
||||||
|
|
||||||
|
|
||||||
async def test_hmip_light(
|
async def test_hmip_light(
|
||||||
hass: HomeAssistant, default_mock_hap_factory: HomeFactory
|
hass: HomeAssistant, default_mock_hap_factory: HomeFactory
|
||||||
) -> None:
|
) -> None:
|
||||||
|
@ -5,28 +5,14 @@ from unittest.mock import patch
|
|||||||
from homematicip.base.enums import LockState as HomematicLockState, MotorState
|
from homematicip.base.enums import LockState as HomematicLockState, MotorState
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant.components.homematicip_cloud import DOMAIN as HMIPC_DOMAIN
|
from homeassistant.components.lock import LockEntityFeature, LockState
|
||||||
from homeassistant.components.lock import (
|
|
||||||
DOMAIN as LOCK_DOMAIN,
|
|
||||||
LockEntityFeature,
|
|
||||||
LockState,
|
|
||||||
)
|
|
||||||
from homeassistant.const import ATTR_SUPPORTED_FEATURES
|
from homeassistant.const import ATTR_SUPPORTED_FEATURES
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.exceptions import HomeAssistantError
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
from homeassistant.setup import async_setup_component
|
|
||||||
|
|
||||||
from .helper import HomeFactory, async_manipulate_test_data, get_and_check_entity_basics
|
from .helper import HomeFactory, async_manipulate_test_data, get_and_check_entity_basics
|
||||||
|
|
||||||
|
|
||||||
async def test_manually_configured_platform(hass: HomeAssistant) -> None:
|
|
||||||
"""Test that we do not set up an access point."""
|
|
||||||
assert await async_setup_component(
|
|
||||||
hass, LOCK_DOMAIN, {LOCK_DOMAIN: {"platform": HMIPC_DOMAIN}}
|
|
||||||
)
|
|
||||||
assert not hass.data.get(HMIPC_DOMAIN)
|
|
||||||
|
|
||||||
|
|
||||||
async def test_hmip_doorlockdrive(
|
async def test_hmip_doorlockdrive(
|
||||||
hass: HomeAssistant, default_mock_hap_factory: HomeFactory
|
hass: HomeAssistant, default_mock_hap_factory: HomeFactory
|
||||||
) -> None:
|
) -> None:
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
from homematicip.base.enums import ValveState
|
from homematicip.base.enums import ValveState
|
||||||
|
|
||||||
from homeassistant.components.homematicip_cloud import DOMAIN as HMIPC_DOMAIN
|
|
||||||
from homeassistant.components.homematicip_cloud.entity import (
|
from homeassistant.components.homematicip_cloud.entity import (
|
||||||
ATTR_CONFIG_PENDING,
|
ATTR_CONFIG_PENDING,
|
||||||
ATTR_DEVICE_OVERHEATED,
|
ATTR_DEVICE_OVERHEATED,
|
||||||
@ -23,11 +22,7 @@ from homeassistant.components.homematicip_cloud.sensor import (
|
|||||||
ATTR_WIND_DIRECTION,
|
ATTR_WIND_DIRECTION,
|
||||||
ATTR_WIND_DIRECTION_VARIATION,
|
ATTR_WIND_DIRECTION_VARIATION,
|
||||||
)
|
)
|
||||||
from homeassistant.components.sensor import (
|
from homeassistant.components.sensor import ATTR_STATE_CLASS, SensorStateClass
|
||||||
ATTR_STATE_CLASS,
|
|
||||||
DOMAIN as SENSOR_DOMAIN,
|
|
||||||
SensorStateClass,
|
|
||||||
)
|
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
ATTR_UNIT_OF_MEASUREMENT,
|
ATTR_UNIT_OF_MEASUREMENT,
|
||||||
LIGHT_LUX,
|
LIGHT_LUX,
|
||||||
@ -39,19 +34,10 @@ from homeassistant.const import (
|
|||||||
UnitOfTemperature,
|
UnitOfTemperature,
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.setup import async_setup_component
|
|
||||||
|
|
||||||
from .helper import HomeFactory, async_manipulate_test_data, get_and_check_entity_basics
|
from .helper import HomeFactory, async_manipulate_test_data, get_and_check_entity_basics
|
||||||
|
|
||||||
|
|
||||||
async def test_manually_configured_platform(hass: HomeAssistant) -> None:
|
|
||||||
"""Test that we do not set up an access point."""
|
|
||||||
assert await async_setup_component(
|
|
||||||
hass, SENSOR_DOMAIN, {SENSOR_DOMAIN: {"platform": HMIPC_DOMAIN}}
|
|
||||||
)
|
|
||||||
assert not hass.data.get(HMIPC_DOMAIN)
|
|
||||||
|
|
||||||
|
|
||||||
async def test_hmip_accesspoint_status(
|
async def test_hmip_accesspoint_status(
|
||||||
hass: HomeAssistant, default_mock_hap_factory: HomeFactory
|
hass: HomeAssistant, default_mock_hap_factory: HomeFactory
|
||||||
) -> None:
|
) -> None:
|
||||||
|
@ -1,25 +1,14 @@
|
|||||||
"""Tests for HomematicIP Cloud switch."""
|
"""Tests for HomematicIP Cloud switch."""
|
||||||
|
|
||||||
from homeassistant.components.homematicip_cloud import DOMAIN as HMIPC_DOMAIN
|
|
||||||
from homeassistant.components.homematicip_cloud.entity import (
|
from homeassistant.components.homematicip_cloud.entity import (
|
||||||
ATTR_GROUP_MEMBER_UNREACHABLE,
|
ATTR_GROUP_MEMBER_UNREACHABLE,
|
||||||
)
|
)
|
||||||
from homeassistant.components.switch import DOMAIN as SWITCH_DOMAIN
|
|
||||||
from homeassistant.const import STATE_OFF, STATE_ON
|
from homeassistant.const import STATE_OFF, STATE_ON
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.setup import async_setup_component
|
|
||||||
|
|
||||||
from .helper import HomeFactory, async_manipulate_test_data, get_and_check_entity_basics
|
from .helper import HomeFactory, async_manipulate_test_data, get_and_check_entity_basics
|
||||||
|
|
||||||
|
|
||||||
async def test_manually_configured_platform(hass: HomeAssistant) -> None:
|
|
||||||
"""Test that we do not set up an access point."""
|
|
||||||
assert await async_setup_component(
|
|
||||||
hass, SWITCH_DOMAIN, {SWITCH_DOMAIN: {"platform": HMIPC_DOMAIN}}
|
|
||||||
)
|
|
||||||
assert not hass.data.get(HMIPC_DOMAIN)
|
|
||||||
|
|
||||||
|
|
||||||
async def test_hmip_switch(
|
async def test_hmip_switch(
|
||||||
hass: HomeAssistant, default_mock_hap_factory: HomeFactory
|
hass: HomeAssistant, default_mock_hap_factory: HomeFactory
|
||||||
) -> None:
|
) -> None:
|
||||||
|
@ -1,28 +1,17 @@
|
|||||||
"""Tests for HomematicIP Cloud weather."""
|
"""Tests for HomematicIP Cloud weather."""
|
||||||
|
|
||||||
from homeassistant.components.homematicip_cloud import DOMAIN as HMIPC_DOMAIN
|
|
||||||
from homeassistant.components.weather import (
|
from homeassistant.components.weather import (
|
||||||
ATTR_WEATHER_HUMIDITY,
|
ATTR_WEATHER_HUMIDITY,
|
||||||
ATTR_WEATHER_TEMPERATURE,
|
ATTR_WEATHER_TEMPERATURE,
|
||||||
ATTR_WEATHER_WIND_BEARING,
|
ATTR_WEATHER_WIND_BEARING,
|
||||||
ATTR_WEATHER_WIND_SPEED,
|
ATTR_WEATHER_WIND_SPEED,
|
||||||
DOMAIN as WEATHER_DOMAIN,
|
|
||||||
)
|
)
|
||||||
from homeassistant.const import ATTR_ATTRIBUTION
|
from homeassistant.const import ATTR_ATTRIBUTION
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.setup import async_setup_component
|
|
||||||
|
|
||||||
from .helper import HomeFactory, async_manipulate_test_data, get_and_check_entity_basics
|
from .helper import HomeFactory, async_manipulate_test_data, get_and_check_entity_basics
|
||||||
|
|
||||||
|
|
||||||
async def test_manually_configured_platform(hass: HomeAssistant) -> None:
|
|
||||||
"""Test that we do not set up an access point."""
|
|
||||||
assert await async_setup_component(
|
|
||||||
hass, WEATHER_DOMAIN, {WEATHER_DOMAIN: {"platform": HMIPC_DOMAIN}}
|
|
||||||
)
|
|
||||||
assert not hass.data.get(HMIPC_DOMAIN)
|
|
||||||
|
|
||||||
|
|
||||||
async def test_hmip_weather_sensor(
|
async def test_hmip_weather_sensor(
|
||||||
hass: HomeAssistant, default_mock_hap_factory: HomeFactory
|
hass: HomeAssistant, default_mock_hap_factory: HomeFactory
|
||||||
) -> None:
|
) -> None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user