mirror of
https://github.com/home-assistant/core.git
synced 2025-07-17 18:27:09 +00:00
Refactor homematicip_cloud connection (#139081)
This commit is contained in:
parent
83c3275054
commit
6d74a6aa19
@ -82,15 +82,15 @@ class HomematicipAlarmControlPanelEntity(AlarmControlPanelEntity):
|
|||||||
|
|
||||||
async def async_alarm_disarm(self, code: str | None = None) -> None:
|
async def async_alarm_disarm(self, code: str | None = None) -> None:
|
||||||
"""Send disarm command."""
|
"""Send disarm command."""
|
||||||
await self._home.set_security_zones_activation(False, False)
|
await self._home.set_security_zones_activation_async(False, False)
|
||||||
|
|
||||||
async def async_alarm_arm_home(self, code: str | None = None) -> None:
|
async def async_alarm_arm_home(self, code: str | None = None) -> None:
|
||||||
"""Send arm home command."""
|
"""Send arm home command."""
|
||||||
await self._home.set_security_zones_activation(False, True)
|
await self._home.set_security_zones_activation_async(False, True)
|
||||||
|
|
||||||
async def async_alarm_arm_away(self, code: str | None = None) -> None:
|
async def async_alarm_arm_away(self, code: str | None = None) -> None:
|
||||||
"""Send arm away command."""
|
"""Send arm away command."""
|
||||||
await self._home.set_security_zones_activation(True, True)
|
await self._home.set_security_zones_activation_async(True, True)
|
||||||
|
|
||||||
async def async_added_to_hass(self) -> None:
|
async def async_added_to_hass(self) -> None:
|
||||||
"""Register callbacks."""
|
"""Register callbacks."""
|
||||||
|
@ -4,31 +4,31 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from homematicip.aio.device import (
|
|
||||||
AsyncAccelerationSensor,
|
|
||||||
AsyncContactInterface,
|
|
||||||
AsyncDevice,
|
|
||||||
AsyncFullFlushContactInterface,
|
|
||||||
AsyncFullFlushContactInterface6,
|
|
||||||
AsyncMotionDetectorIndoor,
|
|
||||||
AsyncMotionDetectorOutdoor,
|
|
||||||
AsyncMotionDetectorPushButton,
|
|
||||||
AsyncPluggableMainsFailureSurveillance,
|
|
||||||
AsyncPresenceDetectorIndoor,
|
|
||||||
AsyncRainSensor,
|
|
||||||
AsyncRotaryHandleSensor,
|
|
||||||
AsyncShutterContact,
|
|
||||||
AsyncShutterContactMagnetic,
|
|
||||||
AsyncSmokeDetector,
|
|
||||||
AsyncTiltVibrationSensor,
|
|
||||||
AsyncWaterSensor,
|
|
||||||
AsyncWeatherSensor,
|
|
||||||
AsyncWeatherSensorPlus,
|
|
||||||
AsyncWeatherSensorPro,
|
|
||||||
AsyncWiredInput32,
|
|
||||||
)
|
|
||||||
from homematicip.aio.group import AsyncSecurityGroup, AsyncSecurityZoneGroup
|
|
||||||
from homematicip.base.enums import SmokeDetectorAlarmType, WindowState
|
from homematicip.base.enums import SmokeDetectorAlarmType, WindowState
|
||||||
|
from homematicip.device import (
|
||||||
|
AccelerationSensor,
|
||||||
|
ContactInterface,
|
||||||
|
Device,
|
||||||
|
FullFlushContactInterface,
|
||||||
|
FullFlushContactInterface6,
|
||||||
|
MotionDetectorIndoor,
|
||||||
|
MotionDetectorOutdoor,
|
||||||
|
MotionDetectorPushButton,
|
||||||
|
PluggableMainsFailureSurveillance,
|
||||||
|
PresenceDetectorIndoor,
|
||||||
|
RainSensor,
|
||||||
|
RotaryHandleSensor,
|
||||||
|
ShutterContact,
|
||||||
|
ShutterContactMagnetic,
|
||||||
|
SmokeDetector,
|
||||||
|
TiltVibrationSensor,
|
||||||
|
WaterSensor,
|
||||||
|
WeatherSensor,
|
||||||
|
WeatherSensorPlus,
|
||||||
|
WeatherSensorPro,
|
||||||
|
WiredInput32,
|
||||||
|
)
|
||||||
|
from homematicip.group import SecurityGroup, SecurityZoneGroup
|
||||||
|
|
||||||
from homeassistant.components.binary_sensor import (
|
from homeassistant.components.binary_sensor import (
|
||||||
BinarySensorDeviceClass,
|
BinarySensorDeviceClass,
|
||||||
@ -82,66 +82,60 @@ async def async_setup_entry(
|
|||||||
hap = hass.data[DOMAIN][config_entry.unique_id]
|
hap = hass.data[DOMAIN][config_entry.unique_id]
|
||||||
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, AsyncAccelerationSensor):
|
if isinstance(device, AccelerationSensor):
|
||||||
entities.append(HomematicipAccelerationSensor(hap, device))
|
entities.append(HomematicipAccelerationSensor(hap, device))
|
||||||
if isinstance(device, AsyncTiltVibrationSensor):
|
if isinstance(device, TiltVibrationSensor):
|
||||||
entities.append(HomematicipTiltVibrationSensor(hap, device))
|
entities.append(HomematicipTiltVibrationSensor(hap, device))
|
||||||
if isinstance(device, AsyncWiredInput32):
|
if isinstance(device, WiredInput32):
|
||||||
entities.extend(
|
entities.extend(
|
||||||
HomematicipMultiContactInterface(hap, device, channel=channel)
|
HomematicipMultiContactInterface(hap, device, channel=channel)
|
||||||
for channel in range(1, 33)
|
for channel in range(1, 33)
|
||||||
)
|
)
|
||||||
elif isinstance(device, AsyncFullFlushContactInterface6):
|
elif isinstance(device, FullFlushContactInterface6):
|
||||||
entities.extend(
|
entities.extend(
|
||||||
HomematicipMultiContactInterface(hap, device, channel=channel)
|
HomematicipMultiContactInterface(hap, device, channel=channel)
|
||||||
for channel in range(1, 7)
|
for channel in range(1, 7)
|
||||||
)
|
)
|
||||||
elif isinstance(
|
elif isinstance(device, (ContactInterface, FullFlushContactInterface)):
|
||||||
device, (AsyncContactInterface, AsyncFullFlushContactInterface)
|
|
||||||
):
|
|
||||||
entities.append(HomematicipContactInterface(hap, device))
|
entities.append(HomematicipContactInterface(hap, device))
|
||||||
if isinstance(
|
if isinstance(
|
||||||
device,
|
device,
|
||||||
(AsyncShutterContact, AsyncShutterContactMagnetic),
|
(ShutterContact, ShutterContactMagnetic),
|
||||||
):
|
):
|
||||||
entities.append(HomematicipShutterContact(hap, device))
|
entities.append(HomematicipShutterContact(hap, device))
|
||||||
if isinstance(device, AsyncRotaryHandleSensor):
|
if isinstance(device, RotaryHandleSensor):
|
||||||
entities.append(HomematicipShutterContact(hap, device, True))
|
entities.append(HomematicipShutterContact(hap, device, True))
|
||||||
if isinstance(
|
if isinstance(
|
||||||
device,
|
device,
|
||||||
(
|
(
|
||||||
AsyncMotionDetectorIndoor,
|
MotionDetectorIndoor,
|
||||||
AsyncMotionDetectorOutdoor,
|
MotionDetectorOutdoor,
|
||||||
AsyncMotionDetectorPushButton,
|
MotionDetectorPushButton,
|
||||||
),
|
),
|
||||||
):
|
):
|
||||||
entities.append(HomematicipMotionDetector(hap, device))
|
entities.append(HomematicipMotionDetector(hap, device))
|
||||||
if isinstance(device, AsyncPluggableMainsFailureSurveillance):
|
if isinstance(device, PluggableMainsFailureSurveillance):
|
||||||
entities.append(
|
entities.append(
|
||||||
HomematicipPluggableMainsFailureSurveillanceSensor(hap, device)
|
HomematicipPluggableMainsFailureSurveillanceSensor(hap, device)
|
||||||
)
|
)
|
||||||
if isinstance(device, AsyncPresenceDetectorIndoor):
|
if isinstance(device, PresenceDetectorIndoor):
|
||||||
entities.append(HomematicipPresenceDetector(hap, device))
|
entities.append(HomematicipPresenceDetector(hap, device))
|
||||||
if isinstance(device, AsyncSmokeDetector):
|
if isinstance(device, SmokeDetector):
|
||||||
entities.append(HomematicipSmokeDetector(hap, device))
|
entities.append(HomematicipSmokeDetector(hap, device))
|
||||||
if isinstance(device, AsyncWaterSensor):
|
if isinstance(device, WaterSensor):
|
||||||
entities.append(HomematicipWaterDetector(hap, device))
|
entities.append(HomematicipWaterDetector(hap, device))
|
||||||
if isinstance(
|
if isinstance(device, (RainSensor, WeatherSensorPlus, WeatherSensorPro)):
|
||||||
device, (AsyncRainSensor, AsyncWeatherSensorPlus, AsyncWeatherSensorPro)
|
|
||||||
):
|
|
||||||
entities.append(HomematicipRainSensor(hap, device))
|
entities.append(HomematicipRainSensor(hap, device))
|
||||||
if isinstance(
|
if isinstance(device, (WeatherSensor, WeatherSensorPlus, WeatherSensorPro)):
|
||||||
device, (AsyncWeatherSensor, AsyncWeatherSensorPlus, AsyncWeatherSensorPro)
|
|
||||||
):
|
|
||||||
entities.append(HomematicipStormSensor(hap, device))
|
entities.append(HomematicipStormSensor(hap, device))
|
||||||
entities.append(HomematicipSunshineSensor(hap, device))
|
entities.append(HomematicipSunshineSensor(hap, device))
|
||||||
if isinstance(device, AsyncDevice) and device.lowBat is not None:
|
if isinstance(device, Device) and device.lowBat is not None:
|
||||||
entities.append(HomematicipBatterySensor(hap, device))
|
entities.append(HomematicipBatterySensor(hap, device))
|
||||||
|
|
||||||
for group in hap.home.groups:
|
for group in hap.home.groups:
|
||||||
if isinstance(group, AsyncSecurityGroup):
|
if isinstance(group, SecurityGroup):
|
||||||
entities.append(HomematicipSecuritySensorGroup(hap, device=group))
|
entities.append(HomematicipSecuritySensorGroup(hap, device=group))
|
||||||
elif isinstance(group, AsyncSecurityZoneGroup):
|
elif isinstance(group, SecurityZoneGroup):
|
||||||
entities.append(HomematicipSecurityZoneSensorGroup(hap, device=group))
|
entities.append(HomematicipSecurityZoneSensorGroup(hap, device=group))
|
||||||
|
|
||||||
async_add_entities(entities)
|
async_add_entities(entities)
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from homematicip.aio.device import AsyncWallMountedGarageDoorController
|
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.config_entries import ConfigEntry
|
||||||
@ -25,7 +25,7 @@ async def async_setup_entry(
|
|||||||
async_add_entities(
|
async_add_entities(
|
||||||
HomematicipGarageDoorControllerButton(hap, device)
|
HomematicipGarageDoorControllerButton(hap, device)
|
||||||
for device in hap.home.devices
|
for device in hap.home.devices
|
||||||
if isinstance(device, AsyncWallMountedGarageDoorController)
|
if isinstance(device, WallMountedGarageDoorController)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -39,4 +39,4 @@ class HomematicipGarageDoorControllerButton(HomematicipGenericEntity, ButtonEnti
|
|||||||
|
|
||||||
async def async_press(self) -> None:
|
async def async_press(self) -> None:
|
||||||
"""Handle the button press."""
|
"""Handle the button press."""
|
||||||
await self._device.send_start_impulse()
|
await self._device.send_start_impulse_async()
|
||||||
|
@ -4,16 +4,15 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from homematicip.aio.device import (
|
|
||||||
AsyncHeatingThermostat,
|
|
||||||
AsyncHeatingThermostatCompact,
|
|
||||||
AsyncHeatingThermostatEvo,
|
|
||||||
)
|
|
||||||
from homematicip.aio.group import AsyncHeatingGroup
|
|
||||||
from homematicip.base.enums import AbsenceType
|
from homematicip.base.enums import AbsenceType
|
||||||
from homematicip.device import Switch
|
from homematicip.device import (
|
||||||
|
HeatingThermostat,
|
||||||
|
HeatingThermostatCompact,
|
||||||
|
HeatingThermostatEvo,
|
||||||
|
Switch,
|
||||||
|
)
|
||||||
from homematicip.functionalHomes import IndoorClimateHome
|
from homematicip.functionalHomes import IndoorClimateHome
|
||||||
from homematicip.group import HeatingCoolingProfile
|
from homematicip.group import HeatingCoolingProfile, HeatingGroup
|
||||||
|
|
||||||
from homeassistant.components.climate import (
|
from homeassistant.components.climate import (
|
||||||
PRESET_AWAY,
|
PRESET_AWAY,
|
||||||
@ -65,7 +64,7 @@ async def async_setup_entry(
|
|||||||
async_add_entities(
|
async_add_entities(
|
||||||
HomematicipHeatingGroup(hap, device)
|
HomematicipHeatingGroup(hap, device)
|
||||||
for device in hap.home.groups
|
for device in hap.home.groups
|
||||||
if isinstance(device, AsyncHeatingGroup)
|
if isinstance(device, HeatingGroup)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -82,7 +81,7 @@ class HomematicipHeatingGroup(HomematicipGenericEntity, ClimateEntity):
|
|||||||
)
|
)
|
||||||
_attr_temperature_unit = UnitOfTemperature.CELSIUS
|
_attr_temperature_unit = UnitOfTemperature.CELSIUS
|
||||||
|
|
||||||
def __init__(self, hap: HomematicipHAP, device: AsyncHeatingGroup) -> None:
|
def __init__(self, hap: HomematicipHAP, device: HeatingGroup) -> None:
|
||||||
"""Initialize heating group."""
|
"""Initialize heating group."""
|
||||||
device.modelType = "HmIP-Heating-Group"
|
device.modelType = "HmIP-Heating-Group"
|
||||||
super().__init__(hap, device)
|
super().__init__(hap, device)
|
||||||
@ -214,7 +213,7 @@ class HomematicipHeatingGroup(HomematicipGenericEntity, ClimateEntity):
|
|||||||
return
|
return
|
||||||
|
|
||||||
if self.min_temp <= temperature <= self.max_temp:
|
if self.min_temp <= temperature <= self.max_temp:
|
||||||
await self._device.set_point_temperature(temperature)
|
await self._device.set_point_temperature_async(temperature)
|
||||||
|
|
||||||
async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None:
|
async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None:
|
||||||
"""Set new target hvac mode."""
|
"""Set new target hvac mode."""
|
||||||
@ -222,23 +221,23 @@ class HomematicipHeatingGroup(HomematicipGenericEntity, ClimateEntity):
|
|||||||
return
|
return
|
||||||
|
|
||||||
if hvac_mode == HVACMode.AUTO:
|
if hvac_mode == HVACMode.AUTO:
|
||||||
await self._device.set_control_mode(HMIP_AUTOMATIC_CM)
|
await self._device.set_control_mode_async(HMIP_AUTOMATIC_CM)
|
||||||
else:
|
else:
|
||||||
await self._device.set_control_mode(HMIP_MANUAL_CM)
|
await self._device.set_control_mode_async(HMIP_MANUAL_CM)
|
||||||
|
|
||||||
async def async_set_preset_mode(self, preset_mode: str) -> None:
|
async def async_set_preset_mode(self, preset_mode: str) -> None:
|
||||||
"""Set new preset mode."""
|
"""Set new preset mode."""
|
||||||
if self._device.boostMode and preset_mode != PRESET_BOOST:
|
if self._device.boostMode and preset_mode != PRESET_BOOST:
|
||||||
await self._device.set_boost(False)
|
await self._device.set_boost_async(False)
|
||||||
if preset_mode == PRESET_BOOST:
|
if preset_mode == PRESET_BOOST:
|
||||||
await self._device.set_boost()
|
await self._device.set_boost_async()
|
||||||
if preset_mode == PRESET_ECO:
|
if preset_mode == PRESET_ECO:
|
||||||
await self._device.set_control_mode(HMIP_ECO_CM)
|
await self._device.set_control_mode_async(HMIP_ECO_CM)
|
||||||
if preset_mode in self._device_profile_names:
|
if preset_mode in self._device_profile_names:
|
||||||
profile_idx = self._get_profile_idx_by_name(preset_mode)
|
profile_idx = self._get_profile_idx_by_name(preset_mode)
|
||||||
if self._device.controlMode != HMIP_AUTOMATIC_CM:
|
if self._device.controlMode != HMIP_AUTOMATIC_CM:
|
||||||
await self.async_set_hvac_mode(HVACMode.AUTO)
|
await self.async_set_hvac_mode(HVACMode.AUTO)
|
||||||
await self._device.set_active_profile(profile_idx)
|
await self._device.set_active_profile_async(profile_idx)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def extra_state_attributes(self) -> dict[str, Any]:
|
def extra_state_attributes(self) -> dict[str, Any]:
|
||||||
@ -332,20 +331,15 @@ class HomematicipHeatingGroup(HomematicipGenericEntity, ClimateEntity):
|
|||||||
@property
|
@property
|
||||||
def _first_radiator_thermostat(
|
def _first_radiator_thermostat(
|
||||||
self,
|
self,
|
||||||
) -> (
|
) -> HeatingThermostat | HeatingThermostatCompact | HeatingThermostatEvo | None:
|
||||||
AsyncHeatingThermostat
|
|
||||||
| AsyncHeatingThermostatCompact
|
|
||||||
| AsyncHeatingThermostatEvo
|
|
||||||
| None
|
|
||||||
):
|
|
||||||
"""Return the first radiator thermostat from the hmip heating group."""
|
"""Return the first radiator thermostat from the hmip heating group."""
|
||||||
for device in self._device.devices:
|
for device in self._device.devices:
|
||||||
if isinstance(
|
if isinstance(
|
||||||
device,
|
device,
|
||||||
(
|
(
|
||||||
AsyncHeatingThermostat,
|
HeatingThermostat,
|
||||||
AsyncHeatingThermostatCompact,
|
HeatingThermostatCompact,
|
||||||
AsyncHeatingThermostatEvo,
|
HeatingThermostatEvo,
|
||||||
),
|
),
|
||||||
):
|
):
|
||||||
return device
|
return device
|
||||||
|
@ -4,16 +4,16 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from homematicip.aio.device import (
|
|
||||||
AsyncBlindModule,
|
|
||||||
AsyncDinRailBlind4,
|
|
||||||
AsyncFullFlushBlind,
|
|
||||||
AsyncFullFlushShutter,
|
|
||||||
AsyncGarageDoorModuleTormatic,
|
|
||||||
AsyncHoermannDrivesModule,
|
|
||||||
)
|
|
||||||
from homematicip.aio.group import AsyncExtendedLinkedShutterGroup
|
|
||||||
from homematicip.base.enums import DoorCommand, DoorState
|
from homematicip.base.enums import DoorCommand, DoorState
|
||||||
|
from homematicip.device import (
|
||||||
|
BlindModule,
|
||||||
|
DinRailBlind4,
|
||||||
|
FullFlushBlind,
|
||||||
|
FullFlushShutter,
|
||||||
|
GarageDoorModuleTormatic,
|
||||||
|
HoermannDrivesModule,
|
||||||
|
)
|
||||||
|
from homematicip.group import ExtendedLinkedShutterGroup
|
||||||
|
|
||||||
from homeassistant.components.cover import (
|
from homeassistant.components.cover import (
|
||||||
ATTR_POSITION,
|
ATTR_POSITION,
|
||||||
@ -45,23 +45,21 @@ async def async_setup_entry(
|
|||||||
entities: list[HomematicipGenericEntity] = [
|
entities: list[HomematicipGenericEntity] = [
|
||||||
HomematicipCoverShutterGroup(hap, group)
|
HomematicipCoverShutterGroup(hap, group)
|
||||||
for group in hap.home.groups
|
for group in hap.home.groups
|
||||||
if isinstance(group, AsyncExtendedLinkedShutterGroup)
|
if isinstance(group, ExtendedLinkedShutterGroup)
|
||||||
]
|
]
|
||||||
for device in hap.home.devices:
|
for device in hap.home.devices:
|
||||||
if isinstance(device, AsyncBlindModule):
|
if isinstance(device, BlindModule):
|
||||||
entities.append(HomematicipBlindModule(hap, device))
|
entities.append(HomematicipBlindModule(hap, device))
|
||||||
elif isinstance(device, AsyncDinRailBlind4):
|
elif isinstance(device, DinRailBlind4):
|
||||||
entities.extend(
|
entities.extend(
|
||||||
HomematicipMultiCoverSlats(hap, device, channel=channel)
|
HomematicipMultiCoverSlats(hap, device, channel=channel)
|
||||||
for channel in range(1, 5)
|
for channel in range(1, 5)
|
||||||
)
|
)
|
||||||
elif isinstance(device, AsyncFullFlushBlind):
|
elif isinstance(device, FullFlushBlind):
|
||||||
entities.append(HomematicipCoverSlats(hap, device))
|
entities.append(HomematicipCoverSlats(hap, device))
|
||||||
elif isinstance(device, AsyncFullFlushShutter):
|
elif isinstance(device, FullFlushShutter):
|
||||||
entities.append(HomematicipCoverShutter(hap, device))
|
entities.append(HomematicipCoverShutter(hap, device))
|
||||||
elif isinstance(
|
elif isinstance(device, (HoermannDrivesModule, GarageDoorModuleTormatic)):
|
||||||
device, (AsyncHoermannDrivesModule, AsyncGarageDoorModuleTormatic)
|
|
||||||
):
|
|
||||||
entities.append(HomematicipGarageDoorModule(hap, device))
|
entities.append(HomematicipGarageDoorModule(hap, device))
|
||||||
|
|
||||||
async_add_entities(entities)
|
async_add_entities(entities)
|
||||||
@ -91,14 +89,14 @@ class HomematicipBlindModule(HomematicipGenericEntity, CoverEntity):
|
|||||||
position = kwargs[ATTR_POSITION]
|
position = kwargs[ATTR_POSITION]
|
||||||
# HmIP cover is closed:1 -> open:0
|
# HmIP cover is closed:1 -> open:0
|
||||||
level = 1 - position / 100.0
|
level = 1 - position / 100.0
|
||||||
await self._device.set_primary_shading_level(primaryShadingLevel=level)
|
await self._device.set_primary_shading_level_async(primaryShadingLevel=level)
|
||||||
|
|
||||||
async def async_set_cover_tilt_position(self, **kwargs: Any) -> None:
|
async def async_set_cover_tilt_position(self, **kwargs: Any) -> None:
|
||||||
"""Move the cover to a specific tilt position."""
|
"""Move the cover to a specific tilt position."""
|
||||||
position = kwargs[ATTR_TILT_POSITION]
|
position = kwargs[ATTR_TILT_POSITION]
|
||||||
# HmIP slats is closed:1 -> open:0
|
# HmIP slats is closed:1 -> open:0
|
||||||
level = 1 - position / 100.0
|
level = 1 - position / 100.0
|
||||||
await self._device.set_secondary_shading_level(
|
await self._device.set_secondary_shading_level_async(
|
||||||
primaryShadingLevel=self._device.primaryShadingLevel,
|
primaryShadingLevel=self._device.primaryShadingLevel,
|
||||||
secondaryShadingLevel=level,
|
secondaryShadingLevel=level,
|
||||||
)
|
)
|
||||||
@ -112,37 +110,37 @@ class HomematicipBlindModule(HomematicipGenericEntity, CoverEntity):
|
|||||||
|
|
||||||
async def async_open_cover(self, **kwargs: Any) -> None:
|
async def async_open_cover(self, **kwargs: Any) -> None:
|
||||||
"""Open the cover."""
|
"""Open the cover."""
|
||||||
await self._device.set_primary_shading_level(
|
await self._device.set_primary_shading_level_async(
|
||||||
primaryShadingLevel=HMIP_COVER_OPEN
|
primaryShadingLevel=HMIP_COVER_OPEN
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_close_cover(self, **kwargs: Any) -> None:
|
async def async_close_cover(self, **kwargs: Any) -> None:
|
||||||
"""Close the cover."""
|
"""Close the cover."""
|
||||||
await self._device.set_primary_shading_level(
|
await self._device.set_primary_shading_level_async(
|
||||||
primaryShadingLevel=HMIP_COVER_CLOSED
|
primaryShadingLevel=HMIP_COVER_CLOSED
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_stop_cover(self, **kwargs: Any) -> None:
|
async def async_stop_cover(self, **kwargs: Any) -> None:
|
||||||
"""Stop the device if in motion."""
|
"""Stop the device if in motion."""
|
||||||
await self._device.stop()
|
await self._device.stop_async()
|
||||||
|
|
||||||
async def async_open_cover_tilt(self, **kwargs: Any) -> None:
|
async def async_open_cover_tilt(self, **kwargs: Any) -> None:
|
||||||
"""Open the slats."""
|
"""Open the slats."""
|
||||||
await self._device.set_secondary_shading_level(
|
await self._device.set_secondary_shading_level_async(
|
||||||
primaryShadingLevel=self._device.primaryShadingLevel,
|
primaryShadingLevel=self._device.primaryShadingLevel,
|
||||||
secondaryShadingLevel=HMIP_SLATS_OPEN,
|
secondaryShadingLevel=HMIP_SLATS_OPEN,
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_close_cover_tilt(self, **kwargs: Any) -> None:
|
async def async_close_cover_tilt(self, **kwargs: Any) -> None:
|
||||||
"""Close the slats."""
|
"""Close the slats."""
|
||||||
await self._device.set_secondary_shading_level(
|
await self._device.set_secondary_shading_level_async(
|
||||||
primaryShadingLevel=self._device.primaryShadingLevel,
|
primaryShadingLevel=self._device.primaryShadingLevel,
|
||||||
secondaryShadingLevel=HMIP_SLATS_CLOSED,
|
secondaryShadingLevel=HMIP_SLATS_CLOSED,
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_stop_cover_tilt(self, **kwargs: Any) -> None:
|
async def async_stop_cover_tilt(self, **kwargs: Any) -> None:
|
||||||
"""Stop the device if in motion."""
|
"""Stop the device if in motion."""
|
||||||
await self._device.stop()
|
await self._device.stop_async()
|
||||||
|
|
||||||
|
|
||||||
class HomematicipMultiCoverShutter(HomematicipGenericEntity, CoverEntity):
|
class HomematicipMultiCoverShutter(HomematicipGenericEntity, CoverEntity):
|
||||||
@ -176,7 +174,7 @@ class HomematicipMultiCoverShutter(HomematicipGenericEntity, CoverEntity):
|
|||||||
position = kwargs[ATTR_POSITION]
|
position = kwargs[ATTR_POSITION]
|
||||||
# HmIP cover is closed:1 -> open:0
|
# HmIP cover is closed:1 -> open:0
|
||||||
level = 1 - position / 100.0
|
level = 1 - position / 100.0
|
||||||
await self._device.set_shutter_level(level, self._channel)
|
await self._device.set_shutter_level_async(level, self._channel)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_closed(self) -> bool | None:
|
def is_closed(self) -> bool | None:
|
||||||
@ -190,15 +188,15 @@ class HomematicipMultiCoverShutter(HomematicipGenericEntity, CoverEntity):
|
|||||||
|
|
||||||
async def async_open_cover(self, **kwargs: Any) -> None:
|
async def async_open_cover(self, **kwargs: Any) -> None:
|
||||||
"""Open the cover."""
|
"""Open the cover."""
|
||||||
await self._device.set_shutter_level(HMIP_COVER_OPEN, self._channel)
|
await self._device.set_shutter_level_async(HMIP_COVER_OPEN, self._channel)
|
||||||
|
|
||||||
async def async_close_cover(self, **kwargs: Any) -> None:
|
async def async_close_cover(self, **kwargs: Any) -> None:
|
||||||
"""Close the cover."""
|
"""Close the cover."""
|
||||||
await self._device.set_shutter_level(HMIP_COVER_CLOSED, self._channel)
|
await self._device.set_shutter_level_async(HMIP_COVER_CLOSED, self._channel)
|
||||||
|
|
||||||
async def async_stop_cover(self, **kwargs: Any) -> None:
|
async def async_stop_cover(self, **kwargs: Any) -> None:
|
||||||
"""Stop the device if in motion."""
|
"""Stop the device if in motion."""
|
||||||
await self._device.set_shutter_stop(self._channel)
|
await self._device.set_shutter_stop_async(self._channel)
|
||||||
|
|
||||||
|
|
||||||
class HomematicipCoverShutter(HomematicipMultiCoverShutter, CoverEntity):
|
class HomematicipCoverShutter(HomematicipMultiCoverShutter, CoverEntity):
|
||||||
@ -238,23 +236,25 @@ class HomematicipMultiCoverSlats(HomematicipMultiCoverShutter, CoverEntity):
|
|||||||
position = kwargs[ATTR_TILT_POSITION]
|
position = kwargs[ATTR_TILT_POSITION]
|
||||||
# HmIP slats is closed:1 -> open:0
|
# HmIP slats is closed:1 -> open:0
|
||||||
level = 1 - position / 100.0
|
level = 1 - position / 100.0
|
||||||
await self._device.set_slats_level(slatsLevel=level, channelIndex=self._channel)
|
await self._device.set_slats_level_async(
|
||||||
|
slatsLevel=level, channelIndex=self._channel
|
||||||
|
)
|
||||||
|
|
||||||
async def async_open_cover_tilt(self, **kwargs: Any) -> None:
|
async def async_open_cover_tilt(self, **kwargs: Any) -> None:
|
||||||
"""Open the slats."""
|
"""Open the slats."""
|
||||||
await self._device.set_slats_level(
|
await self._device.set_slats_level_async(
|
||||||
slatsLevel=HMIP_SLATS_OPEN, channelIndex=self._channel
|
slatsLevel=HMIP_SLATS_OPEN, channelIndex=self._channel
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_close_cover_tilt(self, **kwargs: Any) -> None:
|
async def async_close_cover_tilt(self, **kwargs: Any) -> None:
|
||||||
"""Close the slats."""
|
"""Close the slats."""
|
||||||
await self._device.set_slats_level(
|
await self._device.set_slats_level_async(
|
||||||
slatsLevel=HMIP_SLATS_CLOSED, channelIndex=self._channel
|
slatsLevel=HMIP_SLATS_CLOSED, channelIndex=self._channel
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_stop_cover_tilt(self, **kwargs: Any) -> None:
|
async def async_stop_cover_tilt(self, **kwargs: Any) -> None:
|
||||||
"""Stop the device if in motion."""
|
"""Stop the device if in motion."""
|
||||||
await self._device.set_shutter_stop(self._channel)
|
await self._device.set_shutter_stop_async(self._channel)
|
||||||
|
|
||||||
|
|
||||||
class HomematicipCoverSlats(HomematicipMultiCoverSlats, CoverEntity):
|
class HomematicipCoverSlats(HomematicipMultiCoverSlats, CoverEntity):
|
||||||
@ -288,15 +288,15 @@ class HomematicipGarageDoorModule(HomematicipGenericEntity, CoverEntity):
|
|||||||
|
|
||||||
async def async_open_cover(self, **kwargs: Any) -> None:
|
async def async_open_cover(self, **kwargs: Any) -> None:
|
||||||
"""Open the cover."""
|
"""Open the cover."""
|
||||||
await self._device.send_door_command(DoorCommand.OPEN)
|
await self._device.send_door_command_async(DoorCommand.OPEN)
|
||||||
|
|
||||||
async def async_close_cover(self, **kwargs: Any) -> None:
|
async def async_close_cover(self, **kwargs: Any) -> None:
|
||||||
"""Close the cover."""
|
"""Close the cover."""
|
||||||
await self._device.send_door_command(DoorCommand.CLOSE)
|
await self._device.send_door_command_async(DoorCommand.CLOSE)
|
||||||
|
|
||||||
async def async_stop_cover(self, **kwargs: Any) -> None:
|
async def async_stop_cover(self, **kwargs: Any) -> None:
|
||||||
"""Stop the cover."""
|
"""Stop the cover."""
|
||||||
await self._device.send_door_command(DoorCommand.STOP)
|
await self._device.send_door_command_async(DoorCommand.STOP)
|
||||||
|
|
||||||
|
|
||||||
class HomematicipCoverShutterGroup(HomematicipGenericEntity, CoverEntity):
|
class HomematicipCoverShutterGroup(HomematicipGenericEntity, CoverEntity):
|
||||||
@ -335,35 +335,35 @@ class HomematicipCoverShutterGroup(HomematicipGenericEntity, CoverEntity):
|
|||||||
position = kwargs[ATTR_POSITION]
|
position = kwargs[ATTR_POSITION]
|
||||||
# HmIP cover is closed:1 -> open:0
|
# HmIP cover is closed:1 -> open:0
|
||||||
level = 1 - position / 100.0
|
level = 1 - position / 100.0
|
||||||
await self._device.set_shutter_level(level)
|
await self._device.set_shutter_level_async(level)
|
||||||
|
|
||||||
async def async_set_cover_tilt_position(self, **kwargs: Any) -> None:
|
async def async_set_cover_tilt_position(self, **kwargs: Any) -> None:
|
||||||
"""Move the cover to a specific tilt position."""
|
"""Move the cover to a specific tilt position."""
|
||||||
position = kwargs[ATTR_TILT_POSITION]
|
position = kwargs[ATTR_TILT_POSITION]
|
||||||
# HmIP slats is closed:1 -> open:0
|
# HmIP slats is closed:1 -> open:0
|
||||||
level = 1 - position / 100.0
|
level = 1 - position / 100.0
|
||||||
await self._device.set_slats_level(level)
|
await self._device.set_slats_level_async(level)
|
||||||
|
|
||||||
async def async_open_cover(self, **kwargs: Any) -> None:
|
async def async_open_cover(self, **kwargs: Any) -> None:
|
||||||
"""Open the cover."""
|
"""Open the cover."""
|
||||||
await self._device.set_shutter_level(HMIP_COVER_OPEN)
|
await self._device.set_shutter_level_async(HMIP_COVER_OPEN)
|
||||||
|
|
||||||
async def async_close_cover(self, **kwargs: Any) -> None:
|
async def async_close_cover(self, **kwargs: Any) -> None:
|
||||||
"""Close the cover."""
|
"""Close the cover."""
|
||||||
await self._device.set_shutter_level(HMIP_COVER_CLOSED)
|
await self._device.set_shutter_level_async(HMIP_COVER_CLOSED)
|
||||||
|
|
||||||
async def async_stop_cover(self, **kwargs: Any) -> None:
|
async def async_stop_cover(self, **kwargs: Any) -> None:
|
||||||
"""Stop the group if in motion."""
|
"""Stop the group if in motion."""
|
||||||
await self._device.set_shutter_stop()
|
await self._device.set_shutter_stop_async()
|
||||||
|
|
||||||
async def async_open_cover_tilt(self, **kwargs: Any) -> None:
|
async def async_open_cover_tilt(self, **kwargs: Any) -> None:
|
||||||
"""Open the slats."""
|
"""Open the slats."""
|
||||||
await self._device.set_slats_level(HMIP_SLATS_OPEN)
|
await self._device.set_slats_level_async(HMIP_SLATS_OPEN)
|
||||||
|
|
||||||
async def async_close_cover_tilt(self, **kwargs: Any) -> None:
|
async def async_close_cover_tilt(self, **kwargs: Any) -> None:
|
||||||
"""Close the slats."""
|
"""Close the slats."""
|
||||||
await self._device.set_slats_level(HMIP_SLATS_CLOSED)
|
await self._device.set_slats_level_async(HMIP_SLATS_CLOSED)
|
||||||
|
|
||||||
async def async_stop_cover_tilt(self, **kwargs: Any) -> None:
|
async def async_stop_cover_tilt(self, **kwargs: Any) -> None:
|
||||||
"""Stop the group if in motion."""
|
"""Stop the group if in motion."""
|
||||||
await self._device.set_shutter_stop()
|
await self._device.set_shutter_stop_async()
|
||||||
|
@ -5,9 +5,9 @@ from __future__ import annotations
|
|||||||
import logging
|
import logging
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from homematicip.aio.device import AsyncDevice
|
|
||||||
from homematicip.aio.group import AsyncGroup
|
|
||||||
from homematicip.base.functionalChannels import FunctionalChannel
|
from homematicip.base.functionalChannels import FunctionalChannel
|
||||||
|
from homematicip.device import Device
|
||||||
|
from homematicip.group import Group
|
||||||
|
|
||||||
from homeassistant.const import ATTR_ID
|
from homeassistant.const import ATTR_ID
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
@ -100,7 +100,7 @@ class HomematicipGenericEntity(Entity):
|
|||||||
def device_info(self) -> DeviceInfo | None:
|
def device_info(self) -> DeviceInfo | None:
|
||||||
"""Return device specific attributes."""
|
"""Return device specific attributes."""
|
||||||
# Only physical devices should be HA devices.
|
# Only physical devices should be HA devices.
|
||||||
if isinstance(self._device, AsyncDevice):
|
if isinstance(self._device, Device):
|
||||||
return DeviceInfo(
|
return DeviceInfo(
|
||||||
identifiers={
|
identifiers={
|
||||||
# Serial numbers of Homematic IP device
|
# Serial numbers of Homematic IP device
|
||||||
@ -237,14 +237,14 @@ class HomematicipGenericEntity(Entity):
|
|||||||
"""Return the state attributes of the generic entity."""
|
"""Return the state attributes of the generic entity."""
|
||||||
state_attr = {}
|
state_attr = {}
|
||||||
|
|
||||||
if isinstance(self._device, AsyncDevice):
|
if isinstance(self._device, Device):
|
||||||
for attr, attr_key in DEVICE_ATTRIBUTES.items():
|
for attr, attr_key in DEVICE_ATTRIBUTES.items():
|
||||||
if attr_value := getattr(self._device, attr, None):
|
if attr_value := getattr(self._device, attr, None):
|
||||||
state_attr[attr_key] = attr_value
|
state_attr[attr_key] = attr_value
|
||||||
|
|
||||||
state_attr[ATTR_IS_GROUP] = False
|
state_attr[ATTR_IS_GROUP] = False
|
||||||
|
|
||||||
if isinstance(self._device, AsyncGroup):
|
if isinstance(self._device, Group):
|
||||||
for attr, attr_key in GROUP_ATTRIBUTES.items():
|
for attr, attr_key in GROUP_ATTRIBUTES.items():
|
||||||
if attr_value := getattr(self._device, attr, None):
|
if attr_value := getattr(self._device, attr, None):
|
||||||
state_attr[attr_key] = attr_value
|
state_attr[attr_key] = attr_value
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
from homematicip.aio.device import Device
|
from homematicip.device import Device
|
||||||
|
|
||||||
from homeassistant.components.event import (
|
from homeassistant.components.event import (
|
||||||
EventDeviceClass,
|
EventDeviceClass,
|
||||||
|
@ -7,15 +7,18 @@ from collections.abc import Callable
|
|||||||
import logging
|
import logging
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from homematicip.aio.auth import AsyncAuth
|
from homematicip.async_home import AsyncHome
|
||||||
from homematicip.aio.home import AsyncHome
|
from homematicip.auth import Auth
|
||||||
from homematicip.base.base_connection import HmipConnectionError
|
from homematicip.base.base_connection import HmipConnectionError
|
||||||
from homematicip.base.enums import EventType
|
from homematicip.base.enums import EventType
|
||||||
|
from homematicip.connection.connection_context import ConnectionContextBuilder
|
||||||
|
from homematicip.connection.rest_connection import RestConnection
|
||||||
|
|
||||||
|
import homeassistant
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.exceptions import ConfigEntryNotReady
|
from homeassistant.exceptions import ConfigEntryNotReady
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.httpx_client import get_async_client
|
||||||
|
|
||||||
from .const import HMIPC_AUTHTOKEN, HMIPC_HAPID, HMIPC_NAME, HMIPC_PIN, PLATFORMS
|
from .const import HMIPC_AUTHTOKEN, HMIPC_HAPID, HMIPC_NAME, HMIPC_PIN, PLATFORMS
|
||||||
from .errors import HmipcConnectionError
|
from .errors import HmipcConnectionError
|
||||||
@ -23,10 +26,25 @@ from .errors import HmipcConnectionError
|
|||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
async def build_context_async(
|
||||||
|
hass: HomeAssistant, hapid: str | None, authtoken: str | None
|
||||||
|
):
|
||||||
|
"""Create a HomematicIP context object."""
|
||||||
|
ssl_ctx = homeassistant.util.ssl.get_default_context()
|
||||||
|
client_session = get_async_client(hass)
|
||||||
|
|
||||||
|
return await ConnectionContextBuilder.build_context_async(
|
||||||
|
accesspoint_id=hapid,
|
||||||
|
auth_token=authtoken,
|
||||||
|
ssl_ctx=ssl_ctx,
|
||||||
|
httpx_client_session=client_session,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class HomematicipAuth:
|
class HomematicipAuth:
|
||||||
"""Manages HomematicIP client registration."""
|
"""Manages HomematicIP client registration."""
|
||||||
|
|
||||||
auth: AsyncAuth
|
auth: Auth
|
||||||
|
|
||||||
def __init__(self, hass: HomeAssistant, config: dict[str, str]) -> None:
|
def __init__(self, hass: HomeAssistant, config: dict[str, str]) -> None:
|
||||||
"""Initialize HomematicIP Cloud client registration."""
|
"""Initialize HomematicIP Cloud client registration."""
|
||||||
@ -46,27 +64,34 @@ class HomematicipAuth:
|
|||||||
async def async_checkbutton(self) -> bool:
|
async def async_checkbutton(self) -> bool:
|
||||||
"""Check blue butten has been pressed."""
|
"""Check blue butten has been pressed."""
|
||||||
try:
|
try:
|
||||||
return await self.auth.isRequestAcknowledged()
|
return await self.auth.is_request_acknowledged()
|
||||||
except HmipConnectionError:
|
except HmipConnectionError:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
async def async_register(self):
|
async def async_register(self):
|
||||||
"""Register client at HomematicIP."""
|
"""Register client at HomematicIP."""
|
||||||
try:
|
try:
|
||||||
authtoken = await self.auth.requestAuthToken()
|
authtoken = await self.auth.request_auth_token()
|
||||||
await self.auth.confirmAuthToken(authtoken)
|
await self.auth.confirm_auth_token(authtoken)
|
||||||
except HmipConnectionError:
|
except HmipConnectionError:
|
||||||
return False
|
return False
|
||||||
return authtoken
|
return authtoken
|
||||||
|
|
||||||
async def get_auth(self, hass: HomeAssistant, hapid, pin):
|
async def get_auth(self, hass: HomeAssistant, hapid, pin):
|
||||||
"""Create a HomematicIP access point object."""
|
"""Create a HomematicIP access point object."""
|
||||||
auth = AsyncAuth(hass.loop, async_get_clientsession(hass))
|
context = await build_context_async(hass, hapid, None)
|
||||||
|
connection = RestConnection(
|
||||||
|
context,
|
||||||
|
log_status_exceptions=False,
|
||||||
|
httpx_client_session=get_async_client(hass),
|
||||||
|
)
|
||||||
|
# hass.loop
|
||||||
|
auth = Auth(connection, context.client_auth_token, hapid)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
await auth.init(hapid)
|
auth.set_pin(pin)
|
||||||
if pin:
|
result = await auth.connection_request(hapid)
|
||||||
auth.pin = pin
|
_LOGGER.debug("Connection request result: %s", result)
|
||||||
await auth.connectionRequest("HomeAssistant")
|
|
||||||
except HmipConnectionError:
|
except HmipConnectionError:
|
||||||
return None
|
return None
|
||||||
return auth
|
return auth
|
||||||
@ -156,7 +181,7 @@ class HomematicipHAP:
|
|||||||
|
|
||||||
async def get_state(self) -> None:
|
async def get_state(self) -> None:
|
||||||
"""Update HMIP state and tell Home Assistant."""
|
"""Update HMIP state and tell Home Assistant."""
|
||||||
await self.home.get_current_state()
|
await self.home.get_current_state_async()
|
||||||
self.update_all()
|
self.update_all()
|
||||||
|
|
||||||
def get_state_finished(self, future) -> None:
|
def get_state_finished(self, future) -> None:
|
||||||
@ -187,8 +212,8 @@ class HomematicipHAP:
|
|||||||
retry_delay = 2 ** min(tries, 8)
|
retry_delay = 2 ** min(tries, 8)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
await self.home.get_current_state()
|
await self.home.get_current_state_async()
|
||||||
hmip_events = await self.home.enable_events()
|
hmip_events = self.home.enable_events()
|
||||||
tries = 0
|
tries = 0
|
||||||
await hmip_events
|
await hmip_events
|
||||||
except HmipConnectionError:
|
except HmipConnectionError:
|
||||||
@ -219,7 +244,7 @@ class HomematicipHAP:
|
|||||||
self._ws_close_requested = True
|
self._ws_close_requested = True
|
||||||
if self._retry_task is not None:
|
if self._retry_task is not None:
|
||||||
self._retry_task.cancel()
|
self._retry_task.cancel()
|
||||||
await self.home.disable_events()
|
await self.home.disable_events_async()
|
||||||
_LOGGER.debug("Closed connection to HomematicIP cloud server")
|
_LOGGER.debug("Closed connection to HomematicIP cloud server")
|
||||||
await self.hass.config_entries.async_unload_platforms(
|
await self.hass.config_entries.async_unload_platforms(
|
||||||
self.config_entry, PLATFORMS
|
self.config_entry, PLATFORMS
|
||||||
@ -246,17 +271,17 @@ class HomematicipHAP:
|
|||||||
name: str | None,
|
name: str | None,
|
||||||
) -> AsyncHome:
|
) -> AsyncHome:
|
||||||
"""Create a HomematicIP access point object."""
|
"""Create a HomematicIP access point object."""
|
||||||
home = AsyncHome(hass.loop, async_get_clientsession(hass))
|
home = AsyncHome()
|
||||||
|
|
||||||
home.name = name
|
home.name = name
|
||||||
# Use the title of the config entry as title for the home.
|
# Use the title of the config entry as title for the home.
|
||||||
home.label = self.config_entry.title
|
home.label = self.config_entry.title
|
||||||
home.modelType = "HomematicIP Cloud Home"
|
home.modelType = "HomematicIP Cloud Home"
|
||||||
|
|
||||||
home.set_auth_token(authtoken)
|
|
||||||
try:
|
try:
|
||||||
await home.init(hapid)
|
context = await build_context_async(hass, hapid, authtoken)
|
||||||
await home.get_current_state()
|
home.init_with_context(context, True, get_async_client(hass))
|
||||||
|
await home.get_current_state_async()
|
||||||
except HmipConnectionError as err:
|
except HmipConnectionError as err:
|
||||||
raise HmipcConnectionError from err
|
raise HmipcConnectionError from err
|
||||||
home.on_update(self.async_update)
|
home.on_update(self.async_update)
|
||||||
|
@ -4,18 +4,18 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from homematicip.aio.device import (
|
|
||||||
AsyncBrandDimmer,
|
|
||||||
AsyncBrandSwitchMeasuring,
|
|
||||||
AsyncBrandSwitchNotificationLight,
|
|
||||||
AsyncDimmer,
|
|
||||||
AsyncDinRailDimmer3,
|
|
||||||
AsyncFullFlushDimmer,
|
|
||||||
AsyncPluggableDimmer,
|
|
||||||
AsyncWiredDimmer3,
|
|
||||||
)
|
|
||||||
from homematicip.base.enums import OpticalSignalBehaviour, RGBColorState
|
from homematicip.base.enums import OpticalSignalBehaviour, RGBColorState
|
||||||
from homematicip.base.functionalChannels import NotificationLightChannel
|
from homematicip.base.functionalChannels import NotificationLightChannel
|
||||||
|
from homematicip.device import (
|
||||||
|
BrandDimmer,
|
||||||
|
BrandSwitchMeasuring,
|
||||||
|
BrandSwitchNotificationLight,
|
||||||
|
Dimmer,
|
||||||
|
DinRailDimmer3,
|
||||||
|
FullFlushDimmer,
|
||||||
|
PluggableDimmer,
|
||||||
|
WiredDimmer3,
|
||||||
|
)
|
||||||
from packaging.version import Version
|
from packaging.version import Version
|
||||||
|
|
||||||
from homeassistant.components.light import (
|
from homeassistant.components.light import (
|
||||||
@ -46,9 +46,9 @@ async def async_setup_entry(
|
|||||||
hap = hass.data[DOMAIN][config_entry.unique_id]
|
hap = hass.data[DOMAIN][config_entry.unique_id]
|
||||||
entities: list[HomematicipGenericEntity] = []
|
entities: list[HomematicipGenericEntity] = []
|
||||||
for device in hap.home.devices:
|
for device in hap.home.devices:
|
||||||
if isinstance(device, AsyncBrandSwitchMeasuring):
|
if isinstance(device, BrandSwitchMeasuring):
|
||||||
entities.append(HomematicipLightMeasuring(hap, device))
|
entities.append(HomematicipLightMeasuring(hap, device))
|
||||||
elif isinstance(device, AsyncBrandSwitchNotificationLight):
|
elif isinstance(device, BrandSwitchNotificationLight):
|
||||||
device_version = Version(device.firmwareVersion)
|
device_version = Version(device.firmwareVersion)
|
||||||
entities.append(HomematicipLight(hap, device))
|
entities.append(HomematicipLight(hap, device))
|
||||||
|
|
||||||
@ -65,14 +65,14 @@ async def async_setup_entry(
|
|||||||
entity_class(hap, device, device.bottomLightChannelIndex, "Bottom")
|
entity_class(hap, device, device.bottomLightChannelIndex, "Bottom")
|
||||||
)
|
)
|
||||||
|
|
||||||
elif isinstance(device, (AsyncWiredDimmer3, AsyncDinRailDimmer3)):
|
elif isinstance(device, (WiredDimmer3, DinRailDimmer3)):
|
||||||
entities.extend(
|
entities.extend(
|
||||||
HomematicipMultiDimmer(hap, device, channel=channel)
|
HomematicipMultiDimmer(hap, device, channel=channel)
|
||||||
for channel in range(1, 4)
|
for channel in range(1, 4)
|
||||||
)
|
)
|
||||||
elif isinstance(
|
elif isinstance(
|
||||||
device,
|
device,
|
||||||
(AsyncDimmer, AsyncPluggableDimmer, AsyncBrandDimmer, AsyncFullFlushDimmer),
|
(Dimmer, PluggableDimmer, BrandDimmer, FullFlushDimmer),
|
||||||
):
|
):
|
||||||
entities.append(HomematicipDimmer(hap, device))
|
entities.append(HomematicipDimmer(hap, device))
|
||||||
|
|
||||||
@ -96,11 +96,11 @@ class HomematicipLight(HomematicipGenericEntity, LightEntity):
|
|||||||
|
|
||||||
async def async_turn_on(self, **kwargs: Any) -> None:
|
async def async_turn_on(self, **kwargs: Any) -> None:
|
||||||
"""Turn the light on."""
|
"""Turn the light on."""
|
||||||
await self._device.turn_on()
|
await self._device.turn_on_async()
|
||||||
|
|
||||||
async def async_turn_off(self, **kwargs: Any) -> None:
|
async def async_turn_off(self, **kwargs: Any) -> None:
|
||||||
"""Turn the light off."""
|
"""Turn the light off."""
|
||||||
await self._device.turn_off()
|
await self._device.turn_off_async()
|
||||||
|
|
||||||
|
|
||||||
class HomematicipLightMeasuring(HomematicipLight):
|
class HomematicipLightMeasuring(HomematicipLight):
|
||||||
@ -141,15 +141,15 @@ class HomematicipMultiDimmer(HomematicipGenericEntity, LightEntity):
|
|||||||
async def async_turn_on(self, **kwargs: Any) -> None:
|
async def async_turn_on(self, **kwargs: Any) -> None:
|
||||||
"""Turn the dimmer on."""
|
"""Turn the dimmer on."""
|
||||||
if ATTR_BRIGHTNESS in kwargs:
|
if ATTR_BRIGHTNESS in kwargs:
|
||||||
await self._device.set_dim_level(
|
await self._device.set_dim_level_async(
|
||||||
kwargs[ATTR_BRIGHTNESS] / 255.0, self._channel
|
kwargs[ATTR_BRIGHTNESS] / 255.0, self._channel
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
await self._device.set_dim_level(1, self._channel)
|
await self._device.set_dim_level_async(1, self._channel)
|
||||||
|
|
||||||
async def async_turn_off(self, **kwargs: Any) -> None:
|
async def async_turn_off(self, **kwargs: Any) -> None:
|
||||||
"""Turn the dimmer off."""
|
"""Turn the dimmer off."""
|
||||||
await self._device.set_dim_level(0, self._channel)
|
await self._device.set_dim_level_async(0, self._channel)
|
||||||
|
|
||||||
|
|
||||||
class HomematicipDimmer(HomematicipMultiDimmer, LightEntity):
|
class HomematicipDimmer(HomematicipMultiDimmer, LightEntity):
|
||||||
@ -239,7 +239,7 @@ class HomematicipNotificationLight(HomematicipGenericEntity, LightEntity):
|
|||||||
dim_level = brightness / 255.0
|
dim_level = brightness / 255.0
|
||||||
transition = kwargs.get(ATTR_TRANSITION, 0.5)
|
transition = kwargs.get(ATTR_TRANSITION, 0.5)
|
||||||
|
|
||||||
await self._device.set_rgb_dim_level_with_time(
|
await self._device.set_rgb_dim_level_with_time_async(
|
||||||
channelIndex=self._channel,
|
channelIndex=self._channel,
|
||||||
rgb=simple_rgb_color,
|
rgb=simple_rgb_color,
|
||||||
dimLevel=dim_level,
|
dimLevel=dim_level,
|
||||||
@ -252,7 +252,7 @@ class HomematicipNotificationLight(HomematicipGenericEntity, LightEntity):
|
|||||||
simple_rgb_color = self._func_channel.simpleRGBColorState
|
simple_rgb_color = self._func_channel.simpleRGBColorState
|
||||||
transition = kwargs.get(ATTR_TRANSITION, 0.5)
|
transition = kwargs.get(ATTR_TRANSITION, 0.5)
|
||||||
|
|
||||||
await self._device.set_rgb_dim_level_with_time(
|
await self._device.set_rgb_dim_level_with_time_async(
|
||||||
channelIndex=self._channel,
|
channelIndex=self._channel,
|
||||||
rgb=simple_rgb_color,
|
rgb=simple_rgb_color,
|
||||||
dimLevel=0.0,
|
dimLevel=0.0,
|
||||||
|
@ -5,8 +5,8 @@ from __future__ import annotations
|
|||||||
import logging
|
import logging
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from homematicip.aio.device import AsyncDoorLockDrive
|
|
||||||
from homematicip.base.enums import LockState, MotorState
|
from homematicip.base.enums import LockState, MotorState
|
||||||
|
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.config_entries import ConfigEntry
|
||||||
@ -45,7 +45,7 @@ async def async_setup_entry(
|
|||||||
async_add_entities(
|
async_add_entities(
|
||||||
HomematicipDoorLockDrive(hap, device)
|
HomematicipDoorLockDrive(hap, device)
|
||||||
for device in hap.home.devices
|
for device in hap.home.devices
|
||||||
if isinstance(device, AsyncDoorLockDrive)
|
if isinstance(device, DoorLockDrive)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -75,17 +75,17 @@ class HomematicipDoorLockDrive(HomematicipGenericEntity, LockEntity):
|
|||||||
@handle_errors
|
@handle_errors
|
||||||
async def async_lock(self, **kwargs: Any) -> None:
|
async def async_lock(self, **kwargs: Any) -> None:
|
||||||
"""Lock the device."""
|
"""Lock the device."""
|
||||||
return await self._device.set_lock_state(LockState.LOCKED)
|
return await self._device.set_lock_state_async(LockState.LOCKED)
|
||||||
|
|
||||||
@handle_errors
|
@handle_errors
|
||||||
async def async_unlock(self, **kwargs: Any) -> None:
|
async def async_unlock(self, **kwargs: Any) -> None:
|
||||||
"""Unlock the device."""
|
"""Unlock the device."""
|
||||||
return await self._device.set_lock_state(LockState.UNLOCKED)
|
return await self._device.set_lock_state_async(LockState.UNLOCKED)
|
||||||
|
|
||||||
@handle_errors
|
@handle_errors
|
||||||
async def async_open(self, **kwargs: Any) -> None:
|
async def async_open(self, **kwargs: Any) -> None:
|
||||||
"""Open the door latch."""
|
"""Open the door latch."""
|
||||||
return await self._device.set_lock_state(LockState.OPEN)
|
return await self._device.set_lock_state_async(LockState.OPEN)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def extra_state_attributes(self) -> dict[str, Any]:
|
def extra_state_attributes(self) -> dict[str, Any]:
|
||||||
|
@ -6,5 +6,5 @@
|
|||||||
"documentation": "https://www.home-assistant.io/integrations/homematicip_cloud",
|
"documentation": "https://www.home-assistant.io/integrations/homematicip_cloud",
|
||||||
"iot_class": "cloud_push",
|
"iot_class": "cloud_push",
|
||||||
"loggers": ["homematicip"],
|
"loggers": ["homematicip"],
|
||||||
"requirements": ["homematicip==1.1.7"]
|
"requirements": ["homematicip==2.0.0"]
|
||||||
}
|
}
|
||||||
|
@ -5,39 +5,39 @@ from __future__ import annotations
|
|||||||
from collections.abc import Callable
|
from collections.abc import Callable
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from homematicip.aio.device import (
|
|
||||||
AsyncBrandSwitchMeasuring,
|
|
||||||
AsyncEnergySensorsInterface,
|
|
||||||
AsyncFloorTerminalBlock6,
|
|
||||||
AsyncFloorTerminalBlock10,
|
|
||||||
AsyncFloorTerminalBlock12,
|
|
||||||
AsyncFullFlushSwitchMeasuring,
|
|
||||||
AsyncHeatingThermostat,
|
|
||||||
AsyncHeatingThermostatCompact,
|
|
||||||
AsyncHeatingThermostatEvo,
|
|
||||||
AsyncHomeControlAccessPoint,
|
|
||||||
AsyncLightSensor,
|
|
||||||
AsyncMotionDetectorIndoor,
|
|
||||||
AsyncMotionDetectorOutdoor,
|
|
||||||
AsyncMotionDetectorPushButton,
|
|
||||||
AsyncPassageDetector,
|
|
||||||
AsyncPlugableSwitchMeasuring,
|
|
||||||
AsyncPresenceDetectorIndoor,
|
|
||||||
AsyncRoomControlDeviceAnalog,
|
|
||||||
AsyncTemperatureDifferenceSensor2,
|
|
||||||
AsyncTemperatureHumiditySensorDisplay,
|
|
||||||
AsyncTemperatureHumiditySensorOutdoor,
|
|
||||||
AsyncTemperatureHumiditySensorWithoutDisplay,
|
|
||||||
AsyncWeatherSensor,
|
|
||||||
AsyncWeatherSensorPlus,
|
|
||||||
AsyncWeatherSensorPro,
|
|
||||||
AsyncWiredFloorTerminalBlock12,
|
|
||||||
)
|
|
||||||
from homematicip.base.enums import FunctionalChannelType, ValveState
|
from homematicip.base.enums import FunctionalChannelType, ValveState
|
||||||
from homematicip.base.functionalChannels import (
|
from homematicip.base.functionalChannels import (
|
||||||
FloorTerminalBlockMechanicChannel,
|
FloorTerminalBlockMechanicChannel,
|
||||||
FunctionalChannel,
|
FunctionalChannel,
|
||||||
)
|
)
|
||||||
|
from homematicip.device import (
|
||||||
|
BrandSwitchMeasuring,
|
||||||
|
EnergySensorsInterface,
|
||||||
|
FloorTerminalBlock6,
|
||||||
|
FloorTerminalBlock10,
|
||||||
|
FloorTerminalBlock12,
|
||||||
|
FullFlushSwitchMeasuring,
|
||||||
|
HeatingThermostat,
|
||||||
|
HeatingThermostatCompact,
|
||||||
|
HeatingThermostatEvo,
|
||||||
|
HomeControlAccessPoint,
|
||||||
|
LightSensor,
|
||||||
|
MotionDetectorIndoor,
|
||||||
|
MotionDetectorOutdoor,
|
||||||
|
MotionDetectorPushButton,
|
||||||
|
PassageDetector,
|
||||||
|
PlugableSwitchMeasuring,
|
||||||
|
PresenceDetectorIndoor,
|
||||||
|
RoomControlDeviceAnalog,
|
||||||
|
TemperatureDifferenceSensor2,
|
||||||
|
TemperatureHumiditySensorDisplay,
|
||||||
|
TemperatureHumiditySensorOutdoor,
|
||||||
|
TemperatureHumiditySensorWithoutDisplay,
|
||||||
|
WeatherSensor,
|
||||||
|
WeatherSensorPlus,
|
||||||
|
WeatherSensorPro,
|
||||||
|
WiredFloorTerminalBlock12,
|
||||||
|
)
|
||||||
|
|
||||||
from homeassistant.components.sensor import (
|
from homeassistant.components.sensor import (
|
||||||
SensorDeviceClass,
|
SensorDeviceClass,
|
||||||
@ -102,14 +102,14 @@ async def async_setup_entry(
|
|||||||
hap = hass.data[DOMAIN][config_entry.unique_id]
|
hap = hass.data[DOMAIN][config_entry.unique_id]
|
||||||
entities: list[HomematicipGenericEntity] = []
|
entities: list[HomematicipGenericEntity] = []
|
||||||
for device in hap.home.devices:
|
for device in hap.home.devices:
|
||||||
if isinstance(device, AsyncHomeControlAccessPoint):
|
if isinstance(device, HomeControlAccessPoint):
|
||||||
entities.append(HomematicipAccesspointDutyCycle(hap, device))
|
entities.append(HomematicipAccesspointDutyCycle(hap, device))
|
||||||
if isinstance(
|
if isinstance(
|
||||||
device,
|
device,
|
||||||
(
|
(
|
||||||
AsyncHeatingThermostat,
|
HeatingThermostat,
|
||||||
AsyncHeatingThermostatCompact,
|
HeatingThermostatCompact,
|
||||||
AsyncHeatingThermostatEvo,
|
HeatingThermostatEvo,
|
||||||
),
|
),
|
||||||
):
|
):
|
||||||
entities.append(HomematicipHeatingThermostat(hap, device))
|
entities.append(HomematicipHeatingThermostat(hap, device))
|
||||||
@ -117,55 +117,53 @@ async def async_setup_entry(
|
|||||||
if isinstance(
|
if isinstance(
|
||||||
device,
|
device,
|
||||||
(
|
(
|
||||||
AsyncTemperatureHumiditySensorDisplay,
|
TemperatureHumiditySensorDisplay,
|
||||||
AsyncTemperatureHumiditySensorWithoutDisplay,
|
TemperatureHumiditySensorWithoutDisplay,
|
||||||
AsyncTemperatureHumiditySensorOutdoor,
|
TemperatureHumiditySensorOutdoor,
|
||||||
AsyncWeatherSensor,
|
WeatherSensor,
|
||||||
AsyncWeatherSensorPlus,
|
WeatherSensorPlus,
|
||||||
AsyncWeatherSensorPro,
|
WeatherSensorPro,
|
||||||
),
|
),
|
||||||
):
|
):
|
||||||
entities.append(HomematicipTemperatureSensor(hap, device))
|
entities.append(HomematicipTemperatureSensor(hap, device))
|
||||||
entities.append(HomematicipHumiditySensor(hap, device))
|
entities.append(HomematicipHumiditySensor(hap, device))
|
||||||
elif isinstance(device, (AsyncRoomControlDeviceAnalog,)):
|
elif isinstance(device, (RoomControlDeviceAnalog,)):
|
||||||
entities.append(HomematicipTemperatureSensor(hap, device))
|
entities.append(HomematicipTemperatureSensor(hap, device))
|
||||||
if isinstance(
|
if isinstance(
|
||||||
device,
|
device,
|
||||||
(
|
(
|
||||||
AsyncLightSensor,
|
LightSensor,
|
||||||
AsyncMotionDetectorIndoor,
|
MotionDetectorIndoor,
|
||||||
AsyncMotionDetectorOutdoor,
|
MotionDetectorOutdoor,
|
||||||
AsyncMotionDetectorPushButton,
|
MotionDetectorPushButton,
|
||||||
AsyncPresenceDetectorIndoor,
|
PresenceDetectorIndoor,
|
||||||
AsyncWeatherSensor,
|
WeatherSensor,
|
||||||
AsyncWeatherSensorPlus,
|
WeatherSensorPlus,
|
||||||
AsyncWeatherSensorPro,
|
WeatherSensorPro,
|
||||||
),
|
),
|
||||||
):
|
):
|
||||||
entities.append(HomematicipIlluminanceSensor(hap, device))
|
entities.append(HomematicipIlluminanceSensor(hap, device))
|
||||||
if isinstance(
|
if isinstance(
|
||||||
device,
|
device,
|
||||||
(
|
(
|
||||||
AsyncPlugableSwitchMeasuring,
|
PlugableSwitchMeasuring,
|
||||||
AsyncBrandSwitchMeasuring,
|
BrandSwitchMeasuring,
|
||||||
AsyncFullFlushSwitchMeasuring,
|
FullFlushSwitchMeasuring,
|
||||||
),
|
),
|
||||||
):
|
):
|
||||||
entities.append(HomematicipPowerSensor(hap, device))
|
entities.append(HomematicipPowerSensor(hap, device))
|
||||||
entities.append(HomematicipEnergySensor(hap, device))
|
entities.append(HomematicipEnergySensor(hap, device))
|
||||||
if isinstance(
|
if isinstance(device, (WeatherSensor, WeatherSensorPlus, WeatherSensorPro)):
|
||||||
device, (AsyncWeatherSensor, AsyncWeatherSensorPlus, AsyncWeatherSensorPro)
|
|
||||||
):
|
|
||||||
entities.append(HomematicipWindspeedSensor(hap, device))
|
entities.append(HomematicipWindspeedSensor(hap, device))
|
||||||
if isinstance(device, (AsyncWeatherSensorPlus, AsyncWeatherSensorPro)):
|
if isinstance(device, (WeatherSensorPlus, WeatherSensorPro)):
|
||||||
entities.append(HomematicipTodayRainSensor(hap, device))
|
entities.append(HomematicipTodayRainSensor(hap, device))
|
||||||
if isinstance(device, AsyncPassageDetector):
|
if isinstance(device, PassageDetector):
|
||||||
entities.append(HomematicipPassageDetectorDeltaCounter(hap, device))
|
entities.append(HomematicipPassageDetectorDeltaCounter(hap, device))
|
||||||
if isinstance(device, AsyncTemperatureDifferenceSensor2):
|
if isinstance(device, TemperatureDifferenceSensor2):
|
||||||
entities.append(HomematicpTemperatureExternalSensorCh1(hap, device))
|
entities.append(HomematicpTemperatureExternalSensorCh1(hap, device))
|
||||||
entities.append(HomematicpTemperatureExternalSensorCh2(hap, device))
|
entities.append(HomematicpTemperatureExternalSensorCh2(hap, device))
|
||||||
entities.append(HomematicpTemperatureExternalSensorDelta(hap, device))
|
entities.append(HomematicpTemperatureExternalSensorDelta(hap, device))
|
||||||
if isinstance(device, AsyncEnergySensorsInterface):
|
if isinstance(device, EnergySensorsInterface):
|
||||||
for ch in get_channels_from_device(
|
for ch in get_channels_from_device(
|
||||||
device, FunctionalChannelType.ENERGY_SENSORS_INTERFACE_CHANNEL
|
device, FunctionalChannelType.ENERGY_SENSORS_INTERFACE_CHANNEL
|
||||||
):
|
):
|
||||||
@ -194,10 +192,10 @@ async def async_setup_entry(
|
|||||||
if isinstance(
|
if isinstance(
|
||||||
device,
|
device,
|
||||||
(
|
(
|
||||||
AsyncFloorTerminalBlock6,
|
FloorTerminalBlock6,
|
||||||
AsyncFloorTerminalBlock10,
|
FloorTerminalBlock10,
|
||||||
AsyncFloorTerminalBlock12,
|
FloorTerminalBlock12,
|
||||||
AsyncWiredFloorTerminalBlock12,
|
WiredFloorTerminalBlock12,
|
||||||
),
|
),
|
||||||
):
|
):
|
||||||
entities.extend(
|
entities.extend(
|
||||||
|
@ -5,10 +5,10 @@ from __future__ import annotations
|
|||||||
import logging
|
import logging
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from homematicip.aio.device import AsyncSwitchMeasuring
|
from homematicip.async_home import AsyncHome
|
||||||
from homematicip.aio.group import AsyncHeatingGroup
|
|
||||||
from homematicip.aio.home import AsyncHome
|
|
||||||
from homematicip.base.helpers import handle_config
|
from homematicip.base.helpers import handle_config
|
||||||
|
from homematicip.device import SwitchMeasuring
|
||||||
|
from homematicip.group import HeatingGroup
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.const import ATTR_ENTITY_ID, ATTR_TEMPERATURE
|
from homeassistant.const import ATTR_ENTITY_ID, ATTR_TEMPERATURE
|
||||||
@ -233,10 +233,10 @@ async def _async_activate_eco_mode_with_duration(
|
|||||||
|
|
||||||
if hapid := service.data.get(ATTR_ACCESSPOINT_ID):
|
if hapid := service.data.get(ATTR_ACCESSPOINT_ID):
|
||||||
if home := _get_home(hass, hapid):
|
if home := _get_home(hass, hapid):
|
||||||
await home.activate_absence_with_duration(duration)
|
await home.activate_absence_with_duration_async(duration)
|
||||||
else:
|
else:
|
||||||
for hap in hass.data[DOMAIN].values():
|
for hap in hass.data[DOMAIN].values():
|
||||||
await hap.home.activate_absence_with_duration(duration)
|
await hap.home.activate_absence_with_duration_async(duration)
|
||||||
|
|
||||||
|
|
||||||
async def _async_activate_eco_mode_with_period(
|
async def _async_activate_eco_mode_with_period(
|
||||||
@ -247,10 +247,10 @@ async def _async_activate_eco_mode_with_period(
|
|||||||
|
|
||||||
if hapid := service.data.get(ATTR_ACCESSPOINT_ID):
|
if hapid := service.data.get(ATTR_ACCESSPOINT_ID):
|
||||||
if home := _get_home(hass, hapid):
|
if home := _get_home(hass, hapid):
|
||||||
await home.activate_absence_with_period(endtime)
|
await home.activate_absence_with_period_async(endtime)
|
||||||
else:
|
else:
|
||||||
for hap in hass.data[DOMAIN].values():
|
for hap in hass.data[DOMAIN].values():
|
||||||
await hap.home.activate_absence_with_period(endtime)
|
await hap.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:
|
||||||
@ -260,30 +260,30 @@ async def _async_activate_vacation(hass: HomeAssistant, service: ServiceCall) ->
|
|||||||
|
|
||||||
if hapid := service.data.get(ATTR_ACCESSPOINT_ID):
|
if hapid := service.data.get(ATTR_ACCESSPOINT_ID):
|
||||||
if home := _get_home(hass, hapid):
|
if home := _get_home(hass, hapid):
|
||||||
await home.activate_vacation(endtime, temperature)
|
await home.activate_vacation_async(endtime, temperature)
|
||||||
else:
|
else:
|
||||||
for hap in hass.data[DOMAIN].values():
|
for hap in hass.data[DOMAIN].values():
|
||||||
await hap.home.activate_vacation(endtime, temperature)
|
await hap.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:
|
||||||
"""Service to deactivate eco mode."""
|
"""Service to deactivate eco mode."""
|
||||||
if hapid := service.data.get(ATTR_ACCESSPOINT_ID):
|
if hapid := service.data.get(ATTR_ACCESSPOINT_ID):
|
||||||
if home := _get_home(hass, hapid):
|
if home := _get_home(hass, hapid):
|
||||||
await home.deactivate_absence()
|
await home.deactivate_absence_async()
|
||||||
else:
|
else:
|
||||||
for hap in hass.data[DOMAIN].values():
|
for hap in hass.data[DOMAIN].values():
|
||||||
await hap.home.deactivate_absence()
|
await hap.home.deactivate_absence_async()
|
||||||
|
|
||||||
|
|
||||||
async def _async_deactivate_vacation(hass: HomeAssistant, service: ServiceCall) -> None:
|
async def _async_deactivate_vacation(hass: HomeAssistant, service: ServiceCall) -> None:
|
||||||
"""Service to deactivate vacation."""
|
"""Service to deactivate vacation."""
|
||||||
if hapid := service.data.get(ATTR_ACCESSPOINT_ID):
|
if hapid := service.data.get(ATTR_ACCESSPOINT_ID):
|
||||||
if home := _get_home(hass, hapid):
|
if home := _get_home(hass, hapid):
|
||||||
await home.deactivate_vacation()
|
await home.deactivate_vacation_async()
|
||||||
else:
|
else:
|
||||||
for hap in hass.data[DOMAIN].values():
|
for hap in hass.data[DOMAIN].values():
|
||||||
await hap.home.deactivate_vacation()
|
await hap.home.deactivate_vacation_async()
|
||||||
|
|
||||||
|
|
||||||
async def _set_active_climate_profile(
|
async def _set_active_climate_profile(
|
||||||
@ -297,12 +297,12 @@ async def _set_active_climate_profile(
|
|||||||
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 = hap.hmip_device_by_entity_id.get(entity_id)
|
||||||
if group and isinstance(group, AsyncHeatingGroup):
|
if group and isinstance(group, HeatingGroup):
|
||||||
await group.set_active_profile(climate_profile_index)
|
await group.set_active_profile_async(climate_profile_index)
|
||||||
else:
|
else:
|
||||||
for group in hap.home.groups:
|
for group in hap.home.groups:
|
||||||
if isinstance(group, AsyncHeatingGroup):
|
if isinstance(group, HeatingGroup):
|
||||||
await group.set_active_profile(climate_profile_index)
|
await group.set_active_profile_async(climate_profile_index)
|
||||||
|
|
||||||
|
|
||||||
async def _async_dump_hap_config(hass: HomeAssistant, service: ServiceCall) -> None:
|
async def _async_dump_hap_config(hass: HomeAssistant, service: ServiceCall) -> None:
|
||||||
@ -323,7 +323,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()
|
json_state = await hap.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")
|
||||||
@ -337,12 +337,12 @@ async def _async_reset_energy_counter(hass: HomeAssistant, service: ServiceCall)
|
|||||||
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 = hap.hmip_device_by_entity_id.get(entity_id)
|
||||||
if device and isinstance(device, AsyncSwitchMeasuring):
|
if device and isinstance(device, SwitchMeasuring):
|
||||||
await device.reset_energy_counter()
|
await device.reset_energy_counter_async()
|
||||||
else:
|
else:
|
||||||
for device in hap.home.devices:
|
for device in hap.home.devices:
|
||||||
if isinstance(device, AsyncSwitchMeasuring):
|
if isinstance(device, SwitchMeasuring):
|
||||||
await device.reset_energy_counter()
|
await device.reset_energy_counter_async()
|
||||||
|
|
||||||
|
|
||||||
async def _async_set_home_cooling_mode(hass: HomeAssistant, service: ServiceCall):
|
async def _async_set_home_cooling_mode(hass: HomeAssistant, service: ServiceCall):
|
||||||
@ -351,10 +351,10 @@ async def _async_set_home_cooling_mode(hass: HomeAssistant, service: ServiceCall
|
|||||||
|
|
||||||
if hapid := service.data.get(ATTR_ACCESSPOINT_ID):
|
if hapid := service.data.get(ATTR_ACCESSPOINT_ID):
|
||||||
if home := _get_home(hass, hapid):
|
if home := _get_home(hass, hapid):
|
||||||
await home.set_cooling(cooling)
|
await home.set_cooling_async(cooling)
|
||||||
else:
|
else:
|
||||||
for hap in hass.data[DOMAIN].values():
|
for hap in hass.data[DOMAIN].values():
|
||||||
await hap.home.set_cooling(cooling)
|
await hap.home.set_cooling_async(cooling)
|
||||||
|
|
||||||
|
|
||||||
def _get_home(hass: HomeAssistant, hapid: str) -> AsyncHome | None:
|
def _get_home(hass: HomeAssistant, hapid: str) -> AsyncHome | None:
|
||||||
|
@ -4,23 +4,23 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from homematicip.aio.device import (
|
from homematicip.device import (
|
||||||
AsyncBrandSwitch2,
|
BrandSwitch2,
|
||||||
AsyncBrandSwitchMeasuring,
|
BrandSwitchMeasuring,
|
||||||
AsyncDinRailSwitch,
|
DinRailSwitch,
|
||||||
AsyncDinRailSwitch4,
|
DinRailSwitch4,
|
||||||
AsyncFullFlushInputSwitch,
|
FullFlushInputSwitch,
|
||||||
AsyncFullFlushSwitchMeasuring,
|
FullFlushSwitchMeasuring,
|
||||||
AsyncHeatingSwitch2,
|
HeatingSwitch2,
|
||||||
AsyncMultiIOBox,
|
MultiIOBox,
|
||||||
AsyncOpenCollector8Module,
|
OpenCollector8Module,
|
||||||
AsyncPlugableSwitch,
|
PlugableSwitch,
|
||||||
AsyncPlugableSwitchMeasuring,
|
PlugableSwitchMeasuring,
|
||||||
AsyncPrintedCircuitBoardSwitch2,
|
PrintedCircuitBoardSwitch2,
|
||||||
AsyncPrintedCircuitBoardSwitchBattery,
|
PrintedCircuitBoardSwitchBattery,
|
||||||
AsyncWiredSwitch8,
|
WiredSwitch8,
|
||||||
)
|
)
|
||||||
from homematicip.aio.group import AsyncExtendedLinkedSwitchingGroup, AsyncSwitchingGroup
|
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.config_entries import ConfigEntry
|
||||||
@ -42,26 +42,24 @@ async def async_setup_entry(
|
|||||||
entities: list[HomematicipGenericEntity] = [
|
entities: list[HomematicipGenericEntity] = [
|
||||||
HomematicipGroupSwitch(hap, group)
|
HomematicipGroupSwitch(hap, group)
|
||||||
for group in hap.home.groups
|
for group in hap.home.groups
|
||||||
if isinstance(group, (AsyncExtendedLinkedSwitchingGroup, AsyncSwitchingGroup))
|
if isinstance(group, (ExtendedLinkedSwitchingGroup, SwitchingGroup))
|
||||||
]
|
]
|
||||||
for device in hap.home.devices:
|
for device in hap.home.devices:
|
||||||
if isinstance(device, AsyncBrandSwitchMeasuring):
|
if isinstance(device, BrandSwitchMeasuring):
|
||||||
# BrandSwitchMeasuring inherits PlugableSwitchMeasuring
|
# BrandSwitchMeasuring inherits PlugableSwitchMeasuring
|
||||||
# This entity is implemented in the light platform and will
|
# This entity is implemented in the light platform and will
|
||||||
# not be added in the switch platform
|
# not be added in the switch platform
|
||||||
pass
|
pass
|
||||||
elif isinstance(
|
elif isinstance(device, (PlugableSwitchMeasuring, FullFlushSwitchMeasuring)):
|
||||||
device, (AsyncPlugableSwitchMeasuring, AsyncFullFlushSwitchMeasuring)
|
|
||||||
):
|
|
||||||
entities.append(HomematicipSwitchMeasuring(hap, device))
|
entities.append(HomematicipSwitchMeasuring(hap, device))
|
||||||
elif isinstance(device, AsyncWiredSwitch8):
|
elif isinstance(device, WiredSwitch8):
|
||||||
entities.extend(
|
entities.extend(
|
||||||
HomematicipMultiSwitch(hap, device, channel=channel)
|
HomematicipMultiSwitch(hap, device, channel=channel)
|
||||||
for channel in range(1, 9)
|
for channel in range(1, 9)
|
||||||
)
|
)
|
||||||
elif isinstance(device, AsyncDinRailSwitch):
|
elif isinstance(device, DinRailSwitch):
|
||||||
entities.append(HomematicipMultiSwitch(hap, device, channel=1))
|
entities.append(HomematicipMultiSwitch(hap, device, channel=1))
|
||||||
elif isinstance(device, AsyncDinRailSwitch4):
|
elif isinstance(device, DinRailSwitch4):
|
||||||
entities.extend(
|
entities.extend(
|
||||||
HomematicipMultiSwitch(hap, device, channel=channel)
|
HomematicipMultiSwitch(hap, device, channel=channel)
|
||||||
for channel in range(1, 5)
|
for channel in range(1, 5)
|
||||||
@ -69,13 +67,13 @@ async def async_setup_entry(
|
|||||||
elif isinstance(
|
elif isinstance(
|
||||||
device,
|
device,
|
||||||
(
|
(
|
||||||
AsyncPlugableSwitch,
|
PlugableSwitch,
|
||||||
AsyncPrintedCircuitBoardSwitchBattery,
|
PrintedCircuitBoardSwitchBattery,
|
||||||
AsyncFullFlushInputSwitch,
|
FullFlushInputSwitch,
|
||||||
),
|
),
|
||||||
):
|
):
|
||||||
entities.append(HomematicipSwitch(hap, device))
|
entities.append(HomematicipSwitch(hap, device))
|
||||||
elif isinstance(device, AsyncOpenCollector8Module):
|
elif isinstance(device, OpenCollector8Module):
|
||||||
entities.extend(
|
entities.extend(
|
||||||
HomematicipMultiSwitch(hap, device, channel=channel)
|
HomematicipMultiSwitch(hap, device, channel=channel)
|
||||||
for channel in range(1, 9)
|
for channel in range(1, 9)
|
||||||
@ -83,10 +81,10 @@ async def async_setup_entry(
|
|||||||
elif isinstance(
|
elif isinstance(
|
||||||
device,
|
device,
|
||||||
(
|
(
|
||||||
AsyncBrandSwitch2,
|
BrandSwitch2,
|
||||||
AsyncPrintedCircuitBoardSwitch2,
|
PrintedCircuitBoardSwitch2,
|
||||||
AsyncHeatingSwitch2,
|
HeatingSwitch2,
|
||||||
AsyncMultiIOBox,
|
MultiIOBox,
|
||||||
),
|
),
|
||||||
):
|
):
|
||||||
entities.extend(
|
entities.extend(
|
||||||
@ -119,11 +117,11 @@ class HomematicipMultiSwitch(HomematicipGenericEntity, SwitchEntity):
|
|||||||
|
|
||||||
async def async_turn_on(self, **kwargs: Any) -> None:
|
async def async_turn_on(self, **kwargs: Any) -> None:
|
||||||
"""Turn the switch on."""
|
"""Turn the switch on."""
|
||||||
await self._device.turn_on(self._channel)
|
await self._device.turn_on_async(self._channel)
|
||||||
|
|
||||||
async def async_turn_off(self, **kwargs: Any) -> None:
|
async def async_turn_off(self, **kwargs: Any) -> None:
|
||||||
"""Turn the switch off."""
|
"""Turn the switch off."""
|
||||||
await self._device.turn_off(self._channel)
|
await self._device.turn_off_async(self._channel)
|
||||||
|
|
||||||
|
|
||||||
class HomematicipSwitch(HomematicipMultiSwitch, SwitchEntity):
|
class HomematicipSwitch(HomematicipMultiSwitch, SwitchEntity):
|
||||||
@ -168,11 +166,11 @@ class HomematicipGroupSwitch(HomematicipGenericEntity, SwitchEntity):
|
|||||||
|
|
||||||
async def async_turn_on(self, **kwargs: Any) -> None:
|
async def async_turn_on(self, **kwargs: Any) -> None:
|
||||||
"""Turn the group on."""
|
"""Turn the group on."""
|
||||||
await self._device.turn_on()
|
await self._device.turn_on_async()
|
||||||
|
|
||||||
async def async_turn_off(self, **kwargs: Any) -> None:
|
async def async_turn_off(self, **kwargs: Any) -> None:
|
||||||
"""Turn the group off."""
|
"""Turn the group off."""
|
||||||
await self._device.turn_off()
|
await self._device.turn_off_async()
|
||||||
|
|
||||||
|
|
||||||
class HomematicipSwitchMeasuring(HomematicipSwitch):
|
class HomematicipSwitchMeasuring(HomematicipSwitch):
|
||||||
|
@ -2,12 +2,8 @@
|
|||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from homematicip.aio.device import (
|
|
||||||
AsyncWeatherSensor,
|
|
||||||
AsyncWeatherSensorPlus,
|
|
||||||
AsyncWeatherSensorPro,
|
|
||||||
)
|
|
||||||
from homematicip.base.enums import WeatherCondition
|
from homematicip.base.enums import WeatherCondition
|
||||||
|
from homematicip.device import WeatherSensor, WeatherSensorPlus, WeatherSensorPro
|
||||||
|
|
||||||
from homeassistant.components.weather import (
|
from homeassistant.components.weather import (
|
||||||
ATTR_CONDITION_CLOUDY,
|
ATTR_CONDITION_CLOUDY,
|
||||||
@ -59,9 +55,9 @@ async def async_setup_entry(
|
|||||||
hap = hass.data[DOMAIN][config_entry.unique_id]
|
hap = hass.data[DOMAIN][config_entry.unique_id]
|
||||||
entities: list[HomematicipGenericEntity] = []
|
entities: list[HomematicipGenericEntity] = []
|
||||||
for device in hap.home.devices:
|
for device in hap.home.devices:
|
||||||
if isinstance(device, AsyncWeatherSensorPro):
|
if isinstance(device, WeatherSensorPro):
|
||||||
entities.append(HomematicipWeatherSensorPro(hap, device))
|
entities.append(HomematicipWeatherSensorPro(hap, device))
|
||||||
elif isinstance(device, (AsyncWeatherSensor, AsyncWeatherSensorPlus)):
|
elif isinstance(device, (WeatherSensor, WeatherSensorPlus)):
|
||||||
entities.append(HomematicipWeatherSensor(hap, device))
|
entities.append(HomematicipWeatherSensor(hap, device))
|
||||||
|
|
||||||
entities.append(HomematicipHomeWeather(hap))
|
entities.append(HomematicipHomeWeather(hap))
|
||||||
|
2
requirements_all.txt
generated
2
requirements_all.txt
generated
@ -1163,7 +1163,7 @@ home-assistant-frontend==20250411.0
|
|||||||
home-assistant-intents==2025.3.28
|
home-assistant-intents==2025.3.28
|
||||||
|
|
||||||
# homeassistant.components.homematicip_cloud
|
# homeassistant.components.homematicip_cloud
|
||||||
homematicip==1.1.7
|
homematicip==2.0.0
|
||||||
|
|
||||||
# homeassistant.components.horizon
|
# homeassistant.components.horizon
|
||||||
horimote==0.4.1
|
horimote==0.4.1
|
||||||
|
2
requirements_test_all.txt
generated
2
requirements_test_all.txt
generated
@ -993,7 +993,7 @@ home-assistant-frontend==20250411.0
|
|||||||
home-assistant-intents==2025.3.28
|
home-assistant-intents==2025.3.28
|
||||||
|
|
||||||
# homeassistant.components.homematicip_cloud
|
# homeassistant.components.homematicip_cloud
|
||||||
homematicip==1.1.7
|
homematicip==2.0.0
|
||||||
|
|
||||||
# homeassistant.components.remember_the_milk
|
# homeassistant.components.remember_the_milk
|
||||||
httplib2==0.20.4
|
httplib2==0.20.4
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
"""Initializer helpers for HomematicIP fake server."""
|
"""Initializer helpers for HomematicIP fake server."""
|
||||||
|
|
||||||
from unittest.mock import AsyncMock, MagicMock, Mock, patch
|
from unittest.mock import AsyncMock, Mock, patch
|
||||||
|
|
||||||
from homematicip.aio.auth import AsyncAuth
|
from homematicip.async_home import AsyncHome
|
||||||
from homematicip.aio.connection import AsyncConnection
|
from homematicip.auth import Auth
|
||||||
from homematicip.aio.home import AsyncHome
|
|
||||||
from homematicip.base.enums import WeatherCondition, WeatherDayTime
|
from homematicip.base.enums import WeatherCondition, WeatherDayTime
|
||||||
|
from homematicip.connection.rest_connection import RestConnection
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant.components.homematicip_cloud import (
|
from homeassistant.components.homematicip_cloud import (
|
||||||
@ -30,16 +30,14 @@ from tests.components.light.conftest import mock_light_profiles # noqa: F401
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture(name="mock_connection")
|
@pytest.fixture(name="mock_connection")
|
||||||
def mock_connection_fixture() -> AsyncConnection:
|
def mock_connection_fixture() -> RestConnection:
|
||||||
"""Return a mocked connection."""
|
"""Return a mocked connection."""
|
||||||
connection = MagicMock(spec=AsyncConnection)
|
connection = AsyncMock(spec=RestConnection)
|
||||||
|
|
||||||
def _rest_call_side_effect(path, body=None):
|
def _rest_call_side_effect(path, body=None, custom_header=None):
|
||||||
return path, body
|
return path, body
|
||||||
|
|
||||||
connection._rest_call.side_effect = _rest_call_side_effect
|
connection.async_post.side_effect = _rest_call_side_effect
|
||||||
connection.api_call = AsyncMock(return_value=True)
|
|
||||||
connection.init = AsyncMock(side_effect=True)
|
|
||||||
|
|
||||||
return connection
|
return connection
|
||||||
|
|
||||||
@ -107,7 +105,7 @@ async def mock_hap_with_service_fixture(
|
|||||||
def simple_mock_home_fixture():
|
def simple_mock_home_fixture():
|
||||||
"""Return a simple mocked connection."""
|
"""Return a simple mocked connection."""
|
||||||
|
|
||||||
mock_home = Mock(
|
mock_home = AsyncMock(
|
||||||
spec=AsyncHome,
|
spec=AsyncHome,
|
||||||
name="Demo",
|
name="Demo",
|
||||||
devices=[],
|
devices=[],
|
||||||
@ -128,6 +126,8 @@ def simple_mock_home_fixture():
|
|||||||
dutyCycle=88,
|
dutyCycle=88,
|
||||||
connected=True,
|
connected=True,
|
||||||
currentAPVersion="2.0.36",
|
currentAPVersion="2.0.36",
|
||||||
|
init_async=AsyncMock(),
|
||||||
|
get_current_state_async=AsyncMock(),
|
||||||
)
|
)
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
@ -144,18 +144,15 @@ def mock_connection_init_fixture():
|
|||||||
|
|
||||||
with (
|
with (
|
||||||
patch(
|
patch(
|
||||||
"homeassistant.components.homematicip_cloud.hap.AsyncHome.init",
|
"homeassistant.components.homematicip_cloud.hap.AsyncHome.init_async",
|
||||||
return_value=None,
|
|
||||||
),
|
|
||||||
patch(
|
|
||||||
"homeassistant.components.homematicip_cloud.hap.AsyncAuth.init",
|
|
||||||
return_value=None,
|
return_value=None,
|
||||||
|
new_callable=AsyncMock,
|
||||||
),
|
),
|
||||||
):
|
):
|
||||||
yield
|
yield
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(name="simple_mock_auth")
|
@pytest.fixture(name="simple_mock_auth")
|
||||||
def simple_mock_auth_fixture() -> AsyncAuth:
|
def simple_mock_auth_fixture() -> Auth:
|
||||||
"""Return a simple AsyncAuth Mock."""
|
"""Return a simple AsyncAuth Mock."""
|
||||||
return Mock(spec=AsyncAuth, pin=HAPPIN, create=True)
|
return AsyncMock(spec=Auth, pin=HAPPIN, create=True)
|
||||||
|
@ -4,15 +4,15 @@ import json
|
|||||||
from typing import Any
|
from typing import Any
|
||||||
from unittest.mock import Mock, patch
|
from unittest.mock import Mock, patch
|
||||||
|
|
||||||
from homematicip.aio.class_maps import (
|
from homematicip.async_home import AsyncHome
|
||||||
|
from homematicip.base.homematicip_object import HomeMaticIPObject
|
||||||
|
from homematicip.class_maps import (
|
||||||
TYPE_CLASS_MAP,
|
TYPE_CLASS_MAP,
|
||||||
TYPE_GROUP_MAP,
|
TYPE_GROUP_MAP,
|
||||||
TYPE_SECURITY_EVENT_MAP,
|
TYPE_SECURITY_EVENT_MAP,
|
||||||
)
|
)
|
||||||
from homematicip.aio.device import AsyncDevice
|
from homematicip.device import Device
|
||||||
from homematicip.aio.group import AsyncGroup
|
from homematicip.group import Group
|
||||||
from homematicip.aio.home import AsyncHome
|
|
||||||
from homematicip.base.homematicip_object import HomeMaticIPObject
|
|
||||||
from homematicip.home import Home
|
from homematicip.home import Home
|
||||||
|
|
||||||
from homeassistant.components.homematicip_cloud import DOMAIN as HMIPC_DOMAIN
|
from homeassistant.components.homematicip_cloud import DOMAIN as HMIPC_DOMAIN
|
||||||
@ -49,9 +49,9 @@ def get_and_check_entity_basics(
|
|||||||
hmip_device = mock_hap.hmip_device_by_entity_id.get(entity_id)
|
hmip_device = mock_hap.hmip_device_by_entity_id.get(entity_id)
|
||||||
|
|
||||||
if hmip_device:
|
if hmip_device:
|
||||||
if isinstance(hmip_device, AsyncDevice):
|
if isinstance(hmip_device, Device):
|
||||||
assert ha_state.attributes[ATTR_IS_GROUP] is False
|
assert ha_state.attributes[ATTR_IS_GROUP] is False
|
||||||
elif isinstance(hmip_device, AsyncGroup):
|
elif isinstance(hmip_device, Group):
|
||||||
assert ha_state.attributes[ATTR_IS_GROUP]
|
assert ha_state.attributes[ATTR_IS_GROUP]
|
||||||
return ha_state, hmip_device
|
return ha_state, hmip_device
|
||||||
|
|
||||||
@ -174,12 +174,12 @@ class HomeTemplate(Home):
|
|||||||
def init_home(self):
|
def init_home(self):
|
||||||
"""Init template with json."""
|
"""Init template with json."""
|
||||||
self.init_json_state = self._cleanup_json(json.loads(FIXTURE_DATA))
|
self.init_json_state = self._cleanup_json(json.loads(FIXTURE_DATA))
|
||||||
self.update_home(json_state=self.init_json_state, clearConfig=True)
|
self.update_home(json_state=self.init_json_state, clear_config=True)
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def update_home(self, json_state, clearConfig: bool = False):
|
def update_home(self, json_state, clear_config: bool = False):
|
||||||
"""Update home and ensure that mocks are created."""
|
"""Update home and ensure that mocks are created."""
|
||||||
result = super().update_home(json_state, clearConfig)
|
result = super().update_home(json_state, clear_config)
|
||||||
self._generate_mocks()
|
self._generate_mocks()
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@ -193,7 +193,7 @@ class HomeTemplate(Home):
|
|||||||
|
|
||||||
self.groups = [_get_mock(group) for group in self.groups]
|
self.groups = [_get_mock(group) for group in self.groups]
|
||||||
|
|
||||||
def download_configuration(self):
|
async def download_configuration_async(self):
|
||||||
"""Return the initial json config."""
|
"""Return the initial json config."""
|
||||||
return self.init_json_state
|
return self.init_json_state
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
"""Tests for HomematicIP Cloud alarm control panel."""
|
"""Tests for HomematicIP Cloud alarm control panel."""
|
||||||
|
|
||||||
from homematicip.aio.home import AsyncHome
|
from homematicip.async_home import AsyncHome
|
||||||
|
|
||||||
from homeassistant.components.alarm_control_panel import (
|
from homeassistant.components.alarm_control_panel import (
|
||||||
DOMAIN as ALARM_CONTROL_PANEL_DOMAIN,
|
DOMAIN as ALARM_CONTROL_PANEL_DOMAIN,
|
||||||
@ -73,7 +73,7 @@ async def test_hmip_alarm_control_panel(
|
|||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
"alarm_control_panel", "alarm_arm_away", {"entity_id": entity_id}, blocking=True
|
"alarm_control_panel", "alarm_arm_away", {"entity_id": entity_id}, blocking=True
|
||||||
)
|
)
|
||||||
assert home.mock_calls[-1][0] == "set_security_zones_activation"
|
assert home.mock_calls[-1][0] == "set_security_zones_activation_async"
|
||||||
assert home.mock_calls[-1][1] == (True, True)
|
assert home.mock_calls[-1][1] == (True, True)
|
||||||
await _async_manipulate_security_zones(
|
await _async_manipulate_security_zones(
|
||||||
hass, home, internal_active=True, external_active=True
|
hass, home, internal_active=True, external_active=True
|
||||||
@ -83,7 +83,7 @@ async def test_hmip_alarm_control_panel(
|
|||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
"alarm_control_panel", "alarm_arm_home", {"entity_id": entity_id}, blocking=True
|
"alarm_control_panel", "alarm_arm_home", {"entity_id": entity_id}, blocking=True
|
||||||
)
|
)
|
||||||
assert home.mock_calls[-1][0] == "set_security_zones_activation"
|
assert home.mock_calls[-1][0] == "set_security_zones_activation_async"
|
||||||
assert home.mock_calls[-1][1] == (False, True)
|
assert home.mock_calls[-1][1] == (False, True)
|
||||||
await _async_manipulate_security_zones(hass, home, external_active=True)
|
await _async_manipulate_security_zones(hass, home, external_active=True)
|
||||||
assert hass.states.get(entity_id).state == AlarmControlPanelState.ARMED_HOME
|
assert hass.states.get(entity_id).state == AlarmControlPanelState.ARMED_HOME
|
||||||
@ -91,7 +91,7 @@ async def test_hmip_alarm_control_panel(
|
|||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
"alarm_control_panel", "alarm_disarm", {"entity_id": entity_id}, blocking=True
|
"alarm_control_panel", "alarm_disarm", {"entity_id": entity_id}, blocking=True
|
||||||
)
|
)
|
||||||
assert home.mock_calls[-1][0] == "set_security_zones_activation"
|
assert home.mock_calls[-1][0] == "set_security_zones_activation_async"
|
||||||
assert home.mock_calls[-1][1] == (False, False)
|
assert home.mock_calls[-1][1] == (False, False)
|
||||||
await _async_manipulate_security_zones(hass, home)
|
await _async_manipulate_security_zones(hass, home)
|
||||||
assert hass.states.get(entity_id).state == AlarmControlPanelState.DISARMED
|
assert hass.states.get(entity_id).state == AlarmControlPanelState.DISARMED
|
||||||
@ -99,7 +99,7 @@ async def test_hmip_alarm_control_panel(
|
|||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
"alarm_control_panel", "alarm_arm_away", {"entity_id": entity_id}, blocking=True
|
"alarm_control_panel", "alarm_arm_away", {"entity_id": entity_id}, blocking=True
|
||||||
)
|
)
|
||||||
assert home.mock_calls[-1][0] == "set_security_zones_activation"
|
assert home.mock_calls[-1][0] == "set_security_zones_activation_async"
|
||||||
assert home.mock_calls[-1][1] == (True, True)
|
assert home.mock_calls[-1][1] == (True, True)
|
||||||
await _async_manipulate_security_zones(
|
await _async_manipulate_security_zones(
|
||||||
hass, home, internal_active=True, external_active=True, alarm_triggered=True
|
hass, home, internal_active=True, external_active=True, alarm_triggered=True
|
||||||
@ -109,7 +109,7 @@ async def test_hmip_alarm_control_panel(
|
|||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
"alarm_control_panel", "alarm_arm_home", {"entity_id": entity_id}, blocking=True
|
"alarm_control_panel", "alarm_arm_home", {"entity_id": entity_id}, blocking=True
|
||||||
)
|
)
|
||||||
assert home.mock_calls[-1][0] == "set_security_zones_activation"
|
assert home.mock_calls[-1][0] == "set_security_zones_activation_async"
|
||||||
assert home.mock_calls[-1][1] == (False, True)
|
assert home.mock_calls[-1][1] == (False, True)
|
||||||
await _async_manipulate_security_zones(
|
await _async_manipulate_security_zones(
|
||||||
hass, home, external_active=True, alarm_triggered=True
|
hass, home, external_active=True, alarm_triggered=True
|
||||||
|
@ -83,7 +83,7 @@ async def test_hmip_heating_group_heat(
|
|||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
assert len(hmip_device.mock_calls) == service_call_counter + 1
|
assert len(hmip_device.mock_calls) == service_call_counter + 1
|
||||||
assert hmip_device.mock_calls[-1][0] == "set_point_temperature"
|
assert hmip_device.mock_calls[-1][0] == "set_point_temperature_async"
|
||||||
assert hmip_device.mock_calls[-1][1] == (22.5,)
|
assert hmip_device.mock_calls[-1][1] == (22.5,)
|
||||||
await async_manipulate_test_data(hass, hmip_device, "actualTemperature", 22.5)
|
await async_manipulate_test_data(hass, hmip_device, "actualTemperature", 22.5)
|
||||||
ha_state = hass.states.get(entity_id)
|
ha_state = hass.states.get(entity_id)
|
||||||
@ -96,7 +96,7 @@ async def test_hmip_heating_group_heat(
|
|||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
assert len(hmip_device.mock_calls) == service_call_counter + 3
|
assert len(hmip_device.mock_calls) == service_call_counter + 3
|
||||||
assert hmip_device.mock_calls[-1][0] == "set_control_mode"
|
assert hmip_device.mock_calls[-1][0] == "set_control_mode_async"
|
||||||
assert hmip_device.mock_calls[-1][1] == ("MANUAL",)
|
assert hmip_device.mock_calls[-1][1] == ("MANUAL",)
|
||||||
await async_manipulate_test_data(hass, hmip_device, "controlMode", "MANUAL")
|
await async_manipulate_test_data(hass, hmip_device, "controlMode", "MANUAL")
|
||||||
ha_state = hass.states.get(entity_id)
|
ha_state = hass.states.get(entity_id)
|
||||||
@ -109,7 +109,7 @@ async def test_hmip_heating_group_heat(
|
|||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
assert len(hmip_device.mock_calls) == service_call_counter + 5
|
assert len(hmip_device.mock_calls) == service_call_counter + 5
|
||||||
assert hmip_device.mock_calls[-1][0] == "set_control_mode"
|
assert hmip_device.mock_calls[-1][0] == "set_control_mode_async"
|
||||||
assert hmip_device.mock_calls[-1][1] == ("AUTOMATIC",)
|
assert hmip_device.mock_calls[-1][1] == ("AUTOMATIC",)
|
||||||
await async_manipulate_test_data(hass, hmip_device, "controlMode", "AUTO")
|
await async_manipulate_test_data(hass, hmip_device, "controlMode", "AUTO")
|
||||||
ha_state = hass.states.get(entity_id)
|
ha_state = hass.states.get(entity_id)
|
||||||
@ -122,7 +122,7 @@ async def test_hmip_heating_group_heat(
|
|||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
assert len(hmip_device.mock_calls) == service_call_counter + 7
|
assert len(hmip_device.mock_calls) == service_call_counter + 7
|
||||||
assert hmip_device.mock_calls[-1][0] == "set_boost"
|
assert hmip_device.mock_calls[-1][0] == "set_boost_async"
|
||||||
assert hmip_device.mock_calls[-1][1] == ()
|
assert hmip_device.mock_calls[-1][1] == ()
|
||||||
await async_manipulate_test_data(hass, hmip_device, "boostMode", True)
|
await async_manipulate_test_data(hass, hmip_device, "boostMode", True)
|
||||||
ha_state = hass.states.get(entity_id)
|
ha_state = hass.states.get(entity_id)
|
||||||
@ -135,7 +135,7 @@ async def test_hmip_heating_group_heat(
|
|||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
assert len(hmip_device.mock_calls) == service_call_counter + 11
|
assert len(hmip_device.mock_calls) == service_call_counter + 11
|
||||||
assert hmip_device.mock_calls[-1][0] == "set_active_profile"
|
assert hmip_device.mock_calls[-1][0] == "set_active_profile_async"
|
||||||
assert hmip_device.mock_calls[-1][1] == (0,)
|
assert hmip_device.mock_calls[-1][1] == (0,)
|
||||||
await async_manipulate_test_data(hass, hmip_device, "boostMode", False)
|
await async_manipulate_test_data(hass, hmip_device, "boostMode", False)
|
||||||
ha_state = hass.states.get(entity_id)
|
ha_state = hass.states.get(entity_id)
|
||||||
@ -176,7 +176,7 @@ async def test_hmip_heating_group_heat(
|
|||||||
)
|
)
|
||||||
|
|
||||||
assert len(hmip_device.mock_calls) == service_call_counter + 18
|
assert len(hmip_device.mock_calls) == service_call_counter + 18
|
||||||
assert hmip_device.mock_calls[-1][0] == "set_active_profile"
|
assert hmip_device.mock_calls[-1][0] == "set_active_profile_async"
|
||||||
assert hmip_device.mock_calls[-1][1] == (1,)
|
assert hmip_device.mock_calls[-1][1] == (1,)
|
||||||
|
|
||||||
mock_hap.home.get_functionalHome(
|
mock_hap.home.get_functionalHome(
|
||||||
@ -194,7 +194,7 @@ async def test_hmip_heating_group_heat(
|
|||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
assert len(hmip_device.mock_calls) == service_call_counter + 20
|
assert len(hmip_device.mock_calls) == service_call_counter + 20
|
||||||
assert hmip_device.mock_calls[-1][0] == "set_control_mode"
|
assert hmip_device.mock_calls[-1][0] == "set_control_mode_async"
|
||||||
assert hmip_device.mock_calls[-1][1] == ("MANUAL",)
|
assert hmip_device.mock_calls[-1][1] == ("MANUAL",)
|
||||||
await async_manipulate_test_data(hass, hmip_device, "controlMode", "MANUAL")
|
await async_manipulate_test_data(hass, hmip_device, "controlMode", "MANUAL")
|
||||||
ha_state = hass.states.get(entity_id)
|
ha_state = hass.states.get(entity_id)
|
||||||
@ -208,7 +208,7 @@ async def test_hmip_heating_group_heat(
|
|||||||
)
|
)
|
||||||
|
|
||||||
assert len(hmip_device.mock_calls) == service_call_counter + 23
|
assert len(hmip_device.mock_calls) == service_call_counter + 23
|
||||||
assert hmip_device.mock_calls[-1][0] == "set_active_profile"
|
assert hmip_device.mock_calls[-1][0] == "set_active_profile_async"
|
||||||
assert hmip_device.mock_calls[-1][1] == (1,)
|
assert hmip_device.mock_calls[-1][1] == (1,)
|
||||||
hmip_device.activeProfile = hmip_device.profiles[0]
|
hmip_device.activeProfile = hmip_device.profiles[0]
|
||||||
await async_manipulate_test_data(hass, hmip_device, "controlMode", "AUTOMATIC")
|
await async_manipulate_test_data(hass, hmip_device, "controlMode", "AUTOMATIC")
|
||||||
@ -235,7 +235,7 @@ async def test_hmip_heating_group_heat(
|
|||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
assert len(hmip_device.mock_calls) == service_call_counter + 25
|
assert len(hmip_device.mock_calls) == service_call_counter + 25
|
||||||
assert hmip_device.mock_calls[-1][0] == "set_control_mode"
|
assert hmip_device.mock_calls[-1][0] == "set_control_mode_async"
|
||||||
assert hmip_device.mock_calls[-1][1] == ("ECO",)
|
assert hmip_device.mock_calls[-1][1] == ("ECO",)
|
||||||
await async_manipulate_test_data(hass, hmip_device, "controlMode", "ECO")
|
await async_manipulate_test_data(hass, hmip_device, "controlMode", "ECO")
|
||||||
ha_state = hass.states.get(entity_id)
|
ha_state = hass.states.get(entity_id)
|
||||||
@ -293,7 +293,7 @@ async def test_hmip_heating_group_cool(
|
|||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
assert len(hmip_device.mock_calls) == service_call_counter + 1
|
assert len(hmip_device.mock_calls) == service_call_counter + 1
|
||||||
assert hmip_device.mock_calls[-1][0] == "set_control_mode"
|
assert hmip_device.mock_calls[-1][0] == "set_control_mode_async"
|
||||||
assert hmip_device.mock_calls[-1][1] == ("MANUAL",)
|
assert hmip_device.mock_calls[-1][1] == ("MANUAL",)
|
||||||
await async_manipulate_test_data(hass, hmip_device, "controlMode", "MANUAL")
|
await async_manipulate_test_data(hass, hmip_device, "controlMode", "MANUAL")
|
||||||
ha_state = hass.states.get(entity_id)
|
ha_state = hass.states.get(entity_id)
|
||||||
@ -306,7 +306,7 @@ async def test_hmip_heating_group_cool(
|
|||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
assert len(hmip_device.mock_calls) == service_call_counter + 3
|
assert len(hmip_device.mock_calls) == service_call_counter + 3
|
||||||
assert hmip_device.mock_calls[-1][0] == "set_control_mode"
|
assert hmip_device.mock_calls[-1][0] == "set_control_mode_async"
|
||||||
assert hmip_device.mock_calls[-1][1] == ("AUTOMATIC",)
|
assert hmip_device.mock_calls[-1][1] == ("AUTOMATIC",)
|
||||||
await async_manipulate_test_data(hass, hmip_device, "controlMode", "AUTO")
|
await async_manipulate_test_data(hass, hmip_device, "controlMode", "AUTO")
|
||||||
ha_state = hass.states.get(entity_id)
|
ha_state = hass.states.get(entity_id)
|
||||||
@ -320,7 +320,7 @@ async def test_hmip_heating_group_cool(
|
|||||||
)
|
)
|
||||||
|
|
||||||
assert len(hmip_device.mock_calls) == service_call_counter + 6
|
assert len(hmip_device.mock_calls) == service_call_counter + 6
|
||||||
assert hmip_device.mock_calls[-1][0] == "set_active_profile"
|
assert hmip_device.mock_calls[-1][0] == "set_active_profile_async"
|
||||||
assert hmip_device.mock_calls[-1][1] == (4,)
|
assert hmip_device.mock_calls[-1][1] == (4,)
|
||||||
|
|
||||||
hmip_device.activeProfile = hmip_device.profiles[4]
|
hmip_device.activeProfile = hmip_device.profiles[4]
|
||||||
@ -373,7 +373,7 @@ async def test_hmip_heating_group_cool(
|
|||||||
)
|
)
|
||||||
|
|
||||||
assert len(hmip_device.mock_calls) == service_call_counter + 17
|
assert len(hmip_device.mock_calls) == service_call_counter + 17
|
||||||
assert hmip_device.mock_calls[-1][0] == "set_active_profile"
|
assert hmip_device.mock_calls[-1][0] == "set_active_profile_async"
|
||||||
assert hmip_device.mock_calls[-1][1] == (4,)
|
assert hmip_device.mock_calls[-1][1] == (4,)
|
||||||
|
|
||||||
|
|
||||||
@ -531,7 +531,7 @@ async def test_hmip_climate_services(
|
|||||||
{"duration": 60, "accesspoint_id": HAPID},
|
{"duration": 60, "accesspoint_id": HAPID},
|
||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
assert home.mock_calls[-1][0] == "activate_absence_with_duration"
|
assert home.mock_calls[-1][0] == "activate_absence_with_duration_async"
|
||||||
assert home.mock_calls[-1][1] == (60,)
|
assert home.mock_calls[-1][1] == (60,)
|
||||||
assert len(home._connection.mock_calls) == 1
|
assert len(home._connection.mock_calls) == 1
|
||||||
|
|
||||||
@ -541,7 +541,7 @@ async def test_hmip_climate_services(
|
|||||||
{"duration": 60},
|
{"duration": 60},
|
||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
assert home.mock_calls[-1][0] == "activate_absence_with_duration"
|
assert home.mock_calls[-1][0] == "activate_absence_with_duration_async"
|
||||||
assert home.mock_calls[-1][1] == (60,)
|
assert home.mock_calls[-1][1] == (60,)
|
||||||
assert len(home._connection.mock_calls) == 2
|
assert len(home._connection.mock_calls) == 2
|
||||||
|
|
||||||
@ -551,7 +551,7 @@ async def test_hmip_climate_services(
|
|||||||
{"endtime": "2019-02-17 14:00", "accesspoint_id": HAPID},
|
{"endtime": "2019-02-17 14:00", "accesspoint_id": HAPID},
|
||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
assert home.mock_calls[-1][0] == "activate_absence_with_period"
|
assert home.mock_calls[-1][0] == "activate_absence_with_period_async"
|
||||||
assert home.mock_calls[-1][1] == (datetime.datetime(2019, 2, 17, 14, 0),)
|
assert home.mock_calls[-1][1] == (datetime.datetime(2019, 2, 17, 14, 0),)
|
||||||
assert len(home._connection.mock_calls) == 3
|
assert len(home._connection.mock_calls) == 3
|
||||||
|
|
||||||
@ -561,7 +561,7 @@ async def test_hmip_climate_services(
|
|||||||
{"endtime": "2019-02-17 14:00"},
|
{"endtime": "2019-02-17 14:00"},
|
||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
assert home.mock_calls[-1][0] == "activate_absence_with_period"
|
assert home.mock_calls[-1][0] == "activate_absence_with_period_async"
|
||||||
assert home.mock_calls[-1][1] == (datetime.datetime(2019, 2, 17, 14, 0),)
|
assert home.mock_calls[-1][1] == (datetime.datetime(2019, 2, 17, 14, 0),)
|
||||||
assert len(home._connection.mock_calls) == 4
|
assert len(home._connection.mock_calls) == 4
|
||||||
|
|
||||||
@ -571,7 +571,7 @@ async def test_hmip_climate_services(
|
|||||||
{"endtime": "2019-02-17 14:00", "temperature": 18.5, "accesspoint_id": HAPID},
|
{"endtime": "2019-02-17 14:00", "temperature": 18.5, "accesspoint_id": HAPID},
|
||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
assert home.mock_calls[-1][0] == "activate_vacation"
|
assert home.mock_calls[-1][0] == "activate_vacation_async"
|
||||||
assert home.mock_calls[-1][1] == (datetime.datetime(2019, 2, 17, 14, 0), 18.5)
|
assert home.mock_calls[-1][1] == (datetime.datetime(2019, 2, 17, 14, 0), 18.5)
|
||||||
assert len(home._connection.mock_calls) == 5
|
assert len(home._connection.mock_calls) == 5
|
||||||
|
|
||||||
@ -581,7 +581,7 @@ async def test_hmip_climate_services(
|
|||||||
{"endtime": "2019-02-17 14:00", "temperature": 18.5},
|
{"endtime": "2019-02-17 14:00", "temperature": 18.5},
|
||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
assert home.mock_calls[-1][0] == "activate_vacation"
|
assert home.mock_calls[-1][0] == "activate_vacation_async"
|
||||||
assert home.mock_calls[-1][1] == (datetime.datetime(2019, 2, 17, 14, 0), 18.5)
|
assert home.mock_calls[-1][1] == (datetime.datetime(2019, 2, 17, 14, 0), 18.5)
|
||||||
assert len(home._connection.mock_calls) == 6
|
assert len(home._connection.mock_calls) == 6
|
||||||
|
|
||||||
@ -591,14 +591,14 @@ async def test_hmip_climate_services(
|
|||||||
{"accesspoint_id": HAPID},
|
{"accesspoint_id": HAPID},
|
||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
assert home.mock_calls[-1][0] == "deactivate_absence"
|
assert home.mock_calls[-1][0] == "deactivate_absence_async"
|
||||||
assert home.mock_calls[-1][1] == ()
|
assert home.mock_calls[-1][1] == ()
|
||||||
assert len(home._connection.mock_calls) == 7
|
assert len(home._connection.mock_calls) == 7
|
||||||
|
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
"homematicip_cloud", "deactivate_eco_mode", blocking=True
|
"homematicip_cloud", "deactivate_eco_mode", blocking=True
|
||||||
)
|
)
|
||||||
assert home.mock_calls[-1][0] == "deactivate_absence"
|
assert home.mock_calls[-1][0] == "deactivate_absence_async"
|
||||||
assert home.mock_calls[-1][1] == ()
|
assert home.mock_calls[-1][1] == ()
|
||||||
assert len(home._connection.mock_calls) == 8
|
assert len(home._connection.mock_calls) == 8
|
||||||
|
|
||||||
@ -608,14 +608,14 @@ async def test_hmip_climate_services(
|
|||||||
{"accesspoint_id": HAPID},
|
{"accesspoint_id": HAPID},
|
||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
assert home.mock_calls[-1][0] == "deactivate_vacation"
|
assert home.mock_calls[-1][0] == "deactivate_vacation_async"
|
||||||
assert home.mock_calls[-1][1] == ()
|
assert home.mock_calls[-1][1] == ()
|
||||||
assert len(home._connection.mock_calls) == 9
|
assert len(home._connection.mock_calls) == 9
|
||||||
|
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
"homematicip_cloud", "deactivate_vacation", blocking=True
|
"homematicip_cloud", "deactivate_vacation", blocking=True
|
||||||
)
|
)
|
||||||
assert home.mock_calls[-1][0] == "deactivate_vacation"
|
assert home.mock_calls[-1][0] == "deactivate_vacation_async"
|
||||||
assert home.mock_calls[-1][1] == ()
|
assert home.mock_calls[-1][1] == ()
|
||||||
assert len(home._connection.mock_calls) == 10
|
assert len(home._connection.mock_calls) == 10
|
||||||
|
|
||||||
@ -646,7 +646,7 @@ async def test_hmip_set_home_cooling_mode(
|
|||||||
{"accesspoint_id": HAPID, "cooling": False},
|
{"accesspoint_id": HAPID, "cooling": False},
|
||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
assert home.mock_calls[-1][0] == "set_cooling"
|
assert home.mock_calls[-1][0] == "set_cooling_async"
|
||||||
assert home.mock_calls[-1][1] == (False,)
|
assert home.mock_calls[-1][1] == (False,)
|
||||||
assert len(home._connection.mock_calls) == 1
|
assert len(home._connection.mock_calls) == 1
|
||||||
|
|
||||||
@ -656,14 +656,14 @@ async def test_hmip_set_home_cooling_mode(
|
|||||||
{"accesspoint_id": HAPID, "cooling": True},
|
{"accesspoint_id": HAPID, "cooling": True},
|
||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
assert home.mock_calls[-1][0] == "set_cooling"
|
assert home.mock_calls[-1][0] == "set_cooling_async"
|
||||||
assert home.mock_calls[-1][1]
|
assert home.mock_calls[-1][1]
|
||||||
assert len(home._connection.mock_calls) == 2
|
assert len(home._connection.mock_calls) == 2
|
||||||
|
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
"homematicip_cloud", "set_home_cooling_mode", blocking=True
|
"homematicip_cloud", "set_home_cooling_mode", blocking=True
|
||||||
)
|
)
|
||||||
assert home.mock_calls[-1][0] == "set_cooling"
|
assert home.mock_calls[-1][0] == "set_cooling_async"
|
||||||
assert home.mock_calls[-1][1]
|
assert home.mock_calls[-1][1]
|
||||||
assert len(home._connection.mock_calls) == 3
|
assert len(home._connection.mock_calls) == 3
|
||||||
|
|
||||||
@ -703,9 +703,9 @@ async def test_hmip_heating_group_services(
|
|||||||
{"climate_profile_index": 2, "entity_id": "climate.badezimmer"},
|
{"climate_profile_index": 2, "entity_id": "climate.badezimmer"},
|
||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
assert hmip_device.mock_calls[-1][0] == "set_active_profile"
|
assert hmip_device.mock_calls[-1][0] == "set_active_profile_async"
|
||||||
assert hmip_device.mock_calls[-1][1] == (1,)
|
assert hmip_device.mock_calls[-1][1] == (1,)
|
||||||
assert len(hmip_device._connection.mock_calls) == 2
|
assert len(hmip_device._connection.mock_calls) == 1
|
||||||
|
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
"homematicip_cloud",
|
"homematicip_cloud",
|
||||||
@ -713,6 +713,6 @@ async def test_hmip_heating_group_services(
|
|||||||
{"climate_profile_index": 2, "entity_id": "all"},
|
{"climate_profile_index": 2, "entity_id": "all"},
|
||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
assert hmip_device.mock_calls[-1][0] == "set_active_profile"
|
assert hmip_device.mock_calls[-1][0] == "set_active_profile_async"
|
||||||
assert hmip_device.mock_calls[-1][1] == (1,)
|
assert hmip_device.mock_calls[-1][1] == (1,)
|
||||||
assert len(hmip_device._connection.mock_calls) == 4
|
assert len(hmip_device._connection.mock_calls) == 2
|
||||||
|
@ -47,7 +47,7 @@ async def test_hmip_cover_shutter(
|
|||||||
"cover", "open_cover", {"entity_id": entity_id}, blocking=True
|
"cover", "open_cover", {"entity_id": entity_id}, blocking=True
|
||||||
)
|
)
|
||||||
assert len(hmip_device.mock_calls) == service_call_counter + 1
|
assert len(hmip_device.mock_calls) == service_call_counter + 1
|
||||||
assert hmip_device.mock_calls[-1][0] == "set_shutter_level"
|
assert hmip_device.mock_calls[-1][0] == "set_shutter_level_async"
|
||||||
assert hmip_device.mock_calls[-1][1] == (0, 1)
|
assert hmip_device.mock_calls[-1][1] == (0, 1)
|
||||||
await async_manipulate_test_data(hass, hmip_device, "shutterLevel", 0)
|
await async_manipulate_test_data(hass, hmip_device, "shutterLevel", 0)
|
||||||
ha_state = hass.states.get(entity_id)
|
ha_state = hass.states.get(entity_id)
|
||||||
@ -61,7 +61,7 @@ async def test_hmip_cover_shutter(
|
|||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
assert len(hmip_device.mock_calls) == service_call_counter + 3
|
assert len(hmip_device.mock_calls) == service_call_counter + 3
|
||||||
assert hmip_device.mock_calls[-1][0] == "set_shutter_level"
|
assert hmip_device.mock_calls[-1][0] == "set_shutter_level_async"
|
||||||
assert hmip_device.mock_calls[-1][1] == (0.5, 1)
|
assert hmip_device.mock_calls[-1][1] == (0.5, 1)
|
||||||
await async_manipulate_test_data(hass, hmip_device, "shutterLevel", 0.5)
|
await async_manipulate_test_data(hass, hmip_device, "shutterLevel", 0.5)
|
||||||
ha_state = hass.states.get(entity_id)
|
ha_state = hass.states.get(entity_id)
|
||||||
@ -72,7 +72,7 @@ async def test_hmip_cover_shutter(
|
|||||||
"cover", "close_cover", {"entity_id": entity_id}, blocking=True
|
"cover", "close_cover", {"entity_id": entity_id}, blocking=True
|
||||||
)
|
)
|
||||||
assert len(hmip_device.mock_calls) == service_call_counter + 5
|
assert len(hmip_device.mock_calls) == service_call_counter + 5
|
||||||
assert hmip_device.mock_calls[-1][0] == "set_shutter_level"
|
assert hmip_device.mock_calls[-1][0] == "set_shutter_level_async"
|
||||||
assert hmip_device.mock_calls[-1][1] == (1, 1)
|
assert hmip_device.mock_calls[-1][1] == (1, 1)
|
||||||
await async_manipulate_test_data(hass, hmip_device, "shutterLevel", 1)
|
await async_manipulate_test_data(hass, hmip_device, "shutterLevel", 1)
|
||||||
ha_state = hass.states.get(entity_id)
|
ha_state = hass.states.get(entity_id)
|
||||||
@ -83,7 +83,7 @@ async def test_hmip_cover_shutter(
|
|||||||
"cover", "stop_cover", {"entity_id": entity_id}, blocking=True
|
"cover", "stop_cover", {"entity_id": entity_id}, blocking=True
|
||||||
)
|
)
|
||||||
assert len(hmip_device.mock_calls) == service_call_counter + 7
|
assert len(hmip_device.mock_calls) == service_call_counter + 7
|
||||||
assert hmip_device.mock_calls[-1][0] == "set_shutter_stop"
|
assert hmip_device.mock_calls[-1][0] == "set_shutter_stop_async"
|
||||||
assert hmip_device.mock_calls[-1][1] == (1,)
|
assert hmip_device.mock_calls[-1][1] == (1,)
|
||||||
|
|
||||||
await async_manipulate_test_data(hass, hmip_device, "shutterLevel", None)
|
await async_manipulate_test_data(hass, hmip_device, "shutterLevel", None)
|
||||||
@ -115,7 +115,7 @@ async def test_hmip_cover_slats(
|
|||||||
"cover", "open_cover_tilt", {"entity_id": entity_id}, blocking=True
|
"cover", "open_cover_tilt", {"entity_id": entity_id}, blocking=True
|
||||||
)
|
)
|
||||||
assert len(hmip_device.mock_calls) == service_call_counter + 1
|
assert len(hmip_device.mock_calls) == service_call_counter + 1
|
||||||
assert hmip_device.mock_calls[-1][0] == "set_slats_level"
|
assert hmip_device.mock_calls[-1][0] == "set_slats_level_async"
|
||||||
assert hmip_device.mock_calls[-1][2] == {"channelIndex": 1, "slatsLevel": 0}
|
assert hmip_device.mock_calls[-1][2] == {"channelIndex": 1, "slatsLevel": 0}
|
||||||
await async_manipulate_test_data(hass, hmip_device, "shutterLevel", 0)
|
await async_manipulate_test_data(hass, hmip_device, "shutterLevel", 0)
|
||||||
await async_manipulate_test_data(hass, hmip_device, "slatsLevel", 0)
|
await async_manipulate_test_data(hass, hmip_device, "slatsLevel", 0)
|
||||||
@ -131,7 +131,7 @@ async def test_hmip_cover_slats(
|
|||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
assert len(hmip_device.mock_calls) == service_call_counter + 4
|
assert len(hmip_device.mock_calls) == service_call_counter + 4
|
||||||
assert hmip_device.mock_calls[-1][0] == "set_slats_level"
|
assert hmip_device.mock_calls[-1][0] == "set_slats_level_async"
|
||||||
assert hmip_device.mock_calls[-1][2] == {"channelIndex": 1, "slatsLevel": 0.5}
|
assert hmip_device.mock_calls[-1][2] == {"channelIndex": 1, "slatsLevel": 0.5}
|
||||||
await async_manipulate_test_data(hass, hmip_device, "slatsLevel", 0.5)
|
await async_manipulate_test_data(hass, hmip_device, "slatsLevel", 0.5)
|
||||||
ha_state = hass.states.get(entity_id)
|
ha_state = hass.states.get(entity_id)
|
||||||
@ -143,7 +143,7 @@ async def test_hmip_cover_slats(
|
|||||||
"cover", "close_cover_tilt", {"entity_id": entity_id}, blocking=True
|
"cover", "close_cover_tilt", {"entity_id": entity_id}, blocking=True
|
||||||
)
|
)
|
||||||
assert len(hmip_device.mock_calls) == service_call_counter + 6
|
assert len(hmip_device.mock_calls) == service_call_counter + 6
|
||||||
assert hmip_device.mock_calls[-1][0] == "set_slats_level"
|
assert hmip_device.mock_calls[-1][0] == "set_slats_level_async"
|
||||||
assert hmip_device.mock_calls[-1][2] == {"channelIndex": 1, "slatsLevel": 1}
|
assert hmip_device.mock_calls[-1][2] == {"channelIndex": 1, "slatsLevel": 1}
|
||||||
await async_manipulate_test_data(hass, hmip_device, "slatsLevel", 1)
|
await async_manipulate_test_data(hass, hmip_device, "slatsLevel", 1)
|
||||||
ha_state = hass.states.get(entity_id)
|
ha_state = hass.states.get(entity_id)
|
||||||
@ -155,7 +155,7 @@ async def test_hmip_cover_slats(
|
|||||||
"cover", "stop_cover_tilt", {"entity_id": entity_id}, blocking=True
|
"cover", "stop_cover_tilt", {"entity_id": entity_id}, blocking=True
|
||||||
)
|
)
|
||||||
assert len(hmip_device.mock_calls) == service_call_counter + 8
|
assert len(hmip_device.mock_calls) == service_call_counter + 8
|
||||||
assert hmip_device.mock_calls[-1][0] == "set_shutter_stop"
|
assert hmip_device.mock_calls[-1][0] == "set_shutter_stop_async"
|
||||||
assert hmip_device.mock_calls[-1][1] == (1,)
|
assert hmip_device.mock_calls[-1][1] == (1,)
|
||||||
|
|
||||||
await async_manipulate_test_data(hass, hmip_device, "slatsLevel", None)
|
await async_manipulate_test_data(hass, hmip_device, "slatsLevel", None)
|
||||||
@ -195,7 +195,7 @@ async def test_hmip_multi_cover_slats(
|
|||||||
"cover", "open_cover_tilt", {"entity_id": entity_id}, blocking=True
|
"cover", "open_cover_tilt", {"entity_id": entity_id}, blocking=True
|
||||||
)
|
)
|
||||||
assert len(hmip_device.mock_calls) == service_call_counter + 1
|
assert len(hmip_device.mock_calls) == service_call_counter + 1
|
||||||
assert hmip_device.mock_calls[-1][0] == "set_slats_level"
|
assert hmip_device.mock_calls[-1][0] == "set_slats_level_async"
|
||||||
assert hmip_device.mock_calls[-1][2] == {"channelIndex": 4, "slatsLevel": 0}
|
assert hmip_device.mock_calls[-1][2] == {"channelIndex": 4, "slatsLevel": 0}
|
||||||
await async_manipulate_test_data(hass, hmip_device, "shutterLevel", 0, channel=4)
|
await async_manipulate_test_data(hass, hmip_device, "shutterLevel", 0, channel=4)
|
||||||
await async_manipulate_test_data(hass, hmip_device, "slatsLevel", 0, channel=4)
|
await async_manipulate_test_data(hass, hmip_device, "slatsLevel", 0, channel=4)
|
||||||
@ -211,7 +211,7 @@ async def test_hmip_multi_cover_slats(
|
|||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
assert len(hmip_device.mock_calls) == service_call_counter + 4
|
assert len(hmip_device.mock_calls) == service_call_counter + 4
|
||||||
assert hmip_device.mock_calls[-1][0] == "set_slats_level"
|
assert hmip_device.mock_calls[-1][0] == "set_slats_level_async"
|
||||||
assert hmip_device.mock_calls[-1][2] == {"channelIndex": 4, "slatsLevel": 0.5}
|
assert hmip_device.mock_calls[-1][2] == {"channelIndex": 4, "slatsLevel": 0.5}
|
||||||
await async_manipulate_test_data(hass, hmip_device, "slatsLevel", 0.5, channel=4)
|
await async_manipulate_test_data(hass, hmip_device, "slatsLevel", 0.5, channel=4)
|
||||||
ha_state = hass.states.get(entity_id)
|
ha_state = hass.states.get(entity_id)
|
||||||
@ -223,7 +223,7 @@ async def test_hmip_multi_cover_slats(
|
|||||||
"cover", "close_cover_tilt", {"entity_id": entity_id}, blocking=True
|
"cover", "close_cover_tilt", {"entity_id": entity_id}, blocking=True
|
||||||
)
|
)
|
||||||
assert len(hmip_device.mock_calls) == service_call_counter + 6
|
assert len(hmip_device.mock_calls) == service_call_counter + 6
|
||||||
assert hmip_device.mock_calls[-1][0] == "set_slats_level"
|
assert hmip_device.mock_calls[-1][0] == "set_slats_level_async"
|
||||||
assert hmip_device.mock_calls[-1][2] == {"channelIndex": 4, "slatsLevel": 1}
|
assert hmip_device.mock_calls[-1][2] == {"channelIndex": 4, "slatsLevel": 1}
|
||||||
await async_manipulate_test_data(hass, hmip_device, "slatsLevel", 1, channel=4)
|
await async_manipulate_test_data(hass, hmip_device, "slatsLevel", 1, channel=4)
|
||||||
ha_state = hass.states.get(entity_id)
|
ha_state = hass.states.get(entity_id)
|
||||||
@ -235,7 +235,7 @@ async def test_hmip_multi_cover_slats(
|
|||||||
"cover", "stop_cover_tilt", {"entity_id": entity_id}, blocking=True
|
"cover", "stop_cover_tilt", {"entity_id": entity_id}, blocking=True
|
||||||
)
|
)
|
||||||
assert len(hmip_device.mock_calls) == service_call_counter + 8
|
assert len(hmip_device.mock_calls) == service_call_counter + 8
|
||||||
assert hmip_device.mock_calls[-1][0] == "set_shutter_stop"
|
assert hmip_device.mock_calls[-1][0] == "set_shutter_stop_async"
|
||||||
assert hmip_device.mock_calls[-1][1] == (4,)
|
assert hmip_device.mock_calls[-1][1] == (4,)
|
||||||
|
|
||||||
await async_manipulate_test_data(hass, hmip_device, "slatsLevel", None, channel=4)
|
await async_manipulate_test_data(hass, hmip_device, "slatsLevel", None, channel=4)
|
||||||
@ -271,7 +271,7 @@ async def test_hmip_blind_module(
|
|||||||
"cover", "open_cover_tilt", {"entity_id": entity_id}, blocking=True
|
"cover", "open_cover_tilt", {"entity_id": entity_id}, blocking=True
|
||||||
)
|
)
|
||||||
assert len(hmip_device.mock_calls) == service_call_counter + 1
|
assert len(hmip_device.mock_calls) == service_call_counter + 1
|
||||||
assert hmip_device.mock_calls[-1][0] == "set_secondary_shading_level"
|
assert hmip_device.mock_calls[-1][0] == "set_secondary_shading_level_async"
|
||||||
assert hmip_device.mock_calls[-1][2] == {
|
assert hmip_device.mock_calls[-1][2] == {
|
||||||
"primaryShadingLevel": 0.94956,
|
"primaryShadingLevel": 0.94956,
|
||||||
"secondaryShadingLevel": 0,
|
"secondaryShadingLevel": 0,
|
||||||
@ -284,7 +284,7 @@ async def test_hmip_blind_module(
|
|||||||
)
|
)
|
||||||
assert len(hmip_device.mock_calls) == service_call_counter + 4
|
assert len(hmip_device.mock_calls) == service_call_counter + 4
|
||||||
|
|
||||||
assert hmip_device.mock_calls[-1][0] == "set_primary_shading_level"
|
assert hmip_device.mock_calls[-1][0] == "set_primary_shading_level_async"
|
||||||
assert hmip_device.mock_calls[-1][2] == {"primaryShadingLevel": 0}
|
assert hmip_device.mock_calls[-1][2] == {"primaryShadingLevel": 0}
|
||||||
|
|
||||||
ha_state = hass.states.get(entity_id)
|
ha_state = hass.states.get(entity_id)
|
||||||
@ -308,7 +308,7 @@ async def test_hmip_blind_module(
|
|||||||
)
|
)
|
||||||
assert len(hmip_device.mock_calls) == service_call_counter + 8
|
assert len(hmip_device.mock_calls) == service_call_counter + 8
|
||||||
|
|
||||||
assert hmip_device.mock_calls[-1][0] == "set_primary_shading_level"
|
assert hmip_device.mock_calls[-1][0] == "set_primary_shading_level_async"
|
||||||
assert hmip_device.mock_calls[-1][2] == {"primaryShadingLevel": 0.5}
|
assert hmip_device.mock_calls[-1][2] == {"primaryShadingLevel": 0.5}
|
||||||
ha_state = hass.states.get(entity_id)
|
ha_state = hass.states.get(entity_id)
|
||||||
assert ha_state.state == CoverState.OPEN
|
assert ha_state.state == CoverState.OPEN
|
||||||
@ -325,7 +325,7 @@ async def test_hmip_blind_module(
|
|||||||
)
|
)
|
||||||
assert len(hmip_device.mock_calls) == service_call_counter + 12
|
assert len(hmip_device.mock_calls) == service_call_counter + 12
|
||||||
|
|
||||||
assert hmip_device.mock_calls[-1][0] == "set_secondary_shading_level"
|
assert hmip_device.mock_calls[-1][0] == "set_secondary_shading_level_async"
|
||||||
assert hmip_device.mock_calls[-1][2] == {
|
assert hmip_device.mock_calls[-1][2] == {
|
||||||
"primaryShadingLevel": 1,
|
"primaryShadingLevel": 1,
|
||||||
"secondaryShadingLevel": 1,
|
"secondaryShadingLevel": 1,
|
||||||
@ -340,14 +340,14 @@ async def test_hmip_blind_module(
|
|||||||
"cover", "stop_cover", {"entity_id": entity_id}, blocking=True
|
"cover", "stop_cover", {"entity_id": entity_id}, blocking=True
|
||||||
)
|
)
|
||||||
assert len(hmip_device.mock_calls) == service_call_counter + 13
|
assert len(hmip_device.mock_calls) == service_call_counter + 13
|
||||||
assert hmip_device.mock_calls[-1][0] == "stop"
|
assert hmip_device.mock_calls[-1][0] == "stop_async"
|
||||||
assert hmip_device.mock_calls[-1][1] == ()
|
assert hmip_device.mock_calls[-1][1] == ()
|
||||||
|
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
"cover", "stop_cover_tilt", {"entity_id": entity_id}, blocking=True
|
"cover", "stop_cover_tilt", {"entity_id": entity_id}, blocking=True
|
||||||
)
|
)
|
||||||
assert len(hmip_device.mock_calls) == service_call_counter + 14
|
assert len(hmip_device.mock_calls) == service_call_counter + 14
|
||||||
assert hmip_device.mock_calls[-1][0] == "stop"
|
assert hmip_device.mock_calls[-1][0] == "stop_async"
|
||||||
assert hmip_device.mock_calls[-1][1] == ()
|
assert hmip_device.mock_calls[-1][1] == ()
|
||||||
|
|
||||||
await async_manipulate_test_data(hass, hmip_device, "secondaryShadingLevel", None)
|
await async_manipulate_test_data(hass, hmip_device, "secondaryShadingLevel", None)
|
||||||
@ -382,7 +382,7 @@ async def test_hmip_garage_door_tormatic(
|
|||||||
"cover", "open_cover", {"entity_id": entity_id}, blocking=True
|
"cover", "open_cover", {"entity_id": entity_id}, blocking=True
|
||||||
)
|
)
|
||||||
assert len(hmip_device.mock_calls) == service_call_counter + 1
|
assert len(hmip_device.mock_calls) == service_call_counter + 1
|
||||||
assert hmip_device.mock_calls[-1][0] == "send_door_command"
|
assert hmip_device.mock_calls[-1][0] == "send_door_command_async"
|
||||||
assert hmip_device.mock_calls[-1][1] == (DoorCommand.OPEN,)
|
assert hmip_device.mock_calls[-1][1] == (DoorCommand.OPEN,)
|
||||||
await async_manipulate_test_data(hass, hmip_device, "doorState", DoorState.OPEN)
|
await async_manipulate_test_data(hass, hmip_device, "doorState", DoorState.OPEN)
|
||||||
ha_state = hass.states.get(entity_id)
|
ha_state = hass.states.get(entity_id)
|
||||||
@ -393,7 +393,7 @@ async def test_hmip_garage_door_tormatic(
|
|||||||
"cover", "close_cover", {"entity_id": entity_id}, blocking=True
|
"cover", "close_cover", {"entity_id": entity_id}, blocking=True
|
||||||
)
|
)
|
||||||
assert len(hmip_device.mock_calls) == service_call_counter + 3
|
assert len(hmip_device.mock_calls) == service_call_counter + 3
|
||||||
assert hmip_device.mock_calls[-1][0] == "send_door_command"
|
assert hmip_device.mock_calls[-1][0] == "send_door_command_async"
|
||||||
assert hmip_device.mock_calls[-1][1] == (DoorCommand.CLOSE,)
|
assert hmip_device.mock_calls[-1][1] == (DoorCommand.CLOSE,)
|
||||||
await async_manipulate_test_data(hass, hmip_device, "doorState", DoorState.CLOSED)
|
await async_manipulate_test_data(hass, hmip_device, "doorState", DoorState.CLOSED)
|
||||||
ha_state = hass.states.get(entity_id)
|
ha_state = hass.states.get(entity_id)
|
||||||
@ -404,7 +404,7 @@ async def test_hmip_garage_door_tormatic(
|
|||||||
"cover", "stop_cover", {"entity_id": entity_id}, blocking=True
|
"cover", "stop_cover", {"entity_id": entity_id}, blocking=True
|
||||||
)
|
)
|
||||||
assert len(hmip_device.mock_calls) == service_call_counter + 5
|
assert len(hmip_device.mock_calls) == service_call_counter + 5
|
||||||
assert hmip_device.mock_calls[-1][0] == "send_door_command"
|
assert hmip_device.mock_calls[-1][0] == "send_door_command_async"
|
||||||
assert hmip_device.mock_calls[-1][1] == (DoorCommand.STOP,)
|
assert hmip_device.mock_calls[-1][1] == (DoorCommand.STOP,)
|
||||||
|
|
||||||
|
|
||||||
@ -431,7 +431,7 @@ async def test_hmip_garage_door_hoermann(
|
|||||||
"cover", "open_cover", {"entity_id": entity_id}, blocking=True
|
"cover", "open_cover", {"entity_id": entity_id}, blocking=True
|
||||||
)
|
)
|
||||||
assert len(hmip_device.mock_calls) == service_call_counter + 1
|
assert len(hmip_device.mock_calls) == service_call_counter + 1
|
||||||
assert hmip_device.mock_calls[-1][0] == "send_door_command"
|
assert hmip_device.mock_calls[-1][0] == "send_door_command_async"
|
||||||
assert hmip_device.mock_calls[-1][1] == (DoorCommand.OPEN,)
|
assert hmip_device.mock_calls[-1][1] == (DoorCommand.OPEN,)
|
||||||
await async_manipulate_test_data(hass, hmip_device, "doorState", DoorState.OPEN)
|
await async_manipulate_test_data(hass, hmip_device, "doorState", DoorState.OPEN)
|
||||||
ha_state = hass.states.get(entity_id)
|
ha_state = hass.states.get(entity_id)
|
||||||
@ -442,7 +442,7 @@ async def test_hmip_garage_door_hoermann(
|
|||||||
"cover", "close_cover", {"entity_id": entity_id}, blocking=True
|
"cover", "close_cover", {"entity_id": entity_id}, blocking=True
|
||||||
)
|
)
|
||||||
assert len(hmip_device.mock_calls) == service_call_counter + 3
|
assert len(hmip_device.mock_calls) == service_call_counter + 3
|
||||||
assert hmip_device.mock_calls[-1][0] == "send_door_command"
|
assert hmip_device.mock_calls[-1][0] == "send_door_command_async"
|
||||||
assert hmip_device.mock_calls[-1][1] == (DoorCommand.CLOSE,)
|
assert hmip_device.mock_calls[-1][1] == (DoorCommand.CLOSE,)
|
||||||
await async_manipulate_test_data(hass, hmip_device, "doorState", DoorState.CLOSED)
|
await async_manipulate_test_data(hass, hmip_device, "doorState", DoorState.CLOSED)
|
||||||
ha_state = hass.states.get(entity_id)
|
ha_state = hass.states.get(entity_id)
|
||||||
@ -453,7 +453,7 @@ async def test_hmip_garage_door_hoermann(
|
|||||||
"cover", "stop_cover", {"entity_id": entity_id}, blocking=True
|
"cover", "stop_cover", {"entity_id": entity_id}, blocking=True
|
||||||
)
|
)
|
||||||
assert len(hmip_device.mock_calls) == service_call_counter + 5
|
assert len(hmip_device.mock_calls) == service_call_counter + 5
|
||||||
assert hmip_device.mock_calls[-1][0] == "send_door_command"
|
assert hmip_device.mock_calls[-1][0] == "send_door_command_async"
|
||||||
assert hmip_device.mock_calls[-1][1] == (DoorCommand.STOP,)
|
assert hmip_device.mock_calls[-1][1] == (DoorCommand.STOP,)
|
||||||
|
|
||||||
|
|
||||||
@ -478,7 +478,7 @@ async def test_hmip_cover_shutter_group(
|
|||||||
"cover", "open_cover", {"entity_id": entity_id}, blocking=True
|
"cover", "open_cover", {"entity_id": entity_id}, blocking=True
|
||||||
)
|
)
|
||||||
assert len(hmip_device.mock_calls) == service_call_counter + 1
|
assert len(hmip_device.mock_calls) == service_call_counter + 1
|
||||||
assert hmip_device.mock_calls[-1][0] == "set_shutter_level"
|
assert hmip_device.mock_calls[-1][0] == "set_shutter_level_async"
|
||||||
assert hmip_device.mock_calls[-1][1] == (0,)
|
assert hmip_device.mock_calls[-1][1] == (0,)
|
||||||
await async_manipulate_test_data(hass, hmip_device, "shutterLevel", 0)
|
await async_manipulate_test_data(hass, hmip_device, "shutterLevel", 0)
|
||||||
ha_state = hass.states.get(entity_id)
|
ha_state = hass.states.get(entity_id)
|
||||||
@ -492,7 +492,7 @@ async def test_hmip_cover_shutter_group(
|
|||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
assert len(hmip_device.mock_calls) == service_call_counter + 3
|
assert len(hmip_device.mock_calls) == service_call_counter + 3
|
||||||
assert hmip_device.mock_calls[-1][0] == "set_shutter_level"
|
assert hmip_device.mock_calls[-1][0] == "set_shutter_level_async"
|
||||||
assert hmip_device.mock_calls[-1][1] == (0.5,)
|
assert hmip_device.mock_calls[-1][1] == (0.5,)
|
||||||
await async_manipulate_test_data(hass, hmip_device, "shutterLevel", 0.5)
|
await async_manipulate_test_data(hass, hmip_device, "shutterLevel", 0.5)
|
||||||
ha_state = hass.states.get(entity_id)
|
ha_state = hass.states.get(entity_id)
|
||||||
@ -503,7 +503,7 @@ async def test_hmip_cover_shutter_group(
|
|||||||
"cover", "close_cover", {"entity_id": entity_id}, blocking=True
|
"cover", "close_cover", {"entity_id": entity_id}, blocking=True
|
||||||
)
|
)
|
||||||
assert len(hmip_device.mock_calls) == service_call_counter + 5
|
assert len(hmip_device.mock_calls) == service_call_counter + 5
|
||||||
assert hmip_device.mock_calls[-1][0] == "set_shutter_level"
|
assert hmip_device.mock_calls[-1][0] == "set_shutter_level_async"
|
||||||
assert hmip_device.mock_calls[-1][1] == (1,)
|
assert hmip_device.mock_calls[-1][1] == (1,)
|
||||||
await async_manipulate_test_data(hass, hmip_device, "shutterLevel", 1)
|
await async_manipulate_test_data(hass, hmip_device, "shutterLevel", 1)
|
||||||
ha_state = hass.states.get(entity_id)
|
ha_state = hass.states.get(entity_id)
|
||||||
@ -514,7 +514,7 @@ async def test_hmip_cover_shutter_group(
|
|||||||
"cover", "stop_cover", {"entity_id": entity_id}, blocking=True
|
"cover", "stop_cover", {"entity_id": entity_id}, blocking=True
|
||||||
)
|
)
|
||||||
assert len(hmip_device.mock_calls) == service_call_counter + 7
|
assert len(hmip_device.mock_calls) == service_call_counter + 7
|
||||||
assert hmip_device.mock_calls[-1][0] == "set_shutter_stop"
|
assert hmip_device.mock_calls[-1][0] == "set_shutter_stop_async"
|
||||||
assert hmip_device.mock_calls[-1][1] == ()
|
assert hmip_device.mock_calls[-1][1] == ()
|
||||||
|
|
||||||
await async_manipulate_test_data(hass, hmip_device, "shutterLevel", None)
|
await async_manipulate_test_data(hass, hmip_device, "shutterLevel", None)
|
||||||
@ -553,7 +553,7 @@ async def test_hmip_cover_slats_group(
|
|||||||
)
|
)
|
||||||
|
|
||||||
assert len(hmip_device.mock_calls) == service_call_counter + 2
|
assert len(hmip_device.mock_calls) == service_call_counter + 2
|
||||||
assert hmip_device.mock_calls[-1][0] == "set_slats_level"
|
assert hmip_device.mock_calls[-1][0] == "set_slats_level_async"
|
||||||
assert hmip_device.mock_calls[-1][1] == (0,)
|
assert hmip_device.mock_calls[-1][1] == (0,)
|
||||||
await async_manipulate_test_data(hass, hmip_device, "shutterLevel", 0.5)
|
await async_manipulate_test_data(hass, hmip_device, "shutterLevel", 0.5)
|
||||||
await async_manipulate_test_data(hass, hmip_device, "slatsLevel", 0)
|
await async_manipulate_test_data(hass, hmip_device, "slatsLevel", 0)
|
||||||
@ -569,7 +569,7 @@ async def test_hmip_cover_slats_group(
|
|||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
assert len(hmip_device.mock_calls) == service_call_counter + 5
|
assert len(hmip_device.mock_calls) == service_call_counter + 5
|
||||||
assert hmip_device.mock_calls[-1][0] == "set_slats_level"
|
assert hmip_device.mock_calls[-1][0] == "set_slats_level_async"
|
||||||
assert hmip_device.mock_calls[-1][1] == (0.5,)
|
assert hmip_device.mock_calls[-1][1] == (0.5,)
|
||||||
await async_manipulate_test_data(hass, hmip_device, "slatsLevel", 0.5)
|
await async_manipulate_test_data(hass, hmip_device, "slatsLevel", 0.5)
|
||||||
ha_state = hass.states.get(entity_id)
|
ha_state = hass.states.get(entity_id)
|
||||||
@ -581,7 +581,7 @@ async def test_hmip_cover_slats_group(
|
|||||||
"cover", "close_cover_tilt", {"entity_id": entity_id}, blocking=True
|
"cover", "close_cover_tilt", {"entity_id": entity_id}, blocking=True
|
||||||
)
|
)
|
||||||
assert len(hmip_device.mock_calls) == service_call_counter + 7
|
assert len(hmip_device.mock_calls) == service_call_counter + 7
|
||||||
assert hmip_device.mock_calls[-1][0] == "set_slats_level"
|
assert hmip_device.mock_calls[-1][0] == "set_slats_level_async"
|
||||||
assert hmip_device.mock_calls[-1][1] == (1,)
|
assert hmip_device.mock_calls[-1][1] == (1,)
|
||||||
await async_manipulate_test_data(hass, hmip_device, "slatsLevel", 1)
|
await async_manipulate_test_data(hass, hmip_device, "slatsLevel", 1)
|
||||||
ha_state = hass.states.get(entity_id)
|
ha_state = hass.states.get(entity_id)
|
||||||
@ -593,5 +593,5 @@ async def test_hmip_cover_slats_group(
|
|||||||
"cover", "stop_cover_tilt", {"entity_id": entity_id}, blocking=True
|
"cover", "stop_cover_tilt", {"entity_id": entity_id}, blocking=True
|
||||||
)
|
)
|
||||||
assert len(hmip_device.mock_calls) == service_call_counter + 9
|
assert len(hmip_device.mock_calls) == service_call_counter + 9
|
||||||
assert hmip_device.mock_calls[-1][0] == "set_shutter_stop"
|
assert hmip_device.mock_calls[-1][0] == "set_shutter_stop_async"
|
||||||
assert hmip_device.mock_calls[-1][1] == ()
|
assert hmip_device.mock_calls[-1][1] == ()
|
||||||
|
@ -257,14 +257,14 @@ async def test_hmip_reset_energy_counter_services(
|
|||||||
{"entity_id": "switch.pc"},
|
{"entity_id": "switch.pc"},
|
||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
assert hmip_device.mock_calls[-1][0] == "reset_energy_counter"
|
assert hmip_device.mock_calls[-1][0] == "reset_energy_counter_async"
|
||||||
assert len(hmip_device._connection.mock_calls) == 2
|
assert len(hmip_device._connection.mock_calls) == 1
|
||||||
|
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
"homematicip_cloud", "reset_energy_counter", {"entity_id": "all"}, blocking=True
|
"homematicip_cloud", "reset_energy_counter", {"entity_id": "all"}, blocking=True
|
||||||
)
|
)
|
||||||
assert hmip_device.mock_calls[-1][0] == "reset_energy_counter"
|
assert hmip_device.mock_calls[-1][0] == "reset_energy_counter_async"
|
||||||
assert len(hmip_device._connection.mock_calls) == 4
|
assert len(hmip_device._connection.mock_calls) == 2
|
||||||
|
|
||||||
|
|
||||||
async def test_hmip_multi_area_device(
|
async def test_hmip_multi_area_device(
|
||||||
|
@ -2,8 +2,9 @@
|
|||||||
|
|
||||||
from unittest.mock import Mock, patch
|
from unittest.mock import Mock, patch
|
||||||
|
|
||||||
from homematicip.aio.auth import AsyncAuth
|
from homematicip.auth import Auth
|
||||||
from homematicip.base.base_connection import HmipConnectionError
|
from homematicip.base.base_connection import HmipConnectionError
|
||||||
|
from homematicip.connection.connection_context import ConnectionContext
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant.components.homematicip_cloud import DOMAIN as HMIPC_DOMAIN
|
from homeassistant.components.homematicip_cloud import DOMAIN as HMIPC_DOMAIN
|
||||||
@ -48,13 +49,13 @@ async def test_auth_auth_check_and_register(hass: HomeAssistant) -> None:
|
|||||||
config = {HMIPC_HAPID: "ABC123", HMIPC_PIN: "123", HMIPC_NAME: "hmip"}
|
config = {HMIPC_HAPID: "ABC123", HMIPC_PIN: "123", HMIPC_NAME: "hmip"}
|
||||||
|
|
||||||
hmip_auth = HomematicipAuth(hass, config)
|
hmip_auth = HomematicipAuth(hass, config)
|
||||||
hmip_auth.auth = Mock(spec=AsyncAuth)
|
hmip_auth.auth = Mock(spec=Auth)
|
||||||
with (
|
with (
|
||||||
patch.object(hmip_auth.auth, "isRequestAcknowledged", return_value=True),
|
patch.object(hmip_auth.auth, "is_request_acknowledged", return_value=True),
|
||||||
patch.object(hmip_auth.auth, "requestAuthToken", return_value="ABC"),
|
patch.object(hmip_auth.auth, "request_auth_token", return_value="ABC"),
|
||||||
patch.object(
|
patch.object(
|
||||||
hmip_auth.auth,
|
hmip_auth.auth,
|
||||||
"confirmAuthToken",
|
"confirm_auth_token",
|
||||||
),
|
),
|
||||||
):
|
):
|
||||||
assert await hmip_auth.async_checkbutton()
|
assert await hmip_auth.async_checkbutton()
|
||||||
@ -65,13 +66,13 @@ async def test_auth_auth_check_and_register_with_exception(hass: HomeAssistant)
|
|||||||
"""Test auth client registration."""
|
"""Test auth client registration."""
|
||||||
config = {HMIPC_HAPID: "ABC123", HMIPC_PIN: "123", HMIPC_NAME: "hmip"}
|
config = {HMIPC_HAPID: "ABC123", HMIPC_PIN: "123", HMIPC_NAME: "hmip"}
|
||||||
hmip_auth = HomematicipAuth(hass, config)
|
hmip_auth = HomematicipAuth(hass, config)
|
||||||
hmip_auth.auth = Mock(spec=AsyncAuth)
|
hmip_auth.auth = Mock(spec=Auth)
|
||||||
with (
|
with (
|
||||||
patch.object(
|
patch.object(
|
||||||
hmip_auth.auth, "isRequestAcknowledged", side_effect=HmipConnectionError
|
hmip_auth.auth, "is_request_acknowledged", side_effect=HmipConnectionError
|
||||||
),
|
),
|
||||||
patch.object(
|
patch.object(
|
||||||
hmip_auth.auth, "requestAuthToken", side_effect=HmipConnectionError
|
hmip_auth.auth, "request_auth_token", side_effect=HmipConnectionError
|
||||||
),
|
),
|
||||||
):
|
):
|
||||||
assert not await hmip_auth.async_checkbutton()
|
assert not await hmip_auth.async_checkbutton()
|
||||||
@ -128,6 +129,10 @@ async def test_hap_reset_unloads_entry_if_setup(
|
|||||||
assert hass.data[HMIPC_DOMAIN] == {}
|
assert hass.data[HMIPC_DOMAIN] == {}
|
||||||
|
|
||||||
|
|
||||||
|
@patch(
|
||||||
|
"homeassistant.components.homematicip_cloud.hap.ConnectionContextBuilder.build_context_async",
|
||||||
|
return_value=ConnectionContext(),
|
||||||
|
)
|
||||||
async def test_hap_create(
|
async def test_hap_create(
|
||||||
hass: HomeAssistant, hmip_config_entry: MockConfigEntry, simple_mock_home
|
hass: HomeAssistant, hmip_config_entry: MockConfigEntry, simple_mock_home
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -140,6 +145,10 @@ async def test_hap_create(
|
|||||||
assert await hap.async_setup()
|
assert await hap.async_setup()
|
||||||
|
|
||||||
|
|
||||||
|
@patch(
|
||||||
|
"homeassistant.components.homematicip_cloud.hap.ConnectionContextBuilder.build_context_async",
|
||||||
|
return_value=ConnectionContext(),
|
||||||
|
)
|
||||||
async def test_hap_create_exception(
|
async def test_hap_create_exception(
|
||||||
hass: HomeAssistant, hmip_config_entry: MockConfigEntry, mock_connection_init
|
hass: HomeAssistant, hmip_config_entry: MockConfigEntry, mock_connection_init
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -150,14 +159,14 @@ async def test_hap_create_exception(
|
|||||||
assert hap
|
assert hap
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.homematicip_cloud.hap.AsyncHome.get_current_state",
|
"homeassistant.components.homematicip_cloud.hap.AsyncHome.get_current_state_async",
|
||||||
side_effect=Exception,
|
side_effect=Exception,
|
||||||
):
|
):
|
||||||
assert not await hap.async_setup()
|
assert not await hap.async_setup()
|
||||||
|
|
||||||
with (
|
with (
|
||||||
patch(
|
patch(
|
||||||
"homeassistant.components.homematicip_cloud.hap.AsyncHome.get_current_state",
|
"homeassistant.components.homematicip_cloud.hap.AsyncHome.get_current_state_async",
|
||||||
side_effect=HmipConnectionError,
|
side_effect=HmipConnectionError,
|
||||||
),
|
),
|
||||||
pytest.raises(ConfigEntryNotReady),
|
pytest.raises(ConfigEntryNotReady),
|
||||||
@ -171,9 +180,15 @@ async def test_auth_create(hass: HomeAssistant, simple_mock_auth) -> None:
|
|||||||
hmip_auth = HomematicipAuth(hass, config)
|
hmip_auth = HomematicipAuth(hass, config)
|
||||||
assert hmip_auth
|
assert hmip_auth
|
||||||
|
|
||||||
with patch(
|
with (
|
||||||
"homeassistant.components.homematicip_cloud.hap.AsyncAuth",
|
patch(
|
||||||
return_value=simple_mock_auth,
|
"homeassistant.components.homematicip_cloud.hap.Auth",
|
||||||
|
return_value=simple_mock_auth,
|
||||||
|
),
|
||||||
|
patch(
|
||||||
|
"homeassistant.components.homematicip_cloud.hap.ConnectionContextBuilder.build_context_async",
|
||||||
|
return_value=ConnectionContext(),
|
||||||
|
),
|
||||||
):
|
):
|
||||||
assert await hmip_auth.async_setup()
|
assert await hmip_auth.async_setup()
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
@ -184,16 +199,28 @@ async def test_auth_create_exception(hass: HomeAssistant, simple_mock_auth) -> N
|
|||||||
"""Mock AsyncAuth to execute get_auth."""
|
"""Mock AsyncAuth to execute get_auth."""
|
||||||
config = {HMIPC_HAPID: HAPID, HMIPC_PIN: HAPPIN, HMIPC_NAME: "hmip"}
|
config = {HMIPC_HAPID: HAPID, HMIPC_PIN: HAPPIN, HMIPC_NAME: "hmip"}
|
||||||
hmip_auth = HomematicipAuth(hass, config)
|
hmip_auth = HomematicipAuth(hass, config)
|
||||||
simple_mock_auth.connectionRequest.side_effect = HmipConnectionError
|
simple_mock_auth.connection_request.side_effect = HmipConnectionError
|
||||||
assert hmip_auth
|
assert hmip_auth
|
||||||
with patch(
|
with (
|
||||||
"homeassistant.components.homematicip_cloud.hap.AsyncAuth",
|
patch(
|
||||||
return_value=simple_mock_auth,
|
"homeassistant.components.homematicip_cloud.hap.Auth",
|
||||||
|
return_value=simple_mock_auth,
|
||||||
|
),
|
||||||
|
patch(
|
||||||
|
"homeassistant.components.homematicip_cloud.hap.ConnectionContextBuilder.build_context_async",
|
||||||
|
return_value=ConnectionContext(),
|
||||||
|
),
|
||||||
):
|
):
|
||||||
assert not await hmip_auth.async_setup()
|
assert not await hmip_auth.async_setup()
|
||||||
|
|
||||||
with patch(
|
with (
|
||||||
"homeassistant.components.homematicip_cloud.hap.AsyncAuth",
|
patch(
|
||||||
return_value=simple_mock_auth,
|
"homeassistant.components.homematicip_cloud.hap.Auth",
|
||||||
|
return_value=simple_mock_auth,
|
||||||
|
),
|
||||||
|
patch(
|
||||||
|
"homeassistant.components.homematicip_cloud.hap.ConnectionContextBuilder.build_context_async",
|
||||||
|
return_value=ConnectionContext(),
|
||||||
|
),
|
||||||
):
|
):
|
||||||
assert not await hmip_auth.get_auth(hass, HAPID, HAPPIN)
|
assert not await hmip_auth.get_auth(hass, HAPID, HAPPIN)
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
from unittest.mock import AsyncMock, Mock, patch
|
from unittest.mock import AsyncMock, Mock, patch
|
||||||
|
|
||||||
from homematicip.base.base_connection import HmipConnectionError
|
from homematicip.base.base_connection import HmipConnectionError
|
||||||
|
from homematicip.connection.connection_context import ConnectionContext
|
||||||
|
|
||||||
from homeassistant.components.homematicip_cloud.const import (
|
from homeassistant.components.homematicip_cloud.const import (
|
||||||
CONF_ACCESSPOINT,
|
CONF_ACCESSPOINT,
|
||||||
@ -105,9 +106,15 @@ async def test_load_entry_fails_due_to_connection_error(
|
|||||||
"""Test load entry fails due to connection error."""
|
"""Test load entry fails due to connection error."""
|
||||||
hmip_config_entry.add_to_hass(hass)
|
hmip_config_entry.add_to_hass(hass)
|
||||||
|
|
||||||
with patch(
|
with (
|
||||||
"homeassistant.components.homematicip_cloud.hap.AsyncHome.get_current_state",
|
patch(
|
||||||
side_effect=HmipConnectionError,
|
"homeassistant.components.homematicip_cloud.hap.AsyncHome.get_current_state_async",
|
||||||
|
side_effect=HmipConnectionError,
|
||||||
|
),
|
||||||
|
patch(
|
||||||
|
"homeassistant.components.homematicip_cloud.hap.ConnectionContextBuilder.build_context_async",
|
||||||
|
return_value=ConnectionContext(),
|
||||||
|
),
|
||||||
):
|
):
|
||||||
assert await async_setup_component(hass, HMIPC_DOMAIN, {})
|
assert await async_setup_component(hass, HMIPC_DOMAIN, {})
|
||||||
|
|
||||||
@ -123,12 +130,9 @@ async def test_load_entry_fails_due_to_generic_exception(
|
|||||||
|
|
||||||
with (
|
with (
|
||||||
patch(
|
patch(
|
||||||
"homeassistant.components.homematicip_cloud.hap.AsyncHome.get_current_state",
|
"homeassistant.components.homematicip_cloud.hap.AsyncHome.get_current_state_async",
|
||||||
side_effect=Exception,
|
side_effect=Exception,
|
||||||
),
|
),
|
||||||
patch(
|
|
||||||
"homematicip.aio.connection.AsyncConnection.init",
|
|
||||||
),
|
|
||||||
):
|
):
|
||||||
assert await async_setup_component(hass, HMIPC_DOMAIN, {})
|
assert await async_setup_component(hass, HMIPC_DOMAIN, {})
|
||||||
|
|
||||||
@ -175,7 +179,7 @@ async def test_hmip_dump_hap_config_services(
|
|||||||
"homematicip_cloud", "dump_hap_config", {"anonymize": True}, blocking=True
|
"homematicip_cloud", "dump_hap_config", {"anonymize": True}, blocking=True
|
||||||
)
|
)
|
||||||
home = mock_hap_with_service.home
|
home = mock_hap_with_service.home
|
||||||
assert home.mock_calls[-1][0] == "download_configuration"
|
assert home.mock_calls[-1][0] == "download_configuration_async"
|
||||||
assert home.mock_calls
|
assert home.mock_calls
|
||||||
assert write_mock.mock_calls
|
assert write_mock.mock_calls
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ async def test_hmip_light(
|
|||||||
"light", "turn_off", {"entity_id": entity_id}, blocking=True
|
"light", "turn_off", {"entity_id": entity_id}, blocking=True
|
||||||
)
|
)
|
||||||
assert len(hmip_device.mock_calls) == service_call_counter + 1
|
assert len(hmip_device.mock_calls) == service_call_counter + 1
|
||||||
assert hmip_device.mock_calls[-1][0] == "turn_off"
|
assert hmip_device.mock_calls[-1][0] == "turn_off_async"
|
||||||
assert hmip_device.mock_calls[-1][1] == ()
|
assert hmip_device.mock_calls[-1][1] == ()
|
||||||
|
|
||||||
await async_manipulate_test_data(hass, hmip_device, "on", False)
|
await async_manipulate_test_data(hass, hmip_device, "on", False)
|
||||||
@ -68,7 +68,7 @@ async def test_hmip_light(
|
|||||||
"light", "turn_on", {"entity_id": entity_id}, blocking=True
|
"light", "turn_on", {"entity_id": entity_id}, blocking=True
|
||||||
)
|
)
|
||||||
assert len(hmip_device.mock_calls) == service_call_counter + 3
|
assert len(hmip_device.mock_calls) == service_call_counter + 3
|
||||||
assert hmip_device.mock_calls[-1][0] == "turn_on"
|
assert hmip_device.mock_calls[-1][0] == "turn_on_async"
|
||||||
assert hmip_device.mock_calls[-1][1] == ()
|
assert hmip_device.mock_calls[-1][1] == ()
|
||||||
|
|
||||||
await async_manipulate_test_data(hass, hmip_device, "on", True)
|
await async_manipulate_test_data(hass, hmip_device, "on", True)
|
||||||
@ -104,7 +104,7 @@ async def test_hmip_notification_light(
|
|||||||
{"entity_id": entity_id, "brightness_pct": "100", "transition": 100},
|
{"entity_id": entity_id, "brightness_pct": "100", "transition": 100},
|
||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
assert hmip_device.mock_calls[-1][0] == "set_rgb_dim_level_with_time"
|
assert hmip_device.mock_calls[-1][0] == "set_rgb_dim_level_with_time_async"
|
||||||
assert hmip_device.mock_calls[-1][2] == {
|
assert hmip_device.mock_calls[-1][2] == {
|
||||||
"channelIndex": 2,
|
"channelIndex": 2,
|
||||||
"rgb": "RED",
|
"rgb": "RED",
|
||||||
@ -130,7 +130,7 @@ async def test_hmip_notification_light(
|
|||||||
{"entity_id": entity_id, "hs_color": hs_color},
|
{"entity_id": entity_id, "hs_color": hs_color},
|
||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
assert hmip_device.mock_calls[-1][0] == "set_rgb_dim_level_with_time"
|
assert hmip_device.mock_calls[-1][0] == "set_rgb_dim_level_with_time_async"
|
||||||
assert hmip_device.mock_calls[-1][2] == {
|
assert hmip_device.mock_calls[-1][2] == {
|
||||||
"channelIndex": 2,
|
"channelIndex": 2,
|
||||||
"dimLevel": 0.0392156862745098,
|
"dimLevel": 0.0392156862745098,
|
||||||
@ -157,7 +157,7 @@ async def test_hmip_notification_light(
|
|||||||
"light", "turn_off", {"entity_id": entity_id, "transition": 100}, blocking=True
|
"light", "turn_off", {"entity_id": entity_id, "transition": 100}, blocking=True
|
||||||
)
|
)
|
||||||
assert len(hmip_device.mock_calls) == service_call_counter + 11
|
assert len(hmip_device.mock_calls) == service_call_counter + 11
|
||||||
assert hmip_device.mock_calls[-1][0] == "set_rgb_dim_level_with_time"
|
assert hmip_device.mock_calls[-1][0] == "set_rgb_dim_level_with_time_async"
|
||||||
assert hmip_device.mock_calls[-1][2] == {
|
assert hmip_device.mock_calls[-1][2] == {
|
||||||
"channelIndex": 2,
|
"channelIndex": 2,
|
||||||
"dimLevel": 0.0,
|
"dimLevel": 0.0,
|
||||||
@ -294,7 +294,7 @@ async def test_hmip_dimmer(
|
|||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
"light", "turn_on", {"entity_id": entity_id}, blocking=True
|
"light", "turn_on", {"entity_id": entity_id}, blocking=True
|
||||||
)
|
)
|
||||||
assert hmip_device.mock_calls[-1][0] == "set_dim_level"
|
assert hmip_device.mock_calls[-1][0] == "set_dim_level_async"
|
||||||
assert hmip_device.mock_calls[-1][1] == (1, 1)
|
assert hmip_device.mock_calls[-1][1] == (1, 1)
|
||||||
|
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
@ -304,7 +304,7 @@ async def test_hmip_dimmer(
|
|||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
assert len(hmip_device.mock_calls) == service_call_counter + 2
|
assert len(hmip_device.mock_calls) == service_call_counter + 2
|
||||||
assert hmip_device.mock_calls[-1][0] == "set_dim_level"
|
assert hmip_device.mock_calls[-1][0] == "set_dim_level_async"
|
||||||
assert hmip_device.mock_calls[-1][1] == (1.0, 1)
|
assert hmip_device.mock_calls[-1][1] == (1.0, 1)
|
||||||
await async_manipulate_test_data(hass, hmip_device, "dimLevel", 1)
|
await async_manipulate_test_data(hass, hmip_device, "dimLevel", 1)
|
||||||
ha_state = hass.states.get(entity_id)
|
ha_state = hass.states.get(entity_id)
|
||||||
@ -318,7 +318,7 @@ async def test_hmip_dimmer(
|
|||||||
"light", "turn_off", {"entity_id": entity_id}, blocking=True
|
"light", "turn_off", {"entity_id": entity_id}, blocking=True
|
||||||
)
|
)
|
||||||
assert len(hmip_device.mock_calls) == service_call_counter + 4
|
assert len(hmip_device.mock_calls) == service_call_counter + 4
|
||||||
assert hmip_device.mock_calls[-1][0] == "set_dim_level"
|
assert hmip_device.mock_calls[-1][0] == "set_dim_level_async"
|
||||||
assert hmip_device.mock_calls[-1][1] == (0, 1)
|
assert hmip_device.mock_calls[-1][1] == (0, 1)
|
||||||
await async_manipulate_test_data(hass, hmip_device, "dimLevel", 0)
|
await async_manipulate_test_data(hass, hmip_device, "dimLevel", 0)
|
||||||
ha_state = hass.states.get(entity_id)
|
ha_state = hass.states.get(entity_id)
|
||||||
@ -355,7 +355,7 @@ async def test_hmip_light_measuring(
|
|||||||
"light", "turn_on", {"entity_id": entity_id}, blocking=True
|
"light", "turn_on", {"entity_id": entity_id}, blocking=True
|
||||||
)
|
)
|
||||||
assert len(hmip_device.mock_calls) == service_call_counter + 1
|
assert len(hmip_device.mock_calls) == service_call_counter + 1
|
||||||
assert hmip_device.mock_calls[-1][0] == "turn_on"
|
assert hmip_device.mock_calls[-1][0] == "turn_on_async"
|
||||||
assert hmip_device.mock_calls[-1][1] == ()
|
assert hmip_device.mock_calls[-1][1] == ()
|
||||||
await async_manipulate_test_data(hass, hmip_device, "on", True)
|
await async_manipulate_test_data(hass, hmip_device, "on", True)
|
||||||
await async_manipulate_test_data(hass, hmip_device, "currentPowerConsumption", 50)
|
await async_manipulate_test_data(hass, hmip_device, "currentPowerConsumption", 50)
|
||||||
@ -369,7 +369,7 @@ async def test_hmip_light_measuring(
|
|||||||
"light", "turn_off", {"entity_id": entity_id}, blocking=True
|
"light", "turn_off", {"entity_id": entity_id}, blocking=True
|
||||||
)
|
)
|
||||||
assert len(hmip_device.mock_calls) == service_call_counter + 4
|
assert len(hmip_device.mock_calls) == service_call_counter + 4
|
||||||
assert hmip_device.mock_calls[-1][0] == "turn_off"
|
assert hmip_device.mock_calls[-1][0] == "turn_off_async"
|
||||||
assert hmip_device.mock_calls[-1][1] == ()
|
assert hmip_device.mock_calls[-1][1] == ()
|
||||||
await async_manipulate_test_data(hass, hmip_device, "on", False)
|
await async_manipulate_test_data(hass, hmip_device, "on", False)
|
||||||
ha_state = hass.states.get(entity_id)
|
ha_state = hass.states.get(entity_id)
|
||||||
@ -400,7 +400,7 @@ async def test_hmip_wired_multi_dimmer(
|
|||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
"light", "turn_on", {"entity_id": entity_id}, blocking=True
|
"light", "turn_on", {"entity_id": entity_id}, blocking=True
|
||||||
)
|
)
|
||||||
assert hmip_device.mock_calls[-1][0] == "set_dim_level"
|
assert hmip_device.mock_calls[-1][0] == "set_dim_level_async"
|
||||||
assert hmip_device.mock_calls[-1][1] == (1, 1)
|
assert hmip_device.mock_calls[-1][1] == (1, 1)
|
||||||
|
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
@ -410,7 +410,7 @@ async def test_hmip_wired_multi_dimmer(
|
|||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
assert len(hmip_device.mock_calls) == service_call_counter + 2
|
assert len(hmip_device.mock_calls) == service_call_counter + 2
|
||||||
assert hmip_device.mock_calls[-1][0] == "set_dim_level"
|
assert hmip_device.mock_calls[-1][0] == "set_dim_level_async"
|
||||||
assert hmip_device.mock_calls[-1][1] == (0.39215686274509803, 1)
|
assert hmip_device.mock_calls[-1][1] == (0.39215686274509803, 1)
|
||||||
await async_manipulate_test_data(hass, hmip_device, "dimLevel", 1, channel=1)
|
await async_manipulate_test_data(hass, hmip_device, "dimLevel", 1, channel=1)
|
||||||
ha_state = hass.states.get(entity_id)
|
ha_state = hass.states.get(entity_id)
|
||||||
@ -424,7 +424,7 @@ async def test_hmip_wired_multi_dimmer(
|
|||||||
"light", "turn_off", {"entity_id": entity_id}, blocking=True
|
"light", "turn_off", {"entity_id": entity_id}, blocking=True
|
||||||
)
|
)
|
||||||
assert len(hmip_device.mock_calls) == service_call_counter + 4
|
assert len(hmip_device.mock_calls) == service_call_counter + 4
|
||||||
assert hmip_device.mock_calls[-1][0] == "set_dim_level"
|
assert hmip_device.mock_calls[-1][0] == "set_dim_level_async"
|
||||||
assert hmip_device.mock_calls[-1][1] == (0, 1)
|
assert hmip_device.mock_calls[-1][1] == (0, 1)
|
||||||
await async_manipulate_test_data(hass, hmip_device, "dimLevel", 0, channel=1)
|
await async_manipulate_test_data(hass, hmip_device, "dimLevel", 0, channel=1)
|
||||||
ha_state = hass.states.get(entity_id)
|
ha_state = hass.states.get(entity_id)
|
||||||
@ -459,7 +459,7 @@ async def test_hmip_din_rail_dimmer_3_channel1(
|
|||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
"light", "turn_on", {"entity_id": entity_id}, blocking=True
|
"light", "turn_on", {"entity_id": entity_id}, blocking=True
|
||||||
)
|
)
|
||||||
assert hmip_device.mock_calls[-1][0] == "set_dim_level"
|
assert hmip_device.mock_calls[-1][0] == "set_dim_level_async"
|
||||||
assert hmip_device.mock_calls[-1][1] == (1, 1)
|
assert hmip_device.mock_calls[-1][1] == (1, 1)
|
||||||
|
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
@ -469,7 +469,7 @@ async def test_hmip_din_rail_dimmer_3_channel1(
|
|||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
assert len(hmip_device.mock_calls) == service_call_counter + 2
|
assert len(hmip_device.mock_calls) == service_call_counter + 2
|
||||||
assert hmip_device.mock_calls[-1][0] == "set_dim_level"
|
assert hmip_device.mock_calls[-1][0] == "set_dim_level_async"
|
||||||
assert hmip_device.mock_calls[-1][1] == (0.39215686274509803, 1)
|
assert hmip_device.mock_calls[-1][1] == (0.39215686274509803, 1)
|
||||||
await async_manipulate_test_data(hass, hmip_device, "dimLevel", 1, channel=1)
|
await async_manipulate_test_data(hass, hmip_device, "dimLevel", 1, channel=1)
|
||||||
ha_state = hass.states.get(entity_id)
|
ha_state = hass.states.get(entity_id)
|
||||||
@ -483,7 +483,7 @@ async def test_hmip_din_rail_dimmer_3_channel1(
|
|||||||
"light", "turn_off", {"entity_id": entity_id}, blocking=True
|
"light", "turn_off", {"entity_id": entity_id}, blocking=True
|
||||||
)
|
)
|
||||||
assert len(hmip_device.mock_calls) == service_call_counter + 4
|
assert len(hmip_device.mock_calls) == service_call_counter + 4
|
||||||
assert hmip_device.mock_calls[-1][0] == "set_dim_level"
|
assert hmip_device.mock_calls[-1][0] == "set_dim_level_async"
|
||||||
assert hmip_device.mock_calls[-1][1] == (0, 1)
|
assert hmip_device.mock_calls[-1][1] == (0, 1)
|
||||||
await async_manipulate_test_data(hass, hmip_device, "dimLevel", 0, channel=1)
|
await async_manipulate_test_data(hass, hmip_device, "dimLevel", 0, channel=1)
|
||||||
ha_state = hass.states.get(entity_id)
|
ha_state = hass.states.get(entity_id)
|
||||||
@ -518,7 +518,7 @@ async def test_hmip_din_rail_dimmer_3_channel2(
|
|||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
"light", "turn_on", {"entity_id": entity_id}, blocking=True
|
"light", "turn_on", {"entity_id": entity_id}, blocking=True
|
||||||
)
|
)
|
||||||
assert hmip_device.mock_calls[-1][0] == "set_dim_level"
|
assert hmip_device.mock_calls[-1][0] == "set_dim_level_async"
|
||||||
assert hmip_device.mock_calls[-1][1] == (1, 2)
|
assert hmip_device.mock_calls[-1][1] == (1, 2)
|
||||||
|
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
@ -528,7 +528,7 @@ async def test_hmip_din_rail_dimmer_3_channel2(
|
|||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
assert len(hmip_device.mock_calls) == service_call_counter + 2
|
assert len(hmip_device.mock_calls) == service_call_counter + 2
|
||||||
assert hmip_device.mock_calls[-1][0] == "set_dim_level"
|
assert hmip_device.mock_calls[-1][0] == "set_dim_level_async"
|
||||||
assert hmip_device.mock_calls[-1][1] == (0.39215686274509803, 2)
|
assert hmip_device.mock_calls[-1][1] == (0.39215686274509803, 2)
|
||||||
await async_manipulate_test_data(hass, hmip_device, "dimLevel", 1, channel=2)
|
await async_manipulate_test_data(hass, hmip_device, "dimLevel", 1, channel=2)
|
||||||
ha_state = hass.states.get(entity_id)
|
ha_state = hass.states.get(entity_id)
|
||||||
@ -542,7 +542,7 @@ async def test_hmip_din_rail_dimmer_3_channel2(
|
|||||||
"light", "turn_off", {"entity_id": entity_id}, blocking=True
|
"light", "turn_off", {"entity_id": entity_id}, blocking=True
|
||||||
)
|
)
|
||||||
assert len(hmip_device.mock_calls) == service_call_counter + 4
|
assert len(hmip_device.mock_calls) == service_call_counter + 4
|
||||||
assert hmip_device.mock_calls[-1][0] == "set_dim_level"
|
assert hmip_device.mock_calls[-1][0] == "set_dim_level_async"
|
||||||
assert hmip_device.mock_calls[-1][1] == (0, 2)
|
assert hmip_device.mock_calls[-1][1] == (0, 2)
|
||||||
await async_manipulate_test_data(hass, hmip_device, "dimLevel", 0, channel=2)
|
await async_manipulate_test_data(hass, hmip_device, "dimLevel", 0, channel=2)
|
||||||
ha_state = hass.states.get(entity_id)
|
ha_state = hass.states.get(entity_id)
|
||||||
@ -577,7 +577,7 @@ async def test_hmip_din_rail_dimmer_3_channel3(
|
|||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
"light", "turn_on", {"entity_id": entity_id}, blocking=True
|
"light", "turn_on", {"entity_id": entity_id}, blocking=True
|
||||||
)
|
)
|
||||||
assert hmip_device.mock_calls[-1][0] == "set_dim_level"
|
assert hmip_device.mock_calls[-1][0] == "set_dim_level_async"
|
||||||
assert hmip_device.mock_calls[-1][1] == (1, 3)
|
assert hmip_device.mock_calls[-1][1] == (1, 3)
|
||||||
|
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
@ -587,7 +587,7 @@ async def test_hmip_din_rail_dimmer_3_channel3(
|
|||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
assert len(hmip_device.mock_calls) == service_call_counter + 2
|
assert len(hmip_device.mock_calls) == service_call_counter + 2
|
||||||
assert hmip_device.mock_calls[-1][0] == "set_dim_level"
|
assert hmip_device.mock_calls[-1][0] == "set_dim_level_async"
|
||||||
assert hmip_device.mock_calls[-1][1] == (0.39215686274509803, 3)
|
assert hmip_device.mock_calls[-1][1] == (0.39215686274509803, 3)
|
||||||
await async_manipulate_test_data(hass, hmip_device, "dimLevel", 1, channel=3)
|
await async_manipulate_test_data(hass, hmip_device, "dimLevel", 1, channel=3)
|
||||||
ha_state = hass.states.get(entity_id)
|
ha_state = hass.states.get(entity_id)
|
||||||
@ -601,7 +601,7 @@ async def test_hmip_din_rail_dimmer_3_channel3(
|
|||||||
"light", "turn_off", {"entity_id": entity_id}, blocking=True
|
"light", "turn_off", {"entity_id": entity_id}, blocking=True
|
||||||
)
|
)
|
||||||
assert len(hmip_device.mock_calls) == service_call_counter + 4
|
assert len(hmip_device.mock_calls) == service_call_counter + 4
|
||||||
assert hmip_device.mock_calls[-1][0] == "set_dim_level"
|
assert hmip_device.mock_calls[-1][0] == "set_dim_level_async"
|
||||||
assert hmip_device.mock_calls[-1][1] == (0, 3)
|
assert hmip_device.mock_calls[-1][1] == (0, 3)
|
||||||
await async_manipulate_test_data(hass, hmip_device, "dimLevel", 0, channel=3)
|
await async_manipulate_test_data(hass, hmip_device, "dimLevel", 0, channel=3)
|
||||||
ha_state = hass.states.get(entity_id)
|
ha_state = hass.states.get(entity_id)
|
||||||
|
@ -50,7 +50,7 @@ async def test_hmip_doorlockdrive(
|
|||||||
{"entity_id": entity_id},
|
{"entity_id": entity_id},
|
||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
assert hmip_device.mock_calls[-1][0] == "set_lock_state"
|
assert hmip_device.mock_calls[-1][0] == "set_lock_state_async"
|
||||||
assert hmip_device.mock_calls[-1][1] == (HomematicLockState.OPEN,)
|
assert hmip_device.mock_calls[-1][1] == (HomematicLockState.OPEN,)
|
||||||
|
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
@ -59,7 +59,7 @@ async def test_hmip_doorlockdrive(
|
|||||||
{"entity_id": entity_id},
|
{"entity_id": entity_id},
|
||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
assert hmip_device.mock_calls[-1][0] == "set_lock_state"
|
assert hmip_device.mock_calls[-1][0] == "set_lock_state_async"
|
||||||
assert hmip_device.mock_calls[-1][1] == (HomematicLockState.LOCKED,)
|
assert hmip_device.mock_calls[-1][1] == (HomematicLockState.LOCKED,)
|
||||||
|
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
@ -69,7 +69,7 @@ async def test_hmip_doorlockdrive(
|
|||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert hmip_device.mock_calls[-1][0] == "set_lock_state"
|
assert hmip_device.mock_calls[-1][0] == "set_lock_state_async"
|
||||||
assert hmip_device.mock_calls[-1][1] == (HomematicLockState.UNLOCKED,)
|
assert hmip_device.mock_calls[-1][1] == (HomematicLockState.UNLOCKED,)
|
||||||
|
|
||||||
await async_manipulate_test_data(
|
await async_manipulate_test_data(
|
||||||
@ -96,7 +96,7 @@ async def test_hmip_doorlockdrive_handle_errors(
|
|||||||
test_devices=[entity_name]
|
test_devices=[entity_name]
|
||||||
)
|
)
|
||||||
with patch(
|
with patch(
|
||||||
"homematicip.aio.device.AsyncDoorLockDrive.set_lock_state",
|
"homematicip.device.DoorLockDrive.set_lock_state_async",
|
||||||
return_value={
|
return_value={
|
||||||
"errorCode": "INVALID_NUMBER_PARAMETER_VALUE",
|
"errorCode": "INVALID_NUMBER_PARAMETER_VALUE",
|
||||||
"minValue": 0.0,
|
"minValue": 0.0,
|
||||||
|
@ -42,7 +42,7 @@ async def test_hmip_switch(
|
|||||||
"switch", "turn_off", {"entity_id": entity_id}, blocking=True
|
"switch", "turn_off", {"entity_id": entity_id}, blocking=True
|
||||||
)
|
)
|
||||||
assert len(hmip_device.mock_calls) == service_call_counter + 1
|
assert len(hmip_device.mock_calls) == service_call_counter + 1
|
||||||
assert hmip_device.mock_calls[-1][0] == "turn_off"
|
assert hmip_device.mock_calls[-1][0] == "turn_off_async"
|
||||||
assert hmip_device.mock_calls[-1][1] == (1,)
|
assert hmip_device.mock_calls[-1][1] == (1,)
|
||||||
await async_manipulate_test_data(hass, hmip_device, "on", False)
|
await async_manipulate_test_data(hass, hmip_device, "on", False)
|
||||||
ha_state = hass.states.get(entity_id)
|
ha_state = hass.states.get(entity_id)
|
||||||
@ -52,7 +52,7 @@ async def test_hmip_switch(
|
|||||||
"switch", "turn_on", {"entity_id": entity_id}, blocking=True
|
"switch", "turn_on", {"entity_id": entity_id}, blocking=True
|
||||||
)
|
)
|
||||||
assert len(hmip_device.mock_calls) == service_call_counter + 3
|
assert len(hmip_device.mock_calls) == service_call_counter + 3
|
||||||
assert hmip_device.mock_calls[-1][0] == "turn_on"
|
assert hmip_device.mock_calls[-1][0] == "turn_on_async"
|
||||||
assert hmip_device.mock_calls[-1][1] == (1,)
|
assert hmip_device.mock_calls[-1][1] == (1,)
|
||||||
await async_manipulate_test_data(hass, hmip_device, "on", True)
|
await async_manipulate_test_data(hass, hmip_device, "on", True)
|
||||||
ha_state = hass.states.get(entity_id)
|
ha_state = hass.states.get(entity_id)
|
||||||
@ -81,7 +81,7 @@ async def test_hmip_switch_input(
|
|||||||
"switch", "turn_off", {"entity_id": entity_id}, blocking=True
|
"switch", "turn_off", {"entity_id": entity_id}, blocking=True
|
||||||
)
|
)
|
||||||
assert len(hmip_device.mock_calls) == service_call_counter + 1
|
assert len(hmip_device.mock_calls) == service_call_counter + 1
|
||||||
assert hmip_device.mock_calls[-1][0] == "turn_off"
|
assert hmip_device.mock_calls[-1][0] == "turn_off_async"
|
||||||
assert hmip_device.mock_calls[-1][1] == (1,)
|
assert hmip_device.mock_calls[-1][1] == (1,)
|
||||||
await async_manipulate_test_data(hass, hmip_device, "on", False)
|
await async_manipulate_test_data(hass, hmip_device, "on", False)
|
||||||
ha_state = hass.states.get(entity_id)
|
ha_state = hass.states.get(entity_id)
|
||||||
@ -91,7 +91,7 @@ async def test_hmip_switch_input(
|
|||||||
"switch", "turn_on", {"entity_id": entity_id}, blocking=True
|
"switch", "turn_on", {"entity_id": entity_id}, blocking=True
|
||||||
)
|
)
|
||||||
assert len(hmip_device.mock_calls) == service_call_counter + 3
|
assert len(hmip_device.mock_calls) == service_call_counter + 3
|
||||||
assert hmip_device.mock_calls[-1][0] == "turn_on"
|
assert hmip_device.mock_calls[-1][0] == "turn_on_async"
|
||||||
assert hmip_device.mock_calls[-1][1] == (1,)
|
assert hmip_device.mock_calls[-1][1] == (1,)
|
||||||
await async_manipulate_test_data(hass, hmip_device, "on", True)
|
await async_manipulate_test_data(hass, hmip_device, "on", True)
|
||||||
ha_state = hass.states.get(entity_id)
|
ha_state = hass.states.get(entity_id)
|
||||||
@ -120,7 +120,7 @@ async def test_hmip_switch_measuring(
|
|||||||
"switch", "turn_off", {"entity_id": entity_id}, blocking=True
|
"switch", "turn_off", {"entity_id": entity_id}, blocking=True
|
||||||
)
|
)
|
||||||
assert len(hmip_device.mock_calls) == service_call_counter + 1
|
assert len(hmip_device.mock_calls) == service_call_counter + 1
|
||||||
assert hmip_device.mock_calls[-1][0] == "turn_off"
|
assert hmip_device.mock_calls[-1][0] == "turn_off_async"
|
||||||
assert hmip_device.mock_calls[-1][1] == (1,)
|
assert hmip_device.mock_calls[-1][1] == (1,)
|
||||||
await async_manipulate_test_data(hass, hmip_device, "on", False)
|
await async_manipulate_test_data(hass, hmip_device, "on", False)
|
||||||
ha_state = hass.states.get(entity_id)
|
ha_state = hass.states.get(entity_id)
|
||||||
@ -130,7 +130,7 @@ async def test_hmip_switch_measuring(
|
|||||||
"switch", "turn_on", {"entity_id": entity_id}, blocking=True
|
"switch", "turn_on", {"entity_id": entity_id}, blocking=True
|
||||||
)
|
)
|
||||||
assert len(hmip_device.mock_calls) == service_call_counter + 3
|
assert len(hmip_device.mock_calls) == service_call_counter + 3
|
||||||
assert hmip_device.mock_calls[-1][0] == "turn_on"
|
assert hmip_device.mock_calls[-1][0] == "turn_on_async"
|
||||||
assert hmip_device.mock_calls[-1][1] == (1,)
|
assert hmip_device.mock_calls[-1][1] == (1,)
|
||||||
await async_manipulate_test_data(hass, hmip_device, "on", True)
|
await async_manipulate_test_data(hass, hmip_device, "on", True)
|
||||||
await async_manipulate_test_data(hass, hmip_device, "currentPowerConsumption", 50)
|
await async_manipulate_test_data(hass, hmip_device, "currentPowerConsumption", 50)
|
||||||
@ -158,7 +158,7 @@ async def test_hmip_group_switch(
|
|||||||
"switch", "turn_off", {"entity_id": entity_id}, blocking=True
|
"switch", "turn_off", {"entity_id": entity_id}, blocking=True
|
||||||
)
|
)
|
||||||
assert len(hmip_device.mock_calls) == service_call_counter + 1
|
assert len(hmip_device.mock_calls) == service_call_counter + 1
|
||||||
assert hmip_device.mock_calls[-1][0] == "turn_off"
|
assert hmip_device.mock_calls[-1][0] == "turn_off_async"
|
||||||
assert hmip_device.mock_calls[-1][1] == ()
|
assert hmip_device.mock_calls[-1][1] == ()
|
||||||
await async_manipulate_test_data(hass, hmip_device, "on", False)
|
await async_manipulate_test_data(hass, hmip_device, "on", False)
|
||||||
ha_state = hass.states.get(entity_id)
|
ha_state = hass.states.get(entity_id)
|
||||||
@ -168,7 +168,7 @@ async def test_hmip_group_switch(
|
|||||||
"switch", "turn_on", {"entity_id": entity_id}, blocking=True
|
"switch", "turn_on", {"entity_id": entity_id}, blocking=True
|
||||||
)
|
)
|
||||||
assert len(hmip_device.mock_calls) == service_call_counter + 3
|
assert len(hmip_device.mock_calls) == service_call_counter + 3
|
||||||
assert hmip_device.mock_calls[-1][0] == "turn_on"
|
assert hmip_device.mock_calls[-1][0] == "turn_on_async"
|
||||||
assert hmip_device.mock_calls[-1][1] == ()
|
assert hmip_device.mock_calls[-1][1] == ()
|
||||||
await async_manipulate_test_data(hass, hmip_device, "on", True)
|
await async_manipulate_test_data(hass, hmip_device, "on", True)
|
||||||
ha_state = hass.states.get(entity_id)
|
ha_state = hass.states.get(entity_id)
|
||||||
@ -208,7 +208,7 @@ async def test_hmip_multi_switch(
|
|||||||
"switch", "turn_on", {"entity_id": entity_id}, blocking=True
|
"switch", "turn_on", {"entity_id": entity_id}, blocking=True
|
||||||
)
|
)
|
||||||
assert len(hmip_device.mock_calls) == service_call_counter + 1
|
assert len(hmip_device.mock_calls) == service_call_counter + 1
|
||||||
assert hmip_device.mock_calls[-1][0] == "turn_on"
|
assert hmip_device.mock_calls[-1][0] == "turn_on_async"
|
||||||
assert hmip_device.mock_calls[-1][1] == (1,)
|
assert hmip_device.mock_calls[-1][1] == (1,)
|
||||||
await async_manipulate_test_data(hass, hmip_device, "on", True)
|
await async_manipulate_test_data(hass, hmip_device, "on", True)
|
||||||
ha_state = hass.states.get(entity_id)
|
ha_state = hass.states.get(entity_id)
|
||||||
@ -218,7 +218,7 @@ async def test_hmip_multi_switch(
|
|||||||
"switch", "turn_off", {"entity_id": entity_id}, blocking=True
|
"switch", "turn_off", {"entity_id": entity_id}, blocking=True
|
||||||
)
|
)
|
||||||
assert len(hmip_device.mock_calls) == service_call_counter + 3
|
assert len(hmip_device.mock_calls) == service_call_counter + 3
|
||||||
assert hmip_device.mock_calls[-1][0] == "turn_off"
|
assert hmip_device.mock_calls[-1][0] == "turn_off_async"
|
||||||
assert hmip_device.mock_calls[-1][1] == (1,)
|
assert hmip_device.mock_calls[-1][1] == (1,)
|
||||||
await async_manipulate_test_data(hass, hmip_device, "on", False)
|
await async_manipulate_test_data(hass, hmip_device, "on", False)
|
||||||
ha_state = hass.states.get(entity_id)
|
ha_state = hass.states.get(entity_id)
|
||||||
@ -259,7 +259,7 @@ async def test_hmip_wired_multi_switch(
|
|||||||
"switch", "turn_off", {"entity_id": entity_id}, blocking=True
|
"switch", "turn_off", {"entity_id": entity_id}, blocking=True
|
||||||
)
|
)
|
||||||
assert len(hmip_device.mock_calls) == service_call_counter + 1
|
assert len(hmip_device.mock_calls) == service_call_counter + 1
|
||||||
assert hmip_device.mock_calls[-1][0] == "turn_off"
|
assert hmip_device.mock_calls[-1][0] == "turn_off_async"
|
||||||
assert hmip_device.mock_calls[-1][1] == (1,)
|
assert hmip_device.mock_calls[-1][1] == (1,)
|
||||||
await async_manipulate_test_data(hass, hmip_device, "on", False)
|
await async_manipulate_test_data(hass, hmip_device, "on", False)
|
||||||
ha_state = hass.states.get(entity_id)
|
ha_state = hass.states.get(entity_id)
|
||||||
@ -269,7 +269,7 @@ async def test_hmip_wired_multi_switch(
|
|||||||
"switch", "turn_on", {"entity_id": entity_id}, blocking=True
|
"switch", "turn_on", {"entity_id": entity_id}, blocking=True
|
||||||
)
|
)
|
||||||
assert len(hmip_device.mock_calls) == service_call_counter + 3
|
assert len(hmip_device.mock_calls) == service_call_counter + 3
|
||||||
assert hmip_device.mock_calls[-1][0] == "turn_on"
|
assert hmip_device.mock_calls[-1][0] == "turn_on_async"
|
||||||
assert hmip_device.mock_calls[-1][1] == (1,)
|
assert hmip_device.mock_calls[-1][1] == (1,)
|
||||||
await async_manipulate_test_data(hass, hmip_device, "on", True)
|
await async_manipulate_test_data(hass, hmip_device, "on", True)
|
||||||
ha_state = hass.states.get(entity_id)
|
ha_state = hass.states.get(entity_id)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user