From bdc90f74b7c505e8b1d0b00d8d7bc164b1e986ab Mon Sep 17 00:00:00 2001 From: Erik Date: Sat, 25 Apr 2020 09:12:43 +0200 Subject: [PATCH 1/2] Rename WaterHeaterDevice to WaterHeaterEntity --- homeassistant/components/demo/water_heater.py | 4 ++-- homeassistant/components/econet/water_heater.py | 4 ++-- homeassistant/components/evohome/water_heater.py | 4 ++-- homeassistant/components/geniushub/water_heater.py | 4 ++-- homeassistant/components/hive/water_heater.py | 4 ++-- homeassistant/components/incomfort/water_heater.py | 4 ++-- homeassistant/components/melcloud/water_heater.py | 4 ++-- homeassistant/components/tado/water_heater.py | 4 ++-- homeassistant/components/vicare/water_heater.py | 4 ++-- homeassistant/components/water_heater/__init__.py | 14 +++++++++++++- homeassistant/components/wink/water_heater.py | 4 ++-- tests/components/water_heater/test_init.py | 12 ++++++++++++ 12 files changed, 45 insertions(+), 21 deletions(-) create mode 100644 tests/components/water_heater/test_init.py diff --git a/homeassistant/components/demo/water_heater.py b/homeassistant/components/demo/water_heater.py index f9aca14124565..0b96bbf75f857 100644 --- a/homeassistant/components/demo/water_heater.py +++ b/homeassistant/components/demo/water_heater.py @@ -3,7 +3,7 @@ SUPPORT_AWAY_MODE, SUPPORT_OPERATION_MODE, SUPPORT_TARGET_TEMPERATURE, - WaterHeaterDevice, + WaterHeaterEntity, ) from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS, TEMP_FAHRENHEIT @@ -27,7 +27,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities): await async_setup_platform(hass, {}, async_add_entities) -class DemoWaterHeater(WaterHeaterDevice): +class DemoWaterHeater(WaterHeaterEntity): """Representation of a demo water_heater device.""" def __init__( diff --git a/homeassistant/components/econet/water_heater.py b/homeassistant/components/econet/water_heater.py index 59afe1351f55a..0c31e3e50e0ba 100644 --- a/homeassistant/components/econet/water_heater.py +++ b/homeassistant/components/econet/water_heater.py @@ -16,7 +16,7 @@ STATE_PERFORMANCE, SUPPORT_OPERATION_MODE, SUPPORT_TARGET_TEMPERATURE, - WaterHeaterDevice, + WaterHeaterEntity, ) from homeassistant.const import ( ATTR_ENTITY_ID, @@ -120,7 +120,7 @@ def service_handle(service): ) -class EcoNetWaterHeater(WaterHeaterDevice): +class EcoNetWaterHeater(WaterHeaterEntity): """Representation of an EcoNet water heater.""" def __init__(self, water_heater): diff --git a/homeassistant/components/evohome/water_heater.py b/homeassistant/components/evohome/water_heater.py index 20aa0710d0de2..846c8c0915532 100644 --- a/homeassistant/components/evohome/water_heater.py +++ b/homeassistant/components/evohome/water_heater.py @@ -5,7 +5,7 @@ from homeassistant.components.water_heater import ( SUPPORT_AWAY_MODE, SUPPORT_OPERATION_MODE, - WaterHeaterDevice, + WaterHeaterEntity, ) from homeassistant.const import PRECISION_TENTHS, PRECISION_WHOLE, STATE_OFF, STATE_ON from homeassistant.helpers.typing import ConfigType, HomeAssistantType @@ -43,7 +43,7 @@ async def async_setup_platform( async_add_entities([new_entity], update_before_add=True) -class EvoDHW(EvoChild, WaterHeaterDevice): +class EvoDHW(EvoChild, WaterHeaterEntity): """Base for a Honeywell TCC DHW controller (aka boiler).""" def __init__(self, evo_broker, evo_device) -> None: diff --git a/homeassistant/components/geniushub/water_heater.py b/homeassistant/components/geniushub/water_heater.py index e7e3278eaf6c1..51fdce4a6d7c5 100644 --- a/homeassistant/components/geniushub/water_heater.py +++ b/homeassistant/components/geniushub/water_heater.py @@ -4,7 +4,7 @@ from homeassistant.components.water_heater import ( SUPPORT_OPERATION_MODE, SUPPORT_TARGET_TEMPERATURE, - WaterHeaterDevice, + WaterHeaterEntity, ) from homeassistant.const import STATE_OFF from homeassistant.helpers.typing import ConfigType, HomeAssistantType @@ -49,7 +49,7 @@ async def async_setup_platform( ) -class GeniusWaterHeater(GeniusHeatingZone, WaterHeaterDevice): +class GeniusWaterHeater(GeniusHeatingZone, WaterHeaterEntity): """Representation of a Genius Hub water_heater device.""" def __init__(self, broker, zone) -> None: diff --git a/homeassistant/components/hive/water_heater.py b/homeassistant/components/hive/water_heater.py index d7d98426df5ea..693fd6f322b8e 100644 --- a/homeassistant/components/hive/water_heater.py +++ b/homeassistant/components/hive/water_heater.py @@ -4,7 +4,7 @@ STATE_OFF, STATE_ON, SUPPORT_OPERATION_MODE, - WaterHeaterDevice, + WaterHeaterEntity, ) from homeassistant.const import TEMP_CELSIUS @@ -29,7 +29,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(devs) -class HiveWaterHeater(HiveEntity, WaterHeaterDevice): +class HiveWaterHeater(HiveEntity, WaterHeaterEntity): """Hive Water Heater Device.""" @property diff --git a/homeassistant/components/incomfort/water_heater.py b/homeassistant/components/incomfort/water_heater.py index 88370acf1665f..da6e6d893150a 100644 --- a/homeassistant/components/incomfort/water_heater.py +++ b/homeassistant/components/incomfort/water_heater.py @@ -7,7 +7,7 @@ from homeassistant.components.water_heater import ( DOMAIN as WATER_HEATER_DOMAIN, - WaterHeaterDevice, + WaterHeaterEntity, ) from homeassistant.const import TEMP_CELSIUS from homeassistant.helpers.dispatcher import async_dispatcher_send @@ -30,7 +30,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= async_add_entities([IncomfortWaterHeater(client, h) for h in heaters]) -class IncomfortWaterHeater(IncomfortEntity, WaterHeaterDevice): +class IncomfortWaterHeater(IncomfortEntity, WaterHeaterEntity): """Representation of an InComfort/Intouch water_heater device.""" def __init__(self, client, heater) -> None: diff --git a/homeassistant/components/melcloud/water_heater.py b/homeassistant/components/melcloud/water_heater.py index fa7aff2b64009..fc4167c9af9c0 100644 --- a/homeassistant/components/melcloud/water_heater.py +++ b/homeassistant/components/melcloud/water_heater.py @@ -11,7 +11,7 @@ from homeassistant.components.water_heater import ( SUPPORT_OPERATION_MODE, SUPPORT_TARGET_TEMPERATURE, - WaterHeaterDevice, + WaterHeaterEntity, ) from homeassistant.config_entries import ConfigEntry from homeassistant.const import TEMP_CELSIUS @@ -35,7 +35,7 @@ async def async_setup_entry( ) -class AtwWaterHeater(WaterHeaterDevice): +class AtwWaterHeater(WaterHeaterEntity): """Air-to-Water water heater.""" def __init__(self, api: MelCloudDevice, device: AtwDevice) -> None: diff --git a/homeassistant/components/tado/water_heater.py b/homeassistant/components/tado/water_heater.py index aeb2d1ee10667..1c0d37c90df00 100644 --- a/homeassistant/components/tado/water_heater.py +++ b/homeassistant/components/tado/water_heater.py @@ -4,7 +4,7 @@ from homeassistant.components.water_heater import ( SUPPORT_OPERATION_MODE, SUPPORT_TARGET_TEMPERATURE, - WaterHeaterDevice, + WaterHeaterEntity, ) from homeassistant.config_entries import ConfigEntry from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS @@ -98,7 +98,7 @@ def create_water_heater_entity(tado, name: str, zone_id: int, zone: str): return entity -class TadoWaterHeater(TadoZoneEntity, WaterHeaterDevice): +class TadoWaterHeater(TadoZoneEntity, WaterHeaterEntity): """Representation of a Tado water heater.""" def __init__( diff --git a/homeassistant/components/vicare/water_heater.py b/homeassistant/components/vicare/water_heater.py index eea3d81faf6a0..c6aa5205f2478 100644 --- a/homeassistant/components/vicare/water_heater.py +++ b/homeassistant/components/vicare/water_heater.py @@ -5,7 +5,7 @@ from homeassistant.components.water_heater import ( SUPPORT_TARGET_TEMPERATURE, - WaterHeaterDevice, + WaterHeaterEntity, ) from homeassistant.const import ATTR_TEMPERATURE, PRECISION_WHOLE, TEMP_CELSIUS @@ -60,7 +60,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): ) -class ViCareWater(WaterHeaterDevice): +class ViCareWater(WaterHeaterEntity): """Representation of the ViCare domestic hot water device.""" def __init__(self, name, api, heating_type): diff --git a/homeassistant/components/water_heater/__init__.py b/homeassistant/components/water_heater/__init__.py index 4de0a58a881ea..e92a9a12429da 100644 --- a/homeassistant/components/water_heater/__init__.py +++ b/homeassistant/components/water_heater/__init__.py @@ -128,7 +128,7 @@ async def async_unload_entry(hass, entry): return await hass.data[DOMAIN].async_unload_entry(entry) -class WaterHeaterDevice(Entity): +class WaterHeaterEntity(Entity): """Representation of a water_heater device.""" @property @@ -319,3 +319,15 @@ async def async_service_temperature_set(entity, service): kwargs[value] = temp await entity.async_set_temperature(**kwargs) + + +class WaterHeaterDevice(WaterHeaterEntity): + """Representation of a remote (for backwards compatibility).""" + + def __init_subclass__(cls, **kwargs): + """Print deprecation warning.""" + super().__init_subclass__(**kwargs) + _LOGGER.warning( + "WaterHeaterDevice is deprecated, modify %s to extend WaterHeaterEntity", + cls.__name__, + ) diff --git a/homeassistant/components/wink/water_heater.py b/homeassistant/components/wink/water_heater.py index dae6acf91bf97..0ce31762c7a65 100644 --- a/homeassistant/components/wink/water_heater.py +++ b/homeassistant/components/wink/water_heater.py @@ -14,7 +14,7 @@ SUPPORT_AWAY_MODE, SUPPORT_OPERATION_MODE, SUPPORT_TARGET_TEMPERATURE, - WaterHeaterDevice, + WaterHeaterEntity, ) from homeassistant.const import STATE_OFF, STATE_UNKNOWN, TEMP_CELSIUS @@ -51,7 +51,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities([WinkWaterHeater(water_heater, hass)]) -class WinkWaterHeater(WinkDevice, WaterHeaterDevice): +class WinkWaterHeater(WinkDevice, WaterHeaterEntity): """Representation of a Wink water heater.""" @property diff --git a/tests/components/water_heater/test_init.py b/tests/components/water_heater/test_init.py new file mode 100644 index 0000000000000..967e8b03620d9 --- /dev/null +++ b/tests/components/water_heater/test_init.py @@ -0,0 +1,12 @@ +"""Tests for Water heater.""" +from homeassistant.components import water_heater + + +def test_deprecated_base_class(caplog): + """Test deprecated base class.""" + + class CustomWaterHeater(water_heater.WaterHeaterDevice): + pass + + CustomWaterHeater() + assert "WaterHeaterDevice is deprecated, modify CustomWaterHeater" in caplog.text From f3c36e5a125c24e723ce24b97c8a5fe8be4502bb Mon Sep 17 00:00:00 2001 From: Martin Hjelmare Date: Sun, 26 Apr 2020 02:14:30 +0200 Subject: [PATCH 2/2] Fix stale name --- homeassistant/components/water_heater/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/components/water_heater/__init__.py b/homeassistant/components/water_heater/__init__.py index e92a9a12429da..0763c55207511 100644 --- a/homeassistant/components/water_heater/__init__.py +++ b/homeassistant/components/water_heater/__init__.py @@ -322,7 +322,7 @@ async def async_service_temperature_set(entity, service): class WaterHeaterDevice(WaterHeaterEntity): - """Representation of a remote (for backwards compatibility).""" + """Representation of a water heater (for backwards compatibility).""" def __init_subclass__(cls, **kwargs): """Print deprecation warning."""