Remove deprecated base entity classes (#61006)
* Remove deprecated base entity classes * Clean up tests
This commit is contained in:
parent
21c09d1a3e
commit
cf371ea8dd
22 changed files with 2 additions and 279 deletions
|
@ -217,15 +217,3 @@ class AlarmControlPanelEntity(Entity):
|
||||||
ATTR_CHANGED_BY: self.changed_by,
|
ATTR_CHANGED_BY: self.changed_by,
|
||||||
ATTR_CODE_ARM_REQUIRED: self.code_arm_required,
|
ATTR_CODE_ARM_REQUIRED: self.code_arm_required,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class AlarmControlPanel(AlarmControlPanelEntity):
|
|
||||||
"""An abstract class for alarm control entities (for backwards compatibility)."""
|
|
||||||
|
|
||||||
def __init_subclass__(cls, **kwargs: Any) -> None:
|
|
||||||
"""Print deprecation warning."""
|
|
||||||
super().__init_subclass__(**kwargs) # type: ignore[call-arg]
|
|
||||||
_LOGGER.warning(
|
|
||||||
"AlarmControlPanel is deprecated, modify %s to extend AlarmControlPanelEntity",
|
|
||||||
cls.__name__,
|
|
||||||
)
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ from __future__ import annotations
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
from typing import Any, final
|
from typing import final
|
||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
|
@ -203,15 +203,3 @@ class BinarySensorEntity(Entity):
|
||||||
def state(self) -> StateType:
|
def state(self) -> StateType:
|
||||||
"""Return the state of the binary sensor."""
|
"""Return the state of the binary sensor."""
|
||||||
return STATE_ON if self.is_on else STATE_OFF
|
return STATE_ON if self.is_on else STATE_OFF
|
||||||
|
|
||||||
|
|
||||||
class BinarySensorDevice(BinarySensorEntity):
|
|
||||||
"""Represent a binary sensor (for backwards compatibility)."""
|
|
||||||
|
|
||||||
def __init_subclass__(cls, **kwargs: Any):
|
|
||||||
"""Print deprecation warning."""
|
|
||||||
super().__init_subclass__(**kwargs) # type: ignore[call-arg]
|
|
||||||
_LOGGER.warning(
|
|
||||||
"BinarySensorDevice is deprecated, modify %s to extend BinarySensorEntity",
|
|
||||||
cls.__name__,
|
|
||||||
)
|
|
||||||
|
|
|
@ -584,15 +584,3 @@ async def async_service_temperature_set(
|
||||||
kwargs[value] = temp
|
kwargs[value] = temp
|
||||||
|
|
||||||
await entity.async_set_temperature(**kwargs)
|
await entity.async_set_temperature(**kwargs)
|
||||||
|
|
||||||
|
|
||||||
class ClimateDevice(ClimateEntity):
|
|
||||||
"""Representation of a climate entity (for backwards compatibility)."""
|
|
||||||
|
|
||||||
def __init_subclass__(cls, **kwargs):
|
|
||||||
"""Print deprecation warning."""
|
|
||||||
super().__init_subclass__(**kwargs)
|
|
||||||
_LOGGER.warning(
|
|
||||||
"ClimateDevice is deprecated, modify %s to extend ClimateEntity",
|
|
||||||
cls.__name__,
|
|
||||||
)
|
|
||||||
|
|
|
@ -403,15 +403,3 @@ class CoverEntity(Entity):
|
||||||
if self._cover_is_last_toggle_direction_open:
|
if self._cover_is_last_toggle_direction_open:
|
||||||
return fns["close"]
|
return fns["close"]
|
||||||
return fns["open"]
|
return fns["open"]
|
||||||
|
|
||||||
|
|
||||||
class CoverDevice(CoverEntity):
|
|
||||||
"""Representation of a cover (for backwards compatibility)."""
|
|
||||||
|
|
||||||
def __init_subclass__(cls, **kwargs):
|
|
||||||
"""Print deprecation warning."""
|
|
||||||
super().__init_subclass__(**kwargs)
|
|
||||||
_LOGGER.warning(
|
|
||||||
"CoverDevice is deprecated, modify %s to extend CoverEntity",
|
|
||||||
cls.__name__,
|
|
||||||
)
|
|
||||||
|
|
|
@ -958,18 +958,6 @@ class LightEntity(ToggleEntity):
|
||||||
return self._attr_supported_features
|
return self._attr_supported_features
|
||||||
|
|
||||||
|
|
||||||
class Light(LightEntity):
|
|
||||||
"""Representation of a light (for backwards compatibility)."""
|
|
||||||
|
|
||||||
def __init_subclass__(cls, **kwargs):
|
|
||||||
"""Print deprecation warning."""
|
|
||||||
super().__init_subclass__(**kwargs)
|
|
||||||
_LOGGER.warning(
|
|
||||||
"Light is deprecated, modify %s to extend LightEntity",
|
|
||||||
cls.__name__,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def legacy_supported_features(
|
def legacy_supported_features(
|
||||||
supported_features: int, supported_color_modes: list[str] | None
|
supported_features: int, supported_color_modes: list[str] | None
|
||||||
) -> int:
|
) -> int:
|
||||||
|
|
|
@ -179,15 +179,3 @@ class LockEntity(Entity):
|
||||||
if (locked := self.is_locked) is None:
|
if (locked := self.is_locked) is None:
|
||||||
return None
|
return None
|
||||||
return STATE_LOCKED if locked else STATE_UNLOCKED
|
return STATE_LOCKED if locked else STATE_UNLOCKED
|
||||||
|
|
||||||
|
|
||||||
class LockDevice(LockEntity):
|
|
||||||
"""Representation of a lock (for backwards compatibility)."""
|
|
||||||
|
|
||||||
def __init_subclass__(cls, **kwargs: Any):
|
|
||||||
"""Print deprecation warning."""
|
|
||||||
super().__init_subclass__(**kwargs) # type: ignore[call-arg]
|
|
||||||
_LOGGER.warning(
|
|
||||||
"LockDevice is deprecated, modify %s to extend LockEntity",
|
|
||||||
cls.__name__,
|
|
||||||
)
|
|
||||||
|
|
|
@ -1147,7 +1147,7 @@ async def websocket_browse_media(hass, connection, msg):
|
||||||
To use, media_player integrations can implement MediaPlayerEntity.async_browse_media()
|
To use, media_player integrations can implement MediaPlayerEntity.async_browse_media()
|
||||||
"""
|
"""
|
||||||
component = hass.data[DOMAIN]
|
component = hass.data[DOMAIN]
|
||||||
player: MediaPlayerDevice | None = component.get_entity(msg["entity_id"])
|
player: MediaPlayerEntity | None = component.get_entity(msg["entity_id"])
|
||||||
|
|
||||||
if player is None:
|
if player is None:
|
||||||
connection.send_error(msg["id"], "entity_not_found", "Entity not found")
|
connection.send_error(msg["id"], "entity_not_found", "Entity not found")
|
||||||
|
@ -1195,18 +1195,6 @@ async def websocket_browse_media(hass, connection, msg):
|
||||||
connection.send_result(msg["id"], payload)
|
connection.send_result(msg["id"], payload)
|
||||||
|
|
||||||
|
|
||||||
class MediaPlayerDevice(MediaPlayerEntity):
|
|
||||||
"""ABC for media player devices (for backwards compatibility)."""
|
|
||||||
|
|
||||||
def __init_subclass__(cls, **kwargs):
|
|
||||||
"""Print deprecation warning."""
|
|
||||||
super().__init_subclass__(**kwargs)
|
|
||||||
_LOGGER.warning(
|
|
||||||
"MediaPlayerDevice is deprecated, modify %s to extend MediaPlayerEntity",
|
|
||||||
cls.__name__,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class BrowseMedia:
|
class BrowseMedia:
|
||||||
"""Represent a browsable media file."""
|
"""Represent a browsable media file."""
|
||||||
|
|
||||||
|
|
|
@ -210,15 +210,3 @@ class RemoteEntity(ToggleEntity):
|
||||||
await self.hass.async_add_executor_job(
|
await self.hass.async_add_executor_job(
|
||||||
ft.partial(self.delete_command, **kwargs)
|
ft.partial(self.delete_command, **kwargs)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class RemoteDevice(RemoteEntity):
|
|
||||||
"""Representation of a remote (for backwards compatibility)."""
|
|
||||||
|
|
||||||
def __init_subclass__(cls, **kwargs):
|
|
||||||
"""Print deprecation warning."""
|
|
||||||
super().__init_subclass__(**kwargs)
|
|
||||||
_LOGGER.warning(
|
|
||||||
"RemoteDevice is deprecated, modify %s to extend RemoteEntity",
|
|
||||||
cls.__name__,
|
|
||||||
)
|
|
||||||
|
|
|
@ -140,15 +140,3 @@ class SwitchEntity(ToggleEntity):
|
||||||
data[attr] = value
|
data[attr] = value
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
||||||
class SwitchDevice(SwitchEntity):
|
|
||||||
"""Representation of a switch (for backwards compatibility)."""
|
|
||||||
|
|
||||||
def __init_subclass__(cls, **kwargs: Any) -> None:
|
|
||||||
"""Print deprecation warning."""
|
|
||||||
super().__init_subclass__(**kwargs) # type: ignore[call-arg]
|
|
||||||
_LOGGER.warning(
|
|
||||||
"SwitchDevice is deprecated, modify %s to extend SwitchEntity",
|
|
||||||
cls.__name__,
|
|
||||||
)
|
|
||||||
|
|
|
@ -341,17 +341,6 @@ class VacuumEntity(_BaseVacuum, ToggleEntity):
|
||||||
"""Not supported."""
|
"""Not supported."""
|
||||||
|
|
||||||
|
|
||||||
class VacuumDevice(VacuumEntity):
|
|
||||||
"""Representation of a vacuum (for backwards compatibility)."""
|
|
||||||
|
|
||||||
def __init_subclass__(cls, **kwargs):
|
|
||||||
"""Print deprecation warning."""
|
|
||||||
super().__init_subclass__(**kwargs)
|
|
||||||
_LOGGER.warning(
|
|
||||||
"VacuumDevice is deprecated, modify %s to extend VacuumEntity", cls.__name__
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class StateVacuumEntityDescription(EntityDescription):
|
class StateVacuumEntityDescription(EntityDescription):
|
||||||
"""A class that describes vacuum entities."""
|
"""A class that describes vacuum entities."""
|
||||||
|
@ -406,15 +395,3 @@ class StateVacuumEntity(_BaseVacuum):
|
||||||
|
|
||||||
async def async_toggle(self, **kwargs):
|
async def async_toggle(self, **kwargs):
|
||||||
"""Not supported."""
|
"""Not supported."""
|
||||||
|
|
||||||
|
|
||||||
class StateVacuumDevice(StateVacuumEntity):
|
|
||||||
"""Representation of a vacuum (for backwards compatibility)."""
|
|
||||||
|
|
||||||
def __init_subclass__(cls, **kwargs):
|
|
||||||
"""Print deprecation warning."""
|
|
||||||
super().__init_subclass__(**kwargs)
|
|
||||||
_LOGGER.warning(
|
|
||||||
"StateVacuumDevice is deprecated, modify %s to extend StateVacuumEntity",
|
|
||||||
cls.__name__,
|
|
||||||
)
|
|
||||||
|
|
|
@ -350,15 +350,3 @@ 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__,
|
|
||||||
)
|
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
"""Tests for Alarm control panel."""
|
|
||||||
from homeassistant.components import alarm_control_panel
|
|
||||||
|
|
||||||
|
|
||||||
def test_deprecated_base_class(caplog):
|
|
||||||
"""Test deprecated base class."""
|
|
||||||
|
|
||||||
class CustomAlarm(alarm_control_panel.AlarmControlPanel):
|
|
||||||
def supported_features(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
CustomAlarm()
|
|
||||||
assert "AlarmControlPanel is deprecated, modify CustomAlarm" in caplog.text
|
|
|
@ -19,13 +19,3 @@ def test_state():
|
||||||
new=True,
|
new=True,
|
||||||
):
|
):
|
||||||
assert binary_sensor.BinarySensorEntity().state == STATE_ON
|
assert binary_sensor.BinarySensorEntity().state == STATE_ON
|
||||||
|
|
||||||
|
|
||||||
def test_deprecated_base_class(caplog):
|
|
||||||
"""Test deprecated base class."""
|
|
||||||
|
|
||||||
class CustomBinarySensor(binary_sensor.BinarySensorDevice):
|
|
||||||
pass
|
|
||||||
|
|
||||||
CustomBinarySensor()
|
|
||||||
assert "BinarySensorDevice is deprecated, modify CustomBinarySensor" in caplog.text
|
|
||||||
|
|
|
@ -10,7 +10,6 @@ from homeassistant.components.climate import (
|
||||||
HVAC_MODE_HEAT,
|
HVAC_MODE_HEAT,
|
||||||
HVAC_MODE_OFF,
|
HVAC_MODE_OFF,
|
||||||
SET_TEMPERATURE_SCHEMA,
|
SET_TEMPERATURE_SCHEMA,
|
||||||
ClimateDevice,
|
|
||||||
ClimateEntity,
|
ClimateEntity,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -93,21 +92,3 @@ async def test_sync_turn_off(hass):
|
||||||
await climate.async_turn_off()
|
await climate.async_turn_off()
|
||||||
|
|
||||||
assert climate.turn_off.called
|
assert climate.turn_off.called
|
||||||
|
|
||||||
|
|
||||||
def test_deprecated_base_class(caplog):
|
|
||||||
"""Test deprecated base class."""
|
|
||||||
|
|
||||||
class CustomClimate(ClimateDevice):
|
|
||||||
"""Custom climate entity class."""
|
|
||||||
|
|
||||||
@property
|
|
||||||
def hvac_mode(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
@property
|
|
||||||
def hvac_modes(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
CustomClimate()
|
|
||||||
assert "ClimateDevice is deprecated, modify CustomClimate" in caplog.text
|
|
||||||
|
|
|
@ -111,13 +111,3 @@ def is_closed(hass, ent):
|
||||||
def is_closing(hass, ent):
|
def is_closing(hass, ent):
|
||||||
"""Return if the cover is closed based on the statemachine."""
|
"""Return if the cover is closed based on the statemachine."""
|
||||||
return hass.states.is_state(ent.entity_id, STATE_CLOSING)
|
return hass.states.is_state(ent.entity_id, STATE_CLOSING)
|
||||||
|
|
||||||
|
|
||||||
def test_deprecated_base_class(caplog):
|
|
||||||
"""Test deprecated base class."""
|
|
||||||
|
|
||||||
class CustomCover(cover.CoverDevice):
|
|
||||||
pass
|
|
||||||
|
|
||||||
CustomCover()
|
|
||||||
assert "CoverDevice is deprecated, modify CustomCover" in caplog.text
|
|
||||||
|
|
|
@ -898,16 +898,6 @@ async def test_light_brightness_pct_conversion(hass, enable_custom_integrations)
|
||||||
assert data["brightness"] == 255
|
assert data["brightness"] == 255
|
||||||
|
|
||||||
|
|
||||||
def test_deprecated_base_class(caplog):
|
|
||||||
"""Test deprecated base class."""
|
|
||||||
|
|
||||||
class CustomLight(light.Light):
|
|
||||||
pass
|
|
||||||
|
|
||||||
CustomLight()
|
|
||||||
assert "Light is deprecated, modify CustomLight" in caplog.text
|
|
||||||
|
|
||||||
|
|
||||||
async def test_profiles(hass):
|
async def test_profiles(hass):
|
||||||
"""Test profiles loading."""
|
"""Test profiles loading."""
|
||||||
profiles = orig_Profiles(hass)
|
profiles = orig_Profiles(hass)
|
||||||
|
|
|
@ -1,12 +0,0 @@
|
||||||
"""The tests for Lock."""
|
|
||||||
from homeassistant.components import lock
|
|
||||||
|
|
||||||
|
|
||||||
def test_deprecated_base_class(caplog):
|
|
||||||
"""Test deprecated base class."""
|
|
||||||
|
|
||||||
class CustomLock(lock.LockDevice):
|
|
||||||
pass
|
|
||||||
|
|
||||||
CustomLock()
|
|
||||||
assert "LockDevice is deprecated, modify CustomLock" in caplog.text
|
|
|
@ -119,16 +119,6 @@ async def test_get_async_get_browse_image(hass, hass_client_no_auth, hass_ws_cli
|
||||||
assert content == b"image"
|
assert content == b"image"
|
||||||
|
|
||||||
|
|
||||||
def test_deprecated_base_class(caplog):
|
|
||||||
"""Test deprecated base class."""
|
|
||||||
|
|
||||||
class CustomMediaPlayer(media_player.MediaPlayerDevice):
|
|
||||||
pass
|
|
||||||
|
|
||||||
CustomMediaPlayer()
|
|
||||||
assert "MediaPlayerDevice is deprecated, modify CustomMediaPlayer" in caplog.text
|
|
||||||
|
|
||||||
|
|
||||||
async def test_media_browse(hass, hass_ws_client):
|
async def test_media_browse(hass, hass_ws_client):
|
||||||
"""Test browsing media."""
|
"""Test browsing media."""
|
||||||
await async_setup_component(
|
await async_setup_component(
|
||||||
|
|
|
@ -139,13 +139,3 @@ async def test_delete_command(hass):
|
||||||
assert call.domain == remote.DOMAIN
|
assert call.domain == remote.DOMAIN
|
||||||
assert call.service == SERVICE_DELETE_COMMAND
|
assert call.service == SERVICE_DELETE_COMMAND
|
||||||
assert call.data[ATTR_ENTITY_ID] == ENTITY_ID
|
assert call.data[ATTR_ENTITY_ID] == ENTITY_ID
|
||||||
|
|
||||||
|
|
||||||
async def test_deprecated_base_class(caplog):
|
|
||||||
"""Test deprecated base class."""
|
|
||||||
|
|
||||||
class CustomRemote(remote.RemoteDevice):
|
|
||||||
pass
|
|
||||||
|
|
||||||
CustomRemote()
|
|
||||||
assert "RemoteDevice is deprecated, modify CustomRemote" in caplog.text
|
|
||||||
|
|
|
@ -72,13 +72,3 @@ async def test_switch_context(
|
||||||
assert state2 is not None
|
assert state2 is not None
|
||||||
assert state.state != state2.state
|
assert state.state != state2.state
|
||||||
assert state2.context.user_id == hass_admin_user.id
|
assert state2.context.user_id == hass_admin_user.id
|
||||||
|
|
||||||
|
|
||||||
def test_deprecated_base_class(caplog):
|
|
||||||
"""Test deprecated base class."""
|
|
||||||
|
|
||||||
class CustomSwitch(switch.SwitchDevice):
|
|
||||||
pass
|
|
||||||
|
|
||||||
CustomSwitch()
|
|
||||||
assert "SwitchDevice is deprecated, modify CustomSwitch" in caplog.text
|
|
||||||
|
|
|
@ -1,18 +0,0 @@
|
||||||
"""The tests for Vacuum."""
|
|
||||||
from homeassistant.components import vacuum
|
|
||||||
|
|
||||||
|
|
||||||
def test_deprecated_base_class(caplog):
|
|
||||||
"""Test deprecated base class."""
|
|
||||||
|
|
||||||
class CustomVacuum(vacuum.VacuumDevice):
|
|
||||||
pass
|
|
||||||
|
|
||||||
class CustomStateVacuum(vacuum.StateVacuumDevice):
|
|
||||||
pass
|
|
||||||
|
|
||||||
CustomVacuum()
|
|
||||||
assert "VacuumDevice is deprecated, modify CustomVacuum" in caplog.text
|
|
||||||
|
|
||||||
CustomStateVacuum()
|
|
||||||
assert "StateVacuumDevice is deprecated, modify CustomStateVacuum" in caplog.text
|
|
|
@ -1,12 +0,0 @@
|
||||||
"""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
|
|
Loading…
Add table
Add a link
Reference in a new issue