From 758c0adb5e3342755ebf2cfb83cacbb62769d60c Mon Sep 17 00:00:00 2001 From: SukramJ Date: Wed, 26 Aug 2020 01:55:55 +0200 Subject: [PATCH] Rename entity base class for HMIPC (#39243) --- .../components/homematicip_cloud/__init__.py | 2 +- .../homematicip_cloud/alarm_control_panel.py | 10 ++-- .../homematicip_cloud/binary_sensor.py | 56 +++++++++---------- .../components/homematicip_cloud/climate.py | 6 +- .../components/homematicip_cloud/cover.py | 14 ++--- .../{device.py => generic_entity.py} | 18 +++--- .../components/homematicip_cloud/hap.py | 6 +- .../components/homematicip_cloud/light.py | 42 +++++++------- .../components/homematicip_cloud/sensor.py | 56 +++++++++---------- .../components/homematicip_cloud/switch.py | 26 ++++----- .../components/homematicip_cloud/weather.py | 16 +++--- tests/components/homematicip_cloud/helper.py | 2 +- .../homematicip_cloud/test_binary_sensor.py | 2 +- .../homematicip_cloud/test_sensor.py | 2 +- .../homematicip_cloud/test_switch.py | 2 +- 15 files changed, 130 insertions(+), 130 deletions(-) rename homeassistant/components/homematicip_cloud/{device.py => generic_entity.py} (93%) diff --git a/homeassistant/components/homematicip_cloud/__init__.py b/homeassistant/components/homematicip_cloud/__init__.py index df1f5062fce..47da33e86da 100644 --- a/homeassistant/components/homematicip_cloud/__init__.py +++ b/homeassistant/components/homematicip_cloud/__init__.py @@ -18,7 +18,7 @@ from .const import ( HMIPC_HAPID, HMIPC_NAME, ) -from .device import HomematicipGenericDevice # noqa: F401 +from .generic_entity import HomematicipGenericEntity # noqa: F401 from .hap import HomematicipAuth, HomematicipHAP # noqa: F401 from .services import async_setup_services, async_unload_services diff --git a/homeassistant/components/homematicip_cloud/alarm_control_panel.py b/homeassistant/components/homematicip_cloud/alarm_control_panel.py index b53e0363a6a..51cec6ac0cd 100644 --- a/homeassistant/components/homematicip_cloud/alarm_control_panel.py +++ b/homeassistant/components/homematicip_cloud/alarm_control_panel.py @@ -36,7 +36,7 @@ async def async_setup_entry( class HomematicipAlarmControlPanelEntity(AlarmControlPanelEntity): - """Representation of an alarm control panel.""" + """Representation of the HomematicIP alarm control panel.""" def __init__(self, hap: HomematicipHAP) -> None: """Initialize the alarm control panel.""" @@ -56,7 +56,7 @@ class HomematicipAlarmControlPanelEntity(AlarmControlPanelEntity): @property def state(self) -> str: - """Return the state of the device.""" + """Return the state of the alarm control panel.""" # check for triggered alarm if self._security_and_alarm.alarmActive: return STATE_ALARM_TRIGGERED @@ -98,7 +98,7 @@ class HomematicipAlarmControlPanelEntity(AlarmControlPanelEntity): @callback def _async_device_changed(self, *args, **kwargs) -> None: - """Handle device state changes.""" + """Handle entity state changes.""" # Don't update disabled entities if self.enabled: _LOGGER.debug("Event %s (%s)", self.name, CONST_ALARM_CONTROL_PANEL_NAME) @@ -111,7 +111,7 @@ class HomematicipAlarmControlPanelEntity(AlarmControlPanelEntity): @property def name(self) -> str: - """Return the name of the generic device.""" + """Return the name of the generic entity.""" name = CONST_ALARM_CONTROL_PANEL_NAME if self._home.name: name = f"{self._home.name} {name}" @@ -124,7 +124,7 @@ class HomematicipAlarmControlPanelEntity(AlarmControlPanelEntity): @property def available(self) -> bool: - """Device available.""" + """Return if alarm control panel is available.""" return self._home.connected @property diff --git a/homeassistant/components/homematicip_cloud/binary_sensor.py b/homeassistant/components/homematicip_cloud/binary_sensor.py index 15c41be24b5..aae7f881be0 100644 --- a/homeassistant/components/homematicip_cloud/binary_sensor.py +++ b/homeassistant/components/homematicip_cloud/binary_sensor.py @@ -41,7 +41,7 @@ from homeassistant.components.binary_sensor import ( from homeassistant.config_entries import ConfigEntry from homeassistant.helpers.typing import HomeAssistantType -from . import DOMAIN as HMIPC_DOMAIN, HomematicipGenericDevice +from . import DOMAIN as HMIPC_DOMAIN, HomematicipGenericEntity from .hap import HomematicipHAP _LOGGER = logging.getLogger(__name__) @@ -131,8 +131,8 @@ async def async_setup_entry( async_add_entities(entities) -class HomematicipAccelerationSensor(HomematicipGenericDevice, BinarySensorEntity): - """Representation of a HomematicIP Cloud acceleration sensor.""" +class HomematicipAccelerationSensor(HomematicipGenericEntity, BinarySensorEntity): + """Representation of the HomematicIP acceleration sensor.""" @property def device_class(self) -> str: @@ -157,8 +157,8 @@ class HomematicipAccelerationSensor(HomematicipGenericDevice, BinarySensorEntity return state_attr -class HomematicipContactInterface(HomematicipGenericDevice, BinarySensorEntity): - """Representation of a HomematicIP Cloud contact interface.""" +class HomematicipContactInterface(HomematicipGenericEntity, BinarySensorEntity): + """Representation of the HomematicIP contact interface.""" @property def device_class(self) -> str: @@ -173,8 +173,8 @@ class HomematicipContactInterface(HomematicipGenericDevice, BinarySensorEntity): return self._device.windowState != WindowState.CLOSED -class HomematicipShutterContact(HomematicipGenericDevice, BinarySensorEntity): - """Representation of a HomematicIP Cloud shutter contact.""" +class HomematicipShutterContact(HomematicipGenericEntity, BinarySensorEntity): + """Representation of the HomematicIP shutter contact.""" @property def device_class(self) -> str: @@ -189,8 +189,8 @@ class HomematicipShutterContact(HomematicipGenericDevice, BinarySensorEntity): return self._device.windowState != WindowState.CLOSED -class HomematicipMotionDetector(HomematicipGenericDevice, BinarySensorEntity): - """Representation of a HomematicIP Cloud motion detector.""" +class HomematicipMotionDetector(HomematicipGenericEntity, BinarySensorEntity): + """Representation of the HomematicIP motion detector.""" @property def device_class(self) -> str: @@ -203,8 +203,8 @@ class HomematicipMotionDetector(HomematicipGenericDevice, BinarySensorEntity): return self._device.motionDetected -class HomematicipPresenceDetector(HomematicipGenericDevice, BinarySensorEntity): - """Representation of a HomematicIP Cloud presence detector.""" +class HomematicipPresenceDetector(HomematicipGenericEntity, BinarySensorEntity): + """Representation of the HomematicIP presence detector.""" @property def device_class(self) -> str: @@ -217,8 +217,8 @@ class HomematicipPresenceDetector(HomematicipGenericDevice, BinarySensorEntity): return self._device.presenceDetected -class HomematicipSmokeDetector(HomematicipGenericDevice, BinarySensorEntity): - """Representation of a HomematicIP Cloud smoke detector.""" +class HomematicipSmokeDetector(HomematicipGenericEntity, BinarySensorEntity): + """Representation of the HomematicIP smoke detector.""" @property def device_class(self) -> str: @@ -236,8 +236,8 @@ class HomematicipSmokeDetector(HomematicipGenericDevice, BinarySensorEntity): return False -class HomematicipWaterDetector(HomematicipGenericDevice, BinarySensorEntity): - """Representation of a HomematicIP Cloud water detector.""" +class HomematicipWaterDetector(HomematicipGenericEntity, BinarySensorEntity): + """Representation of the HomematicIP water detector.""" @property def device_class(self) -> str: @@ -250,8 +250,8 @@ class HomematicipWaterDetector(HomematicipGenericDevice, BinarySensorEntity): return self._device.moistureDetected or self._device.waterlevelDetected -class HomematicipStormSensor(HomematicipGenericDevice, BinarySensorEntity): - """Representation of a HomematicIP Cloud storm sensor.""" +class HomematicipStormSensor(HomematicipGenericEntity, BinarySensorEntity): + """Representation of the HomematicIP storm sensor.""" def __init__(self, hap: HomematicipHAP, device) -> None: """Initialize storm sensor.""" @@ -268,8 +268,8 @@ class HomematicipStormSensor(HomematicipGenericDevice, BinarySensorEntity): return self._device.storm -class HomematicipRainSensor(HomematicipGenericDevice, BinarySensorEntity): - """Representation of a HomematicIP Cloud rain sensor.""" +class HomematicipRainSensor(HomematicipGenericEntity, BinarySensorEntity): + """Representation of the HomematicIP rain sensor.""" def __init__(self, hap: HomematicipHAP, device) -> None: """Initialize rain sensor.""" @@ -286,8 +286,8 @@ class HomematicipRainSensor(HomematicipGenericDevice, BinarySensorEntity): return self._device.raining -class HomematicipSunshineSensor(HomematicipGenericDevice, BinarySensorEntity): - """Representation of a HomematicIP Cloud sunshine sensor.""" +class HomematicipSunshineSensor(HomematicipGenericEntity, BinarySensorEntity): + """Representation of the HomematicIP sunshine sensor.""" def __init__(self, hap: HomematicipHAP, device) -> None: """Initialize sunshine sensor.""" @@ -315,8 +315,8 @@ class HomematicipSunshineSensor(HomematicipGenericDevice, BinarySensorEntity): return state_attr -class HomematicipBatterySensor(HomematicipGenericDevice, BinarySensorEntity): - """Representation of a HomematicIP Cloud low battery sensor.""" +class HomematicipBatterySensor(HomematicipGenericEntity, BinarySensorEntity): + """Representation of the HomematicIP low battery sensor.""" def __init__(self, hap: HomematicipHAP, device) -> None: """Initialize battery sensor.""" @@ -334,9 +334,9 @@ class HomematicipBatterySensor(HomematicipGenericDevice, BinarySensorEntity): class HomematicipPluggableMainsFailureSurveillanceSensor( - HomematicipGenericDevice, BinarySensorEntity + HomematicipGenericEntity, BinarySensorEntity ): - """Representation of a HomematicIP Cloud pluggable mains failure surveillance sensor.""" + """Representation of the HomematicIP pluggable mains failure surveillance sensor.""" def __init__(self, hap: HomematicipHAP, device) -> None: """Initialize pluggable mains failure surveillance sensor.""" @@ -353,8 +353,8 @@ class HomematicipPluggableMainsFailureSurveillanceSensor( return not self._device.powerMainsFailure -class HomematicipSecurityZoneSensorGroup(HomematicipGenericDevice, BinarySensorEntity): - """Representation of a HomematicIP Cloud security zone group.""" +class HomematicipSecurityZoneSensorGroup(HomematicipGenericEntity, BinarySensorEntity): + """Representation of the HomematicIP security zone sensor group.""" def __init__(self, hap: HomematicipHAP, device, post: str = "SecurityZone") -> None: """Initialize security zone group.""" @@ -411,7 +411,7 @@ class HomematicipSecurityZoneSensorGroup(HomematicipGenericDevice, BinarySensorE class HomematicipSecuritySensorGroup( HomematicipSecurityZoneSensorGroup, BinarySensorEntity ): - """Representation of a HomematicIP security group.""" + """Representation of the HomematicIP security group.""" def __init__(self, hap: HomematicipHAP, device) -> None: """Initialize security group.""" diff --git a/homeassistant/components/homematicip_cloud/climate.py b/homeassistant/components/homematicip_cloud/climate.py index 3d01f5d69fd..3f9cdcbcbdd 100644 --- a/homeassistant/components/homematicip_cloud/climate.py +++ b/homeassistant/components/homematicip_cloud/climate.py @@ -27,7 +27,7 @@ from homeassistant.config_entries import ConfigEntry from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS from homeassistant.helpers.typing import HomeAssistantType -from . import DOMAIN as HMIPC_DOMAIN, HomematicipGenericDevice +from . import DOMAIN as HMIPC_DOMAIN, HomematicipGenericEntity from .hap import HomematicipHAP HEATING_PROFILES = {"PROFILE_1": 0, "PROFILE_2": 1, "PROFILE_3": 2} @@ -57,8 +57,8 @@ async def async_setup_entry( async_add_entities(entities) -class HomematicipHeatingGroup(HomematicipGenericDevice, ClimateEntity): - """Representation of a HomematicIP heating group. +class HomematicipHeatingGroup(HomematicipGenericEntity, ClimateEntity): + """Representation of the HomematicIP heating group. Heat mode is supported for all heating devices incl. their defined profiles. Boost is available for radiator thermostats only. diff --git a/homeassistant/components/homematicip_cloud/cover.py b/homeassistant/components/homematicip_cloud/cover.py index d11a08d80a6..5b2f02e8a2d 100644 --- a/homeassistant/components/homematicip_cloud/cover.py +++ b/homeassistant/components/homematicip_cloud/cover.py @@ -19,7 +19,7 @@ from homeassistant.components.cover import ( from homeassistant.config_entries import ConfigEntry from homeassistant.helpers.typing import HomeAssistantType -from . import DOMAIN as HMIPC_DOMAIN, HomematicipGenericDevice +from . import DOMAIN as HMIPC_DOMAIN, HomematicipGenericEntity from .hap import HomematicipHAP _LOGGER = logging.getLogger(__name__) @@ -54,8 +54,8 @@ async def async_setup_entry( async_add_entities(entities) -class HomematicipCoverShutter(HomematicipGenericDevice, CoverEntity): - """Representation of a HomematicIP Cloud cover shutter device.""" +class HomematicipCoverShutter(HomematicipGenericEntity, CoverEntity): + """Representation of the HomematicIP cover shutter.""" @property def current_cover_position(self) -> int: @@ -92,7 +92,7 @@ class HomematicipCoverShutter(HomematicipGenericDevice, CoverEntity): class HomematicipCoverSlats(HomematicipCoverShutter, CoverEntity): - """Representation of a HomematicIP Cloud cover slats device.""" + """Representation of the HomematicIP cover slats.""" @property def current_cover_tilt_position(self) -> int: @@ -121,8 +121,8 @@ class HomematicipCoverSlats(HomematicipCoverShutter, CoverEntity): await self._device.set_shutter_stop() -class HomematicipGarageDoorModule(HomematicipGenericDevice, CoverEntity): - """Representation of a HomematicIP Garage Door Module.""" +class HomematicipGarageDoorModule(HomematicipGenericEntity, CoverEntity): + """Representation of the HomematicIP Garage Door Module.""" @property def current_cover_position(self) -> int: @@ -154,7 +154,7 @@ class HomematicipGarageDoorModule(HomematicipGenericDevice, CoverEntity): class HomematicipCoverShutterGroup(HomematicipCoverSlats, CoverEntity): - """Representation of a HomematicIP Cloud cover shutter group.""" + """Representation of the HomematicIP cover shutter group.""" def __init__(self, hap: HomematicipHAP, device, post: str = "ShutterGroup") -> None: """Initialize switching group.""" diff --git a/homeassistant/components/homematicip_cloud/device.py b/homeassistant/components/homematicip_cloud/generic_entity.py similarity index 93% rename from homeassistant/components/homematicip_cloud/device.py rename to homeassistant/components/homematicip_cloud/generic_entity.py index 91bec464a29..7450a82943f 100644 --- a/homeassistant/components/homematicip_cloud/device.py +++ b/homeassistant/components/homematicip_cloud/generic_entity.py @@ -1,4 +1,4 @@ -"""Generic device for the HomematicIP Cloud component.""" +"""Generic entity for the HomematicIP Cloud component.""" import logging from typing import Any, Dict, Optional @@ -65,11 +65,11 @@ GROUP_ATTRIBUTES = { } -class HomematicipGenericDevice(Entity): - """Representation of an HomematicIP generic device.""" +class HomematicipGenericEntity(Entity): + """Representation of the HomematicIP generic entity.""" def __init__(self, hap: HomematicipHAP, device, post: Optional[str] = None) -> None: - """Initialize the generic device.""" + """Initialize the generic entity.""" self._hap = hap self._home = hap.home self._device = device @@ -117,7 +117,7 @@ class HomematicipGenericDevice(Entity): ) async def async_will_remove_from_hass(self) -> None: - """Run when entity will be removed from hass.""" + """Run when hmip device will be removed from hass.""" # Only go further if the device/entity should be removed from registries # due to a removal of the HmIP device. @@ -127,7 +127,7 @@ class HomematicipGenericDevice(Entity): del self._hap.hmip_device_by_entity_id[self.entity_id] await self.async_remove_from_registries() except KeyError as err: - _LOGGER.debug("Error removing HMIP entity from registry: %s", err) + _LOGGER.debug("Error removing HMIP device from registry: %s", err) async def async_remove_from_registries(self) -> None: """Remove entity/device from registry.""" @@ -164,7 +164,7 @@ class HomematicipGenericDevice(Entity): @property def name(self) -> str: - """Return the name of the generic device.""" + """Return the name of the generic entity.""" name = self._device.label if name and self._home.name: name = f"{self._home.name} {name}" @@ -186,7 +186,7 @@ class HomematicipGenericDevice(Entity): @property def available(self) -> bool: - """Device available.""" + """Return if entity is available.""" return not self._device.unreach @property @@ -205,7 +205,7 @@ class HomematicipGenericDevice(Entity): @property def device_state_attributes(self) -> Dict[str, Any]: - """Return the state attributes of the generic device.""" + """Return the state attributes of the generic entity.""" state_attr = {} if isinstance(self._device, AsyncDevice): diff --git a/homeassistant/components/homematicip_cloud/hap.py b/homeassistant/components/homematicip_cloud/hap.py index dd85827f1ae..431b05e692a 100644 --- a/homeassistant/components/homematicip_cloud/hap.py +++ b/homeassistant/components/homematicip_cloud/hap.py @@ -117,7 +117,7 @@ class HomematicipHAP: Triggered when the HMIP HOME_CHANGED event has fired. There are several occasions for this event to happen. 1. We are interested to check whether the access point - is still connected. If not, device state changes cannot + is still connected. If not, entity state changes cannot be forwarded to hass. So if access point is disconnected all devices are set to unavailable. 2. We need to update home including devices and groups after a reconnect. @@ -131,7 +131,7 @@ class HomematicipHAP: elif not self._accesspoint_connected: # Now the HOME_CHANGED event has fired indicating the access # point has reconnected to the cloud again. - # Explicitly getting an update as device states might have + # Explicitly getting an update as entity states might have # changed during access point disconnect.""" job = self.hass.async_create_task(self.get_state()) @@ -140,7 +140,7 @@ class HomematicipHAP: @callback def async_create_entity(self, *args, **kwargs) -> None: - """Create a device or a group.""" + """Create an entity or a group.""" is_device = EventType(kwargs["event_type"]) == EventType.DEVICE_ADDED self.hass.async_create_task(self.async_create_entity_lazy(is_device)) diff --git a/homeassistant/components/homematicip_cloud/light.py b/homeassistant/components/homematicip_cloud/light.py index 9ddcc44e8bd..72737122372 100644 --- a/homeassistant/components/homematicip_cloud/light.py +++ b/homeassistant/components/homematicip_cloud/light.py @@ -26,7 +26,7 @@ from homeassistant.components.light import ( from homeassistant.config_entries import ConfigEntry from homeassistant.helpers.typing import HomeAssistantType -from . import DOMAIN as HMIPC_DOMAIN, HomematicipGenericDevice +from . import DOMAIN as HMIPC_DOMAIN, HomematicipGenericEntity from .hap import HomematicipHAP _LOGGER = logging.getLogger(__name__) @@ -64,11 +64,11 @@ async def async_setup_entry( async_add_entities(entities) -class HomematicipLight(HomematicipGenericDevice, LightEntity): - """Representation of a HomematicIP Cloud light device.""" +class HomematicipLight(HomematicipGenericEntity, LightEntity): + """Representation of the HomematicIP light.""" def __init__(self, hap: HomematicipHAP, device) -> None: - """Initialize the light device.""" + """Initialize the light entity.""" super().__init__(hap, device) @property @@ -81,24 +81,24 @@ class HomematicipLight(HomematicipGenericDevice, LightEntity): @property def is_on(self) -> bool: - """Return true if device is on.""" + """Return true if light is on.""" return self._device.on async def async_turn_on(self, **kwargs) -> None: - """Turn the device on.""" + """Turn the light on.""" await self._device.turn_on() async def async_turn_off(self, **kwargs) -> None: - """Turn the device off.""" + """Turn the light off.""" await self._device.turn_off() class HomematicipLightMeasuring(HomematicipLight): - """Representation of a HomematicIP Cloud measuring light device.""" + """Representation of the HomematicIP measuring light.""" @property def device_state_attributes(self) -> Dict[str, Any]: - """Return the state attributes of the generic device.""" + """Return the state attributes of the light.""" state_attr = super().device_state_attributes current_power_w = self._device.currentPowerConsumption @@ -110,16 +110,16 @@ class HomematicipLightMeasuring(HomematicipLight): return state_attr -class HomematicipDimmer(HomematicipGenericDevice, LightEntity): - """Representation of HomematicIP Cloud dimmer light device.""" +class HomematicipDimmer(HomematicipGenericEntity, LightEntity): + """Representation of HomematicIP Cloud dimmer.""" def __init__(self, hap: HomematicipHAP, device) -> None: - """Initialize the dimmer light device.""" + """Initialize the dimmer light entity.""" super().__init__(hap, device) @property def is_on(self) -> bool: - """Return true if device is on.""" + """Return true if dimmer is on.""" return self._device.dimLevel is not None and self._device.dimLevel > 0.0 @property @@ -133,22 +133,22 @@ class HomematicipDimmer(HomematicipGenericDevice, LightEntity): return SUPPORT_BRIGHTNESS async def async_turn_on(self, **kwargs) -> None: - """Turn the light on.""" + """Turn the dimmer on.""" if ATTR_BRIGHTNESS in kwargs: await self._device.set_dim_level(kwargs[ATTR_BRIGHTNESS] / 255.0) else: await self._device.set_dim_level(1) async def async_turn_off(self, **kwargs) -> None: - """Turn the light off.""" + """Turn the dimmer off.""" await self._device.set_dim_level(0) -class HomematicipNotificationLight(HomematicipGenericDevice, LightEntity): - """Representation of HomematicIP Cloud dimmer light device.""" +class HomematicipNotificationLight(HomematicipGenericEntity, LightEntity): + """Representation of HomematicIP Cloud notification light.""" def __init__(self, hap: HomematicipHAP, device, channel: int) -> None: - """Initialize the dimmer light device.""" + """Initialize the notification light entity.""" self.channel = channel if self.channel == 2: super().__init__(hap, device, "Top") @@ -171,7 +171,7 @@ class HomematicipNotificationLight(HomematicipGenericDevice, LightEntity): @property def is_on(self) -> bool: - """Return true if device is on.""" + """Return true if light is on.""" return ( self._func_channel.dimLevel is not None and self._func_channel.dimLevel > 0.0 @@ -190,7 +190,7 @@ class HomematicipNotificationLight(HomematicipGenericDevice, LightEntity): @property def device_state_attributes(self) -> Dict[str, Any]: - """Return the state attributes of the generic device.""" + """Return the state attributes of the notification light sensor.""" state_attr = super().device_state_attributes if self.is_on: @@ -200,7 +200,7 @@ class HomematicipNotificationLight(HomematicipGenericDevice, LightEntity): @property def name(self) -> str: - """Return the name of the generic device.""" + """Return the name of the notification light sensor.""" label = self._get_label_by_channel(self.channel) if label: return label diff --git a/homeassistant/components/homematicip_cloud/sensor.py b/homeassistant/components/homematicip_cloud/sensor.py index a45591ecc30..c31e4d73cca 100644 --- a/homeassistant/components/homematicip_cloud/sensor.py +++ b/homeassistant/components/homematicip_cloud/sensor.py @@ -37,8 +37,8 @@ from homeassistant.const import ( ) from homeassistant.helpers.typing import HomeAssistantType -from . import DOMAIN as HMIPC_DOMAIN, HomematicipGenericDevice -from .device import ATTR_IS_GROUP, ATTR_MODEL_TYPE +from . import DOMAIN as HMIPC_DOMAIN, HomematicipGenericEntity +from .generic_entity import ATTR_IS_GROUP, ATTR_MODEL_TYPE from .hap import HomematicipHAP _LOGGER = logging.getLogger(__name__) @@ -120,11 +120,11 @@ async def async_setup_entry( async_add_entities(entities) -class HomematicipAccesspointStatus(HomematicipGenericDevice): - """Representation of an HomeMaticIP Cloud access point.""" +class HomematicipAccesspointStatus(HomematicipGenericEntity): + """Representation of then HomeMaticIP access point.""" def __init__(self, hap: HomematicipHAP) -> None: - """Initialize access point device.""" + """Initialize access point status entity.""" super().__init__(hap, hap.home) @property @@ -140,7 +140,7 @@ class HomematicipAccesspointStatus(HomematicipGenericDevice): @property def icon(self) -> str: - """Return the icon of the access point device.""" + """Return the icon of the access point entity.""" return "mdi:access-point-network" @property @@ -150,7 +150,7 @@ class HomematicipAccesspointStatus(HomematicipGenericDevice): @property def available(self) -> bool: - """Device available.""" + """Return if access point is available.""" return self._home.connected @property @@ -169,8 +169,8 @@ class HomematicipAccesspointStatus(HomematicipGenericDevice): return state_attr -class HomematicipHeatingThermostat(HomematicipGenericDevice): - """Representation of a HomematicIP heating thermostat device.""" +class HomematicipHeatingThermostat(HomematicipGenericEntity): + """Representation of the HomematicIP heating thermostat.""" def __init__(self, hap: HomematicipHAP, device) -> None: """Initialize heating thermostat device.""" @@ -198,8 +198,8 @@ class HomematicipHeatingThermostat(HomematicipGenericDevice): return UNIT_PERCENTAGE -class HomematicipHumiditySensor(HomematicipGenericDevice): - """Representation of a HomematicIP Cloud humidity device.""" +class HomematicipHumiditySensor(HomematicipGenericEntity): + """Representation of the HomematicIP humidity sensor.""" def __init__(self, hap: HomematicipHAP, device) -> None: """Initialize the thermometer device.""" @@ -221,8 +221,8 @@ class HomematicipHumiditySensor(HomematicipGenericDevice): return UNIT_PERCENTAGE -class HomematicipTemperatureSensor(HomematicipGenericDevice): - """Representation of a HomematicIP Cloud thermometer device.""" +class HomematicipTemperatureSensor(HomematicipGenericEntity): + """Representation of the HomematicIP thermometer.""" def __init__(self, hap: HomematicipHAP, device) -> None: """Initialize the thermometer device.""" @@ -258,8 +258,8 @@ class HomematicipTemperatureSensor(HomematicipGenericDevice): return state_attr -class HomematicipIlluminanceSensor(HomematicipGenericDevice): - """Representation of a HomematicIP Illuminance device.""" +class HomematicipIlluminanceSensor(HomematicipGenericEntity): + """Representation of the HomematicIP Illuminance sensor.""" def __init__(self, hap: HomematicipHAP, device) -> None: """Initialize the device.""" @@ -296,8 +296,8 @@ class HomematicipIlluminanceSensor(HomematicipGenericDevice): return state_attr -class HomematicipPowerSensor(HomematicipGenericDevice): - """Representation of a HomematicIP power measuring device.""" +class HomematicipPowerSensor(HomematicipGenericEntity): + """Representation of the HomematicIP power measuring sensor.""" def __init__(self, hap: HomematicipHAP, device) -> None: """Initialize the device.""" @@ -310,7 +310,7 @@ class HomematicipPowerSensor(HomematicipGenericDevice): @property def state(self) -> float: - """Representation of the HomematicIP power consumption value.""" + """Return the power consumption value.""" return self._device.currentPowerConsumption @property @@ -319,16 +319,16 @@ class HomematicipPowerSensor(HomematicipGenericDevice): return POWER_WATT -class HomematicipWindspeedSensor(HomematicipGenericDevice): - """Representation of a HomematicIP wind speed sensor.""" +class HomematicipWindspeedSensor(HomematicipGenericEntity): + """Representation of the HomematicIP wind speed sensor.""" def __init__(self, hap: HomematicipHAP, device) -> None: - """Initialize the device.""" + """Initialize the windspeed sensor.""" super().__init__(hap, device, "Windspeed") @property def state(self) -> float: - """Representation of the HomematicIP wind speed value.""" + """Return the wind speed value.""" return self._device.windSpeed @property @@ -352,8 +352,8 @@ class HomematicipWindspeedSensor(HomematicipGenericDevice): return state_attr -class HomematicipTodayRainSensor(HomematicipGenericDevice): - """Representation of a HomematicIP rain counter of a day sensor.""" +class HomematicipTodayRainSensor(HomematicipGenericEntity): + """Representation of the HomematicIP rain counter of a day sensor.""" def __init__(self, hap: HomematicipHAP, device) -> None: """Initialize the device.""" @@ -361,7 +361,7 @@ class HomematicipTodayRainSensor(HomematicipGenericDevice): @property def state(self) -> float: - """Representation of the HomematicIP today's rain value.""" + """Return the today's rain value.""" return round(self._device.todayRainCounter, 2) @property @@ -370,12 +370,12 @@ class HomematicipTodayRainSensor(HomematicipGenericDevice): return "mm" -class HomematicipPassageDetectorDeltaCounter(HomematicipGenericDevice): - """Representation of a HomematicIP passage detector delta counter.""" +class HomematicipPassageDetectorDeltaCounter(HomematicipGenericEntity): + """Representation of the HomematicIP passage detector delta counter.""" @property def state(self) -> int: - """Representation of the HomematicIP passage detector delta counter value.""" + """Return the passage detector delta counter value.""" return self._device.leftRightCounterDelta @property diff --git a/homeassistant/components/homematicip_cloud/switch.py b/homeassistant/components/homematicip_cloud/switch.py index a63602a6922..64ee862b2d2 100644 --- a/homeassistant/components/homematicip_cloud/switch.py +++ b/homeassistant/components/homematicip_cloud/switch.py @@ -20,8 +20,8 @@ from homeassistant.components.switch import SwitchEntity from homeassistant.config_entries import ConfigEntry from homeassistant.helpers.typing import HomeAssistantType -from . import DOMAIN as HMIPC_DOMAIN, HomematicipGenericDevice -from .device import ATTR_GROUP_MEMBER_UNREACHABLE +from . import DOMAIN as HMIPC_DOMAIN, HomematicipGenericEntity +from .generic_entity import ATTR_GROUP_MEMBER_UNREACHABLE from .hap import HomematicipHAP _LOGGER = logging.getLogger(__name__) @@ -36,7 +36,7 @@ async def async_setup_entry( for device in hap.home.devices: if isinstance(device, AsyncBrandSwitchMeasuring): # BrandSwitchMeasuring inherits PlugableSwitchMeasuring - # This device 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 pass elif isinstance( @@ -73,8 +73,8 @@ async def async_setup_entry( async_add_entities(entities) -class HomematicipSwitch(HomematicipGenericDevice, SwitchEntity): - """representation of a HomematicIP Cloud switch device.""" +class HomematicipSwitch(HomematicipGenericEntity, SwitchEntity): + """Representation of the HomematicIP switch.""" def __init__(self, hap: HomematicipHAP, device) -> None: """Initialize the switch device.""" @@ -94,8 +94,8 @@ class HomematicipSwitch(HomematicipGenericDevice, SwitchEntity): await self._device.turn_off() -class HomematicipGroupSwitch(HomematicipGenericDevice, SwitchEntity): - """representation of a HomematicIP switching group.""" +class HomematicipGroupSwitch(HomematicipGenericEntity, SwitchEntity): + """Representation of the HomematicIP switching group.""" def __init__(self, hap: HomematicipHAP, device, post: str = "Group") -> None: """Initialize switching group.""" @@ -136,7 +136,7 @@ class HomematicipGroupSwitch(HomematicipGenericDevice, SwitchEntity): class HomematicipSwitchMeasuring(HomematicipSwitch): - """Representation of a HomematicIP measuring switch device.""" + """Representation of the HomematicIP measuring switch.""" @property def current_power_w(self) -> float: @@ -151,8 +151,8 @@ class HomematicipSwitchMeasuring(HomematicipSwitch): return round(self._device.energyCounter) -class HomematicipMultiSwitch(HomematicipGenericDevice, SwitchEntity): - """Representation of a HomematicIP Cloud multi switch device.""" +class HomematicipMultiSwitch(HomematicipGenericEntity, SwitchEntity): + """Representation of the HomematicIP multi switch.""" def __init__(self, hap: HomematicipHAP, device, channel: int) -> None: """Initialize the multi switch device.""" @@ -174,13 +174,13 @@ class HomematicipMultiSwitch(HomematicipGenericDevice, SwitchEntity): @property def is_on(self) -> bool: - """Return true if device is on.""" + """Return true if switch is on.""" return self._device.functionalChannels[self.channel].on async def async_turn_on(self, **kwargs) -> None: - """Turn the device on.""" + """Turn the switch on.""" await self._device.turn_on(self.channel) async def async_turn_off(self, **kwargs) -> None: - """Turn the device off.""" + """Turn the switch off.""" await self._device.turn_off(self.channel) diff --git a/homeassistant/components/homematicip_cloud/weather.py b/homeassistant/components/homematicip_cloud/weather.py index 04f3b06cbb0..c845343c030 100644 --- a/homeassistant/components/homematicip_cloud/weather.py +++ b/homeassistant/components/homematicip_cloud/weather.py @@ -13,7 +13,7 @@ from homeassistant.config_entries import ConfigEntry from homeassistant.const import TEMP_CELSIUS from homeassistant.helpers.typing import HomeAssistantType -from . import DOMAIN as HMIPC_DOMAIN, HomematicipGenericDevice +from . import DOMAIN as HMIPC_DOMAIN, HomematicipGenericEntity from .hap import HomematicipHAP _LOGGER = logging.getLogger(__name__) @@ -55,8 +55,8 @@ async def async_setup_entry( async_add_entities(entities) -class HomematicipWeatherSensor(HomematicipGenericDevice, WeatherEntity): - """representation of a HomematicIP Cloud weather sensor plus & basic.""" +class HomematicipWeatherSensor(HomematicipGenericEntity, WeatherEntity): + """Representation of the HomematicIP weather sensor plus & basic.""" def __init__(self, hap: HomematicipHAP, device) -> None: """Initialize the weather sensor.""" @@ -105,7 +105,7 @@ class HomematicipWeatherSensor(HomematicipGenericDevice, WeatherEntity): class HomematicipWeatherSensorPro(HomematicipWeatherSensor): - """representation of a HomematicIP weather sensor pro.""" + """Representation of the HomematicIP weather sensor pro.""" @property def wind_bearing(self) -> float: @@ -113,8 +113,8 @@ class HomematicipWeatherSensorPro(HomematicipWeatherSensor): return self._device.windDirection -class HomematicipHomeWeather(HomematicipGenericDevice, WeatherEntity): - """representation of a HomematicIP Cloud home weather.""" +class HomematicipHomeWeather(HomematicipGenericEntity, WeatherEntity): + """Representation of the HomematicIP home weather.""" def __init__(self, hap: HomematicipHAP) -> None: """Initialize the home weather.""" @@ -123,7 +123,7 @@ class HomematicipHomeWeather(HomematicipGenericDevice, WeatherEntity): @property def available(self) -> bool: - """Device available.""" + """Return if weather entity is available.""" return self._home.connected @property @@ -133,7 +133,7 @@ class HomematicipHomeWeather(HomematicipGenericDevice, WeatherEntity): @property def temperature(self) -> float: - """Return the platform temperature.""" + """Return the temperature.""" return self._device.weather.temperature @property diff --git a/tests/components/homematicip_cloud/helper.py b/tests/components/homematicip_cloud/helper.py index fede095e57d..dbbf0249c0c 100644 --- a/tests/components/homematicip_cloud/helper.py +++ b/tests/components/homematicip_cloud/helper.py @@ -13,7 +13,7 @@ from homematicip.home import Home from homeassistant import config_entries from homeassistant.components.homematicip_cloud import DOMAIN as HMIPC_DOMAIN -from homeassistant.components.homematicip_cloud.device import ( +from homeassistant.components.homematicip_cloud.generic_entity import ( ATTR_IS_GROUP, ATTR_MODEL_TYPE, ) diff --git a/tests/components/homematicip_cloud/test_binary_sensor.py b/tests/components/homematicip_cloud/test_binary_sensor.py index 7fe9a7327ea..cfde3413916 100644 --- a/tests/components/homematicip_cloud/test_binary_sensor.py +++ b/tests/components/homematicip_cloud/test_binary_sensor.py @@ -15,7 +15,7 @@ from homeassistant.components.homematicip_cloud.binary_sensor import ( ATTR_WATER_LEVEL_DETECTED, ATTR_WINDOW_STATE, ) -from homeassistant.components.homematicip_cloud.device import ( +from homeassistant.components.homematicip_cloud.generic_entity import ( ATTR_EVENT_DELAY, ATTR_GROUP_MEMBER_UNREACHABLE, ATTR_LOW_BATTERY, diff --git a/tests/components/homematicip_cloud/test_sensor.py b/tests/components/homematicip_cloud/test_sensor.py index 61de66d916d..2cf7c8dff7b 100644 --- a/tests/components/homematicip_cloud/test_sensor.py +++ b/tests/components/homematicip_cloud/test_sensor.py @@ -2,7 +2,7 @@ from homematicip.base.enums import ValveState from homeassistant.components.homematicip_cloud import DOMAIN as HMIPC_DOMAIN -from homeassistant.components.homematicip_cloud.device import ( +from homeassistant.components.homematicip_cloud.generic_entity import ( ATTR_CONFIG_PENDING, ATTR_DEVICE_OVERHEATED, ATTR_DEVICE_OVERLOADED, diff --git a/tests/components/homematicip_cloud/test_switch.py b/tests/components/homematicip_cloud/test_switch.py index 59690458881..85bfaaa4ec5 100644 --- a/tests/components/homematicip_cloud/test_switch.py +++ b/tests/components/homematicip_cloud/test_switch.py @@ -1,6 +1,6 @@ """Tests for HomematicIP Cloud switch.""" from homeassistant.components.homematicip_cloud import DOMAIN as HMIPC_DOMAIN -from homeassistant.components.homematicip_cloud.device import ( +from homeassistant.components.homematicip_cloud.generic_entity import ( ATTR_GROUP_MEMBER_UNREACHABLE, ) from homeassistant.components.switch import (