Rename WaterHeaterDevice to WaterHeaterEntity (#34675)

* Rename WaterHeaterDevice to WaterHeaterEntity

* Fix stale name

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
This commit is contained in:
Erik Montnemery 2020-05-01 16:29:14 +02:00 committed by GitHub
parent 1cfa46d80b
commit f3d79104a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 45 additions and 21 deletions

View File

@ -3,7 +3,7 @@ from homeassistant.components.water_heater import (
SUPPORT_AWAY_MODE, SUPPORT_AWAY_MODE,
SUPPORT_OPERATION_MODE, SUPPORT_OPERATION_MODE,
SUPPORT_TARGET_TEMPERATURE, SUPPORT_TARGET_TEMPERATURE,
WaterHeaterDevice, WaterHeaterEntity,
) )
from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS, TEMP_FAHRENHEIT 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) await async_setup_platform(hass, {}, async_add_entities)
class DemoWaterHeater(WaterHeaterDevice): class DemoWaterHeater(WaterHeaterEntity):
"""Representation of a demo water_heater device.""" """Representation of a demo water_heater device."""
def __init__( def __init__(

View File

@ -16,7 +16,7 @@ from homeassistant.components.water_heater import (
STATE_PERFORMANCE, STATE_PERFORMANCE,
SUPPORT_OPERATION_MODE, SUPPORT_OPERATION_MODE,
SUPPORT_TARGET_TEMPERATURE, SUPPORT_TARGET_TEMPERATURE,
WaterHeaterDevice, WaterHeaterEntity,
) )
from homeassistant.const import ( from homeassistant.const import (
ATTR_ENTITY_ID, ATTR_ENTITY_ID,
@ -120,7 +120,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
) )
class EcoNetWaterHeater(WaterHeaterDevice): class EcoNetWaterHeater(WaterHeaterEntity):
"""Representation of an EcoNet water heater.""" """Representation of an EcoNet water heater."""
def __init__(self, water_heater): def __init__(self, water_heater):

View File

@ -5,7 +5,7 @@ from typing import List
from homeassistant.components.water_heater import ( from homeassistant.components.water_heater import (
SUPPORT_AWAY_MODE, SUPPORT_AWAY_MODE,
SUPPORT_OPERATION_MODE, SUPPORT_OPERATION_MODE,
WaterHeaterDevice, WaterHeaterEntity,
) )
from homeassistant.const import PRECISION_TENTHS, PRECISION_WHOLE, STATE_OFF, STATE_ON from homeassistant.const import PRECISION_TENTHS, PRECISION_WHOLE, STATE_OFF, STATE_ON
from homeassistant.helpers.typing import ConfigType, HomeAssistantType 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) 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).""" """Base for a Honeywell TCC DHW controller (aka boiler)."""
def __init__(self, evo_broker, evo_device) -> None: def __init__(self, evo_broker, evo_device) -> None:

View File

@ -4,7 +4,7 @@ from typing import List
from homeassistant.components.water_heater import ( from homeassistant.components.water_heater import (
SUPPORT_OPERATION_MODE, SUPPORT_OPERATION_MODE,
SUPPORT_TARGET_TEMPERATURE, SUPPORT_TARGET_TEMPERATURE,
WaterHeaterDevice, WaterHeaterEntity,
) )
from homeassistant.const import STATE_OFF from homeassistant.const import STATE_OFF
from homeassistant.helpers.typing import ConfigType, HomeAssistantType 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.""" """Representation of a Genius Hub water_heater device."""
def __init__(self, broker, zone) -> None: def __init__(self, broker, zone) -> None:

View File

@ -4,7 +4,7 @@ from homeassistant.components.water_heater import (
STATE_OFF, STATE_OFF,
STATE_ON, STATE_ON,
SUPPORT_OPERATION_MODE, SUPPORT_OPERATION_MODE,
WaterHeaterDevice, WaterHeaterEntity,
) )
from homeassistant.const import TEMP_CELSIUS from homeassistant.const import TEMP_CELSIUS
@ -29,7 +29,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
add_entities(devs) add_entities(devs)
class HiveWaterHeater(HiveEntity, WaterHeaterDevice): class HiveWaterHeater(HiveEntity, WaterHeaterEntity):
"""Hive Water Heater Device.""" """Hive Water Heater Device."""
@property @property

View File

@ -7,7 +7,7 @@ from aiohttp import ClientResponseError
from homeassistant.components.water_heater import ( from homeassistant.components.water_heater import (
DOMAIN as WATER_HEATER_DOMAIN, DOMAIN as WATER_HEATER_DOMAIN,
WaterHeaterDevice, WaterHeaterEntity,
) )
from homeassistant.const import TEMP_CELSIUS from homeassistant.const import TEMP_CELSIUS
from homeassistant.helpers.dispatcher import async_dispatcher_send 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]) 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.""" """Representation of an InComfort/Intouch water_heater device."""
def __init__(self, client, heater) -> None: def __init__(self, client, heater) -> None:

View File

@ -11,7 +11,7 @@ from pymelcloud.device import PROPERTY_POWER
from homeassistant.components.water_heater import ( from homeassistant.components.water_heater import (
SUPPORT_OPERATION_MODE, SUPPORT_OPERATION_MODE,
SUPPORT_TARGET_TEMPERATURE, SUPPORT_TARGET_TEMPERATURE,
WaterHeaterDevice, WaterHeaterEntity,
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import TEMP_CELSIUS 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.""" """Air-to-Water water heater."""
def __init__(self, api: MelCloudDevice, device: AtwDevice) -> None: def __init__(self, api: MelCloudDevice, device: AtwDevice) -> None:

View File

@ -4,7 +4,7 @@ import logging
from homeassistant.components.water_heater import ( from homeassistant.components.water_heater import (
SUPPORT_OPERATION_MODE, SUPPORT_OPERATION_MODE,
SUPPORT_TARGET_TEMPERATURE, SUPPORT_TARGET_TEMPERATURE,
WaterHeaterDevice, WaterHeaterEntity,
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS 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 return entity
class TadoWaterHeater(TadoZoneEntity, WaterHeaterDevice): class TadoWaterHeater(TadoZoneEntity, WaterHeaterEntity):
"""Representation of a Tado water heater.""" """Representation of a Tado water heater."""
def __init__( def __init__(

View File

@ -5,7 +5,7 @@ import requests
from homeassistant.components.water_heater import ( from homeassistant.components.water_heater import (
SUPPORT_TARGET_TEMPERATURE, SUPPORT_TARGET_TEMPERATURE,
WaterHeaterDevice, WaterHeaterEntity,
) )
from homeassistant.const import ATTR_TEMPERATURE, PRECISION_WHOLE, TEMP_CELSIUS 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.""" """Representation of the ViCare domestic hot water device."""
def __init__(self, name, api, heating_type): def __init__(self, name, api, heating_type):

View File

@ -128,7 +128,7 @@ async def async_unload_entry(hass, entry):
return await hass.data[DOMAIN].async_unload_entry(entry) return await hass.data[DOMAIN].async_unload_entry(entry)
class WaterHeaterDevice(Entity): class WaterHeaterEntity(Entity):
"""Representation of a water_heater device.""" """Representation of a water_heater device."""
@property @property
@ -319,3 +319,15 @@ async def async_service_temperature_set(entity, service):
kwargs[value] = temp kwargs[value] = temp
await entity.async_set_temperature(**kwargs) await entity.async_set_temperature(**kwargs)
class WaterHeaterDevice(WaterHeaterEntity):
"""Representation of a water heater (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__,
)

View File

@ -14,7 +14,7 @@ from homeassistant.components.water_heater import (
SUPPORT_AWAY_MODE, SUPPORT_AWAY_MODE,
SUPPORT_OPERATION_MODE, SUPPORT_OPERATION_MODE,
SUPPORT_TARGET_TEMPERATURE, SUPPORT_TARGET_TEMPERATURE,
WaterHeaterDevice, WaterHeaterEntity,
) )
from homeassistant.const import STATE_OFF, STATE_UNKNOWN, TEMP_CELSIUS 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)]) add_entities([WinkWaterHeater(water_heater, hass)])
class WinkWaterHeater(WinkDevice, WaterHeaterDevice): class WinkWaterHeater(WinkDevice, WaterHeaterEntity):
"""Representation of a Wink water heater.""" """Representation of a Wink water heater."""
@property @property

View File

@ -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