mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Remove deprecated supported features warning in FanEntity (#132369)
This commit is contained in:
parent
39abeb4600
commit
17afe1ae51
@ -46,7 +46,7 @@ class BAFFan(BAFEntity, FanEntity):
|
|||||||
| FanEntityFeature.TURN_OFF
|
| FanEntityFeature.TURN_OFF
|
||||||
| FanEntityFeature.TURN_ON
|
| FanEntityFeature.TURN_ON
|
||||||
)
|
)
|
||||||
_enable_turn_on_off_backwards_compatibility = False
|
|
||||||
_attr_preset_modes = [PRESET_MODE_AUTO]
|
_attr_preset_modes = [PRESET_MODE_AUTO]
|
||||||
_attr_speed_count = SPEED_COUNT
|
_attr_speed_count = SPEED_COUNT
|
||||||
_attr_name = None
|
_attr_name = None
|
||||||
|
@ -38,7 +38,7 @@ class BalboaPumpFanEntity(BalboaEntity, FanEntity):
|
|||||||
| FanEntityFeature.TURN_OFF
|
| FanEntityFeature.TURN_OFF
|
||||||
| FanEntityFeature.TURN_ON
|
| FanEntityFeature.TURN_ON
|
||||||
)
|
)
|
||||||
_enable_turn_on_off_backwards_compatibility = False
|
|
||||||
_attr_translation_key = "pump"
|
_attr_translation_key = "pump"
|
||||||
|
|
||||||
def __init__(self, control: SpaControl) -> None:
|
def __init__(self, control: SpaControl) -> None:
|
||||||
|
@ -68,7 +68,7 @@ class ComfoConnectFan(FanEntity):
|
|||||||
| FanEntityFeature.TURN_OFF
|
| FanEntityFeature.TURN_OFF
|
||||||
| FanEntityFeature.TURN_ON
|
| FanEntityFeature.TURN_ON
|
||||||
)
|
)
|
||||||
_enable_turn_on_off_backwards_compatibility = False
|
|
||||||
_attr_preset_modes = PRESET_MODES
|
_attr_preset_modes = PRESET_MODES
|
||||||
current_speed: float | None = None
|
current_speed: float | None = None
|
||||||
|
|
||||||
|
@ -65,7 +65,6 @@ class DeconzFan(DeconzDevice[Light], FanEntity):
|
|||||||
| FanEntityFeature.TURN_ON
|
| FanEntityFeature.TURN_ON
|
||||||
| FanEntityFeature.TURN_OFF
|
| FanEntityFeature.TURN_OFF
|
||||||
)
|
)
|
||||||
_enable_turn_on_off_backwards_compatibility = False
|
|
||||||
|
|
||||||
def __init__(self, device: Light, hub: DeconzHub) -> None:
|
def __init__(self, device: Light, hub: DeconzHub) -> None:
|
||||||
"""Set up fan."""
|
"""Set up fan."""
|
||||||
|
@ -100,7 +100,6 @@ class BaseDemoFan(FanEntity):
|
|||||||
|
|
||||||
_attr_should_poll = False
|
_attr_should_poll = False
|
||||||
_attr_translation_key = "demo"
|
_attr_translation_key = "demo"
|
||||||
_enable_turn_on_off_backwards_compatibility = False
|
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
|
@ -45,7 +45,6 @@ class EsphomeFan(EsphomeEntity[FanInfo, FanState], FanEntity):
|
|||||||
"""A fan implementation for ESPHome."""
|
"""A fan implementation for ESPHome."""
|
||||||
|
|
||||||
_supports_speed_levels: bool = True
|
_supports_speed_levels: bool = True
|
||||||
_enable_turn_on_off_backwards_compatibility = False
|
|
||||||
|
|
||||||
async def async_set_percentage(self, percentage: int) -> None:
|
async def async_set_percentage(self, percentage: int) -> None:
|
||||||
"""Set the speed percentage of the fan."""
|
"""Set the speed percentage of the fan."""
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import asyncio
|
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
from enum import IntFlag
|
from enum import IntFlag
|
||||||
import functools as ft
|
import functools as ft
|
||||||
@ -25,7 +24,6 @@ from homeassistant.exceptions import ServiceValidationError
|
|||||||
from homeassistant.helpers import config_validation as cv
|
from homeassistant.helpers import config_validation as cv
|
||||||
from homeassistant.helpers.entity import ToggleEntity, ToggleEntityDescription
|
from homeassistant.helpers.entity import ToggleEntity, ToggleEntityDescription
|
||||||
from homeassistant.helpers.entity_component import EntityComponent
|
from homeassistant.helpers.entity_component import EntityComponent
|
||||||
from homeassistant.helpers.entity_platform import EntityPlatform
|
|
||||||
from homeassistant.helpers.typing import ConfigType
|
from homeassistant.helpers.typing import ConfigType
|
||||||
from homeassistant.loader import bind_hass
|
from homeassistant.loader import bind_hass
|
||||||
from homeassistant.util.hass_dict import HassKey
|
from homeassistant.util.hass_dict import HassKey
|
||||||
@ -219,99 +217,6 @@ class FanEntity(ToggleEntity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_):
|
|||||||
_attr_speed_count: int = 100
|
_attr_speed_count: int = 100
|
||||||
_attr_supported_features: FanEntityFeature = FanEntityFeature(0)
|
_attr_supported_features: FanEntityFeature = FanEntityFeature(0)
|
||||||
|
|
||||||
__mod_supported_features: FanEntityFeature = FanEntityFeature(0)
|
|
||||||
# Integrations should set `_enable_turn_on_off_backwards_compatibility` to False
|
|
||||||
# once migrated and set the feature flags TURN_ON/TURN_OFF as needed.
|
|
||||||
_enable_turn_on_off_backwards_compatibility: bool = True
|
|
||||||
|
|
||||||
def __getattribute__(self, name: str, /) -> Any:
|
|
||||||
"""Get attribute.
|
|
||||||
|
|
||||||
Modify return of `supported_features` to
|
|
||||||
include `_mod_supported_features` if attribute is set.
|
|
||||||
"""
|
|
||||||
if name != "supported_features":
|
|
||||||
return super().__getattribute__(name)
|
|
||||||
|
|
||||||
# Convert the supported features to ClimateEntityFeature.
|
|
||||||
# Remove this compatibility shim in 2025.1 or later.
|
|
||||||
_supported_features: FanEntityFeature = super().__getattribute__(
|
|
||||||
"supported_features"
|
|
||||||
)
|
|
||||||
_mod_supported_features: FanEntityFeature = super().__getattribute__(
|
|
||||||
"_FanEntity__mod_supported_features"
|
|
||||||
)
|
|
||||||
if type(_supported_features) is int: # noqa: E721
|
|
||||||
_features = FanEntityFeature(_supported_features)
|
|
||||||
self._report_deprecated_supported_features_values(_features)
|
|
||||||
else:
|
|
||||||
_features = _supported_features
|
|
||||||
|
|
||||||
if not _mod_supported_features:
|
|
||||||
return _features
|
|
||||||
|
|
||||||
# Add automatically calculated FanEntityFeature.TURN_OFF/TURN_ON to
|
|
||||||
# supported features and return it
|
|
||||||
return _features | _mod_supported_features
|
|
||||||
|
|
||||||
@callback
|
|
||||||
def add_to_platform_start(
|
|
||||||
self,
|
|
||||||
hass: HomeAssistant,
|
|
||||||
platform: EntityPlatform,
|
|
||||||
parallel_updates: asyncio.Semaphore | None,
|
|
||||||
) -> None:
|
|
||||||
"""Start adding an entity to a platform."""
|
|
||||||
super().add_to_platform_start(hass, platform, parallel_updates)
|
|
||||||
|
|
||||||
def _report_turn_on_off(feature: str, method: str) -> None:
|
|
||||||
"""Log warning not implemented turn on/off feature."""
|
|
||||||
report_issue = self._suggest_report_issue()
|
|
||||||
message = (
|
|
||||||
"Entity %s (%s) does not set FanEntityFeature.%s"
|
|
||||||
" but implements the %s method. Please %s"
|
|
||||||
)
|
|
||||||
_LOGGER.warning(
|
|
||||||
message,
|
|
||||||
self.entity_id,
|
|
||||||
type(self),
|
|
||||||
feature,
|
|
||||||
method,
|
|
||||||
report_issue,
|
|
||||||
)
|
|
||||||
|
|
||||||
# Adds FanEntityFeature.TURN_OFF/TURN_ON depending on service calls implemented
|
|
||||||
# This should be removed in 2025.2.
|
|
||||||
if self._enable_turn_on_off_backwards_compatibility is False:
|
|
||||||
# Return if integration has migrated already
|
|
||||||
return
|
|
||||||
|
|
||||||
supported_features = self.supported_features
|
|
||||||
if supported_features & (FanEntityFeature.TURN_ON | FanEntityFeature.TURN_OFF):
|
|
||||||
# The entity supports both turn_on and turn_off, the backwards compatibility
|
|
||||||
# checks are not needed
|
|
||||||
return
|
|
||||||
|
|
||||||
if not supported_features & FanEntityFeature.TURN_OFF and (
|
|
||||||
type(self).async_turn_off is not ToggleEntity.async_turn_off
|
|
||||||
or type(self).turn_off is not ToggleEntity.turn_off
|
|
||||||
):
|
|
||||||
# turn_off implicitly supported by implementing turn_off method
|
|
||||||
_report_turn_on_off("TURN_OFF", "turn_off")
|
|
||||||
self.__mod_supported_features |= ( # pylint: disable=unused-private-member
|
|
||||||
FanEntityFeature.TURN_OFF
|
|
||||||
)
|
|
||||||
|
|
||||||
if not supported_features & FanEntityFeature.TURN_ON and (
|
|
||||||
type(self).async_turn_on is not FanEntity.async_turn_on
|
|
||||||
or type(self).turn_on is not FanEntity.turn_on
|
|
||||||
):
|
|
||||||
# turn_on implicitly supported by implementing turn_on method
|
|
||||||
_report_turn_on_off("TURN_ON", "turn_on")
|
|
||||||
self.__mod_supported_features |= ( # pylint: disable=unused-private-member
|
|
||||||
FanEntityFeature.TURN_ON
|
|
||||||
)
|
|
||||||
|
|
||||||
def set_percentage(self, percentage: int) -> None:
|
def set_percentage(self, percentage: int) -> None:
|
||||||
"""Set the speed of the fan, as a percentage."""
|
"""Set the speed of the fan, as a percentage."""
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
@ -71,7 +71,7 @@ class Fan(CoordinatorEntity[FjaraskupanCoordinator], FanEntity):
|
|||||||
| FanEntityFeature.TURN_OFF
|
| FanEntityFeature.TURN_OFF
|
||||||
| FanEntityFeature.TURN_ON
|
| FanEntityFeature.TURN_ON
|
||||||
)
|
)
|
||||||
_enable_turn_on_off_backwards_compatibility = False
|
|
||||||
_attr_has_entity_name = True
|
_attr_has_entity_name = True
|
||||||
_attr_name = None
|
_attr_name = None
|
||||||
|
|
||||||
|
@ -40,7 +40,6 @@ class FreedomproFan(CoordinatorEntity[FreedomproDataUpdateCoordinator], FanEntit
|
|||||||
_attr_name = None
|
_attr_name = None
|
||||||
_attr_is_on = False
|
_attr_is_on = False
|
||||||
_attr_percentage = 0
|
_attr_percentage = 0
|
||||||
_enable_turn_on_off_backwards_compatibility = False
|
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
|
@ -109,7 +109,6 @@ class FanGroup(GroupEntity, FanEntity):
|
|||||||
"""Representation of a FanGroup."""
|
"""Representation of a FanGroup."""
|
||||||
|
|
||||||
_attr_available: bool = False
|
_attr_available: bool = False
|
||||||
_enable_turn_on_off_backwards_compatibility = False
|
|
||||||
|
|
||||||
def __init__(self, unique_id: str | None, name: str, entities: list[str]) -> None:
|
def __init__(self, unique_id: str | None, name: str, entities: list[str]) -> None:
|
||||||
"""Initialize a FanGroup entity."""
|
"""Initialize a FanGroup entity."""
|
||||||
|
@ -42,7 +42,6 @@ class BaseHomeKitFan(HomeKitEntity, FanEntity):
|
|||||||
# This must be set in subclasses to the name of a boolean characteristic
|
# This must be set in subclasses to the name of a boolean characteristic
|
||||||
# that controls whether the fan is on or off.
|
# that controls whether the fan is on or off.
|
||||||
on_characteristic: str
|
on_characteristic: str
|
||||||
_enable_turn_on_off_backwards_compatibility = False
|
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def _async_reconfigure(self) -> None:
|
def _async_reconfigure(self) -> None:
|
||||||
|
@ -56,7 +56,6 @@ class InsteonFanEntity(InsteonEntity, FanEntity):
|
|||||||
| FanEntityFeature.TURN_ON
|
| FanEntityFeature.TURN_ON
|
||||||
)
|
)
|
||||||
_attr_speed_count = 3
|
_attr_speed_count = 3
|
||||||
_enable_turn_on_off_backwards_compatibility = False
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def percentage(self) -> int | None:
|
def percentage(self) -> int | None:
|
||||||
|
@ -81,7 +81,6 @@ class IntellifireFan(IntellifireEntity, FanEntity):
|
|||||||
| FanEntityFeature.TURN_OFF
|
| FanEntityFeature.TURN_OFF
|
||||||
| FanEntityFeature.TURN_ON
|
| FanEntityFeature.TURN_ON
|
||||||
)
|
)
|
||||||
_enable_turn_on_off_backwards_compatibility = False
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_on(self) -> bool:
|
def is_on(self) -> bool:
|
||||||
|
@ -53,7 +53,6 @@ class ISYFanEntity(ISYNodeEntity, FanEntity):
|
|||||||
| FanEntityFeature.TURN_OFF
|
| FanEntityFeature.TURN_OFF
|
||||||
| FanEntityFeature.TURN_ON
|
| FanEntityFeature.TURN_ON
|
||||||
)
|
)
|
||||||
_enable_turn_on_off_backwards_compatibility = False
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def percentage(self) -> int | None:
|
def percentage(self) -> int | None:
|
||||||
|
@ -43,7 +43,6 @@ class KNXFan(KnxYamlEntity, FanEntity):
|
|||||||
"""Representation of a KNX fan."""
|
"""Representation of a KNX fan."""
|
||||||
|
|
||||||
_device: XknxFan
|
_device: XknxFan
|
||||||
_enable_turn_on_off_backwards_compatibility = False
|
|
||||||
|
|
||||||
def __init__(self, knx_module: KNXModule, config: ConfigType) -> None:
|
def __init__(self, knx_module: KNXModule, config: ConfigType) -> None:
|
||||||
"""Initialize of KNX fan."""
|
"""Initialize of KNX fan."""
|
||||||
|
@ -51,7 +51,6 @@ class LutronFan(LutronDevice, FanEntity):
|
|||||||
)
|
)
|
||||||
_lutron_device: Output
|
_lutron_device: Output
|
||||||
_prev_percentage: int | None = None
|
_prev_percentage: int | None = None
|
||||||
_enable_turn_on_off_backwards_compatibility = False
|
|
||||||
|
|
||||||
def set_percentage(self, percentage: int) -> None:
|
def set_percentage(self, percentage: int) -> None:
|
||||||
"""Set the speed of the fan, as a percentage."""
|
"""Set the speed of the fan, as a percentage."""
|
||||||
|
@ -50,7 +50,6 @@ class LutronCasetaFan(LutronCasetaUpdatableEntity, FanEntity):
|
|||||||
| FanEntityFeature.TURN_ON
|
| FanEntityFeature.TURN_ON
|
||||||
)
|
)
|
||||||
_attr_speed_count = len(ORDERED_NAMED_FAN_SPEEDS)
|
_attr_speed_count = len(ORDERED_NAMED_FAN_SPEEDS)
|
||||||
_enable_turn_on_off_backwards_compatibility = False
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def percentage(self) -> int | None:
|
def percentage(self) -> int | None:
|
||||||
|
@ -58,7 +58,7 @@ class MatterFan(MatterEntity, FanEntity):
|
|||||||
|
|
||||||
_last_known_preset_mode: str | None = None
|
_last_known_preset_mode: str | None = None
|
||||||
_last_known_percentage: int = 0
|
_last_known_percentage: int = 0
|
||||||
_enable_turn_on_off_backwards_compatibility = False
|
|
||||||
_feature_map: int | None = None
|
_feature_map: int | None = None
|
||||||
_platform_translation_key = "fan"
|
_platform_translation_key = "fan"
|
||||||
|
|
||||||
|
@ -38,8 +38,6 @@ async def async_setup_platform(
|
|||||||
class ModbusFan(BaseSwitch, FanEntity):
|
class ModbusFan(BaseSwitch, FanEntity):
|
||||||
"""Class representing a Modbus fan."""
|
"""Class representing a Modbus fan."""
|
||||||
|
|
||||||
_enable_turn_on_off_backwards_compatibility = False
|
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, hass: HomeAssistant, hub: ModbusHub, config: dict[str, Any]
|
self, hass: HomeAssistant, hub: ModbusHub, config: dict[str, Any]
|
||||||
) -> None:
|
) -> None:
|
||||||
|
@ -78,7 +78,6 @@ class ModernFormsFanEntity(FanEntity, ModernFormsDeviceEntity):
|
|||||||
| FanEntityFeature.TURN_ON
|
| FanEntityFeature.TURN_ON
|
||||||
)
|
)
|
||||||
_attr_translation_key = "fan"
|
_attr_translation_key = "fan"
|
||||||
_enable_turn_on_off_backwards_compatibility = False
|
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, entry_id: str, coordinator: ModernFormsDataUpdateCoordinator
|
self, entry_id: str, coordinator: ModernFormsDataUpdateCoordinator
|
||||||
|
@ -226,7 +226,6 @@ class MqttFan(MqttEntity, FanEntity):
|
|||||||
_optimistic_preset_mode: bool
|
_optimistic_preset_mode: bool
|
||||||
_payload: dict[str, Any]
|
_payload: dict[str, Any]
|
||||||
_speed_range: tuple[int, int]
|
_speed_range: tuple[int, int]
|
||||||
_enable_turn_on_off_backwards_compatibility = False
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def config_schema() -> VolSchemaType:
|
def config_schema() -> VolSchemaType:
|
||||||
|
@ -51,7 +51,6 @@ class NetatmoFan(NetatmoModuleEntity, FanEntity):
|
|||||||
_attr_configuration_url = CONF_URL_CONTROL
|
_attr_configuration_url = CONF_URL_CONTROL
|
||||||
_attr_name = None
|
_attr_name = None
|
||||||
device: NaModules.Fan
|
device: NaModules.Fan
|
||||||
_enable_turn_on_off_backwards_compatibility = False
|
|
||||||
|
|
||||||
def __init__(self, netatmo_device: NetatmoDevice) -> None:
|
def __init__(self, netatmo_device: NetatmoDevice) -> None:
|
||||||
"""Initialize of Netatmo fan."""
|
"""Initialize of Netatmo fan."""
|
||||||
|
@ -55,7 +55,6 @@ class RabbitAirFanEntity(RabbitAirBaseEntity, FanEntity):
|
|||||||
| FanEntityFeature.TURN_ON
|
| FanEntityFeature.TURN_ON
|
||||||
| FanEntityFeature.TURN_OFF
|
| FanEntityFeature.TURN_OFF
|
||||||
)
|
)
|
||||||
_enable_turn_on_off_backwards_compatibility = False
|
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
|
@ -127,7 +127,6 @@ class RensonFan(RensonEntity, FanEntity):
|
|||||||
| FanEntityFeature.TURN_OFF
|
| FanEntityFeature.TURN_OFF
|
||||||
| FanEntityFeature.TURN_ON
|
| FanEntityFeature.TURN_ON
|
||||||
)
|
)
|
||||||
_enable_turn_on_off_backwards_compatibility = False
|
|
||||||
|
|
||||||
def __init__(self, api: RensonVentilation, coordinator: RensonCoordinator) -> None:
|
def __init__(self, api: RensonVentilation, coordinator: RensonCoordinator) -> None:
|
||||||
"""Initialize the Renson fan."""
|
"""Initialize the Renson fan."""
|
||||||
|
@ -70,7 +70,6 @@ class SmartThingsFan(SmartThingsEntity, FanEntity):
|
|||||||
"""Define a SmartThings Fan."""
|
"""Define a SmartThings Fan."""
|
||||||
|
|
||||||
_attr_speed_count = int_states_in_range(SPEED_RANGE)
|
_attr_speed_count = int_states_in_range(SPEED_RANGE)
|
||||||
_enable_turn_on_off_backwards_compatibility = False
|
|
||||||
|
|
||||||
def __init__(self, device):
|
def __init__(self, device):
|
||||||
"""Init the class."""
|
"""Init the class."""
|
||||||
|
@ -48,7 +48,6 @@ class SmartyFan(SmartyEntity, FanEntity):
|
|||||||
| FanEntityFeature.TURN_OFF
|
| FanEntityFeature.TURN_OFF
|
||||||
| FanEntityFeature.TURN_ON
|
| FanEntityFeature.TURN_ON
|
||||||
)
|
)
|
||||||
_enable_turn_on_off_backwards_compatibility = False
|
|
||||||
|
|
||||||
def __init__(self, coordinator: SmartyCoordinator) -> None:
|
def __init__(self, coordinator: SmartyCoordinator) -> None:
|
||||||
"""Initialize the entity."""
|
"""Initialize the entity."""
|
||||||
|
@ -83,7 +83,6 @@ class SnoozFan(FanEntity, RestoreEntity):
|
|||||||
_attr_should_poll = False
|
_attr_should_poll = False
|
||||||
_is_on: bool | None = None
|
_is_on: bool | None = None
|
||||||
_percentage: int | None = None
|
_percentage: int | None = None
|
||||||
_enable_turn_on_off_backwards_compatibility = False
|
|
||||||
|
|
||||||
def __init__(self, data: SnoozConfigurationData) -> None:
|
def __init__(self, data: SnoozConfigurationData) -> None:
|
||||||
"""Initialize a Snooz fan entity."""
|
"""Initialize a Snooz fan entity."""
|
||||||
|
@ -46,7 +46,6 @@ class FanSwitch(BaseToggleEntity, FanEntity):
|
|||||||
"""Represents a Switch as a Fan."""
|
"""Represents a Switch as a Fan."""
|
||||||
|
|
||||||
_attr_supported_features = FanEntityFeature.TURN_OFF | FanEntityFeature.TURN_ON
|
_attr_supported_features = FanEntityFeature.TURN_OFF | FanEntityFeature.TURN_ON
|
||||||
_enable_turn_on_off_backwards_compatibility = False
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_on(self) -> bool | None:
|
def is_on(self) -> bool | None:
|
||||||
|
@ -72,7 +72,6 @@ class TasmotaFan(
|
|||||||
)
|
)
|
||||||
_fan_speed = tasmota_const.FAN_SPEED_MEDIUM
|
_fan_speed = tasmota_const.FAN_SPEED_MEDIUM
|
||||||
_tasmota_entity: tasmota_fan.TasmotaFan
|
_tasmota_entity: tasmota_fan.TasmotaFan
|
||||||
_enable_turn_on_off_backwards_compatibility = False
|
|
||||||
|
|
||||||
def __init__(self, **kwds: Any) -> None:
|
def __init__(self, **kwds: Any) -> None:
|
||||||
"""Initialize the Tasmota fan."""
|
"""Initialize the Tasmota fan."""
|
||||||
|
@ -124,7 +124,6 @@ class TemplateFan(TemplateEntity, FanEntity):
|
|||||||
"""A template fan component."""
|
"""A template fan component."""
|
||||||
|
|
||||||
_attr_should_poll = False
|
_attr_should_poll = False
|
||||||
_enable_turn_on_off_backwards_compatibility = False
|
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
|
@ -29,7 +29,6 @@ class ToloFan(ToloSaunaCoordinatorEntity, FanEntity):
|
|||||||
|
|
||||||
_attr_translation_key = "fan"
|
_attr_translation_key = "fan"
|
||||||
_attr_supported_features = FanEntityFeature.TURN_OFF | FanEntityFeature.TURN_ON
|
_attr_supported_features = FanEntityFeature.TURN_OFF | FanEntityFeature.TURN_ON
|
||||||
_enable_turn_on_off_backwards_compatibility = False
|
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, coordinator: ToloSaunaUpdateCoordinator, entry: ConfigEntry
|
self, coordinator: ToloSaunaUpdateCoordinator, entry: ConfigEntry
|
||||||
|
@ -64,7 +64,6 @@ class TPLinkFanEntity(CoordinatedTPLinkEntity, FanEntity):
|
|||||||
| FanEntityFeature.TURN_OFF
|
| FanEntityFeature.TURN_OFF
|
||||||
| FanEntityFeature.TURN_ON
|
| FanEntityFeature.TURN_ON
|
||||||
)
|
)
|
||||||
_enable_turn_on_off_backwards_compatibility = False
|
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
|
@ -69,7 +69,6 @@ class TradfriAirPurifierFan(TradfriBaseEntity, FanEntity):
|
|||||||
# ... with step size 1
|
# ... with step size 1
|
||||||
# 50 = Max
|
# 50 = Max
|
||||||
_attr_speed_count = ATTR_MAX_FAN_STEPS
|
_attr_speed_count = ATTR_MAX_FAN_STEPS
|
||||||
_enable_turn_on_off_backwards_compatibility = False
|
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
|
@ -66,7 +66,6 @@ class TuyaFanEntity(TuyaEntity, FanEntity):
|
|||||||
_speeds: EnumTypeData | None = None
|
_speeds: EnumTypeData | None = None
|
||||||
_switch: DPCode | None = None
|
_switch: DPCode | None = None
|
||||||
_attr_name = None
|
_attr_name = None
|
||||||
_enable_turn_on_off_backwards_compatibility = False
|
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
|
@ -83,7 +83,6 @@ class ValloxFanEntity(ValloxEntity, FanEntity):
|
|||||||
| FanEntityFeature.TURN_OFF
|
| FanEntityFeature.TURN_OFF
|
||||||
| FanEntityFeature.TURN_ON
|
| FanEntityFeature.TURN_ON
|
||||||
)
|
)
|
||||||
_enable_turn_on_off_backwards_compatibility = False
|
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
|
@ -95,7 +95,6 @@ class VeSyncFanHA(VeSyncDevice, FanEntity):
|
|||||||
)
|
)
|
||||||
_attr_name = None
|
_attr_name = None
|
||||||
_attr_translation_key = "vesync"
|
_attr_translation_key = "vesync"
|
||||||
_enable_turn_on_off_backwards_compatibility = False
|
|
||||||
|
|
||||||
def __init__(self, fan) -> None:
|
def __init__(self, fan) -> None:
|
||||||
"""Initialize the VeSync fan device."""
|
"""Initialize the VeSync fan device."""
|
||||||
|
@ -125,7 +125,6 @@ class ViCareFan(ViCareEntity, FanEntity):
|
|||||||
_attr_speed_count = len(ORDERED_NAMED_FAN_SPEEDS)
|
_attr_speed_count = len(ORDERED_NAMED_FAN_SPEEDS)
|
||||||
_attr_supported_features = FanEntityFeature.SET_SPEED
|
_attr_supported_features = FanEntityFeature.SET_SPEED
|
||||||
_attr_translation_key = "ventilation"
|
_attr_translation_key = "ventilation"
|
||||||
_enable_turn_on_off_backwards_compatibility = False
|
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
|
@ -81,7 +81,6 @@ class WemoHumidifier(WemoBinaryStateEntity, FanEntity):
|
|||||||
)
|
)
|
||||||
wemo: Humidifier
|
wemo: Humidifier
|
||||||
_last_fan_on_mode: FanMode
|
_last_fan_on_mode: FanMode
|
||||||
_enable_turn_on_off_backwards_compatibility = False
|
|
||||||
|
|
||||||
def __init__(self, coordinator: DeviceCoordinator) -> None:
|
def __init__(self, coordinator: DeviceCoordinator) -> None:
|
||||||
"""Initialize the WeMo switch."""
|
"""Initialize the WeMo switch."""
|
||||||
|
@ -64,7 +64,6 @@ class WiLightFan(WiLightDevice, FanEntity):
|
|||||||
| FanEntityFeature.TURN_ON
|
| FanEntityFeature.TURN_ON
|
||||||
| FanEntityFeature.TURN_OFF
|
| FanEntityFeature.TURN_OFF
|
||||||
)
|
)
|
||||||
_enable_turn_on_off_backwards_compatibility = False
|
|
||||||
|
|
||||||
def __init__(self, api_device: PyWiLightDevice, index: str, item_name: str) -> None:
|
def __init__(self, api_device: PyWiLightDevice, index: str, item_name: str) -> None:
|
||||||
"""Initialize the device."""
|
"""Initialize the device."""
|
||||||
|
@ -300,7 +300,6 @@ class XiaomiGenericDevice(XiaomiCoordinatedMiioEntity, FanEntity):
|
|||||||
"""Representation of a generic Xiaomi device."""
|
"""Representation of a generic Xiaomi device."""
|
||||||
|
|
||||||
_attr_name = None
|
_attr_name = None
|
||||||
_enable_turn_on_off_backwards_compatibility = False
|
|
||||||
|
|
||||||
def __init__(self, device, entry, unique_id, coordinator):
|
def __init__(self, device, entry, unique_id, coordinator):
|
||||||
"""Initialize the generic Xiaomi device."""
|
"""Initialize the generic Xiaomi device."""
|
||||||
|
@ -47,7 +47,6 @@ class ZhaFan(FanEntity, ZHAEntity):
|
|||||||
"""Representation of a ZHA fan."""
|
"""Representation of a ZHA fan."""
|
||||||
|
|
||||||
_attr_translation_key: str = "fan"
|
_attr_translation_key: str = "fan"
|
||||||
_enable_turn_on_off_backwards_compatibility = False
|
|
||||||
|
|
||||||
def __init__(self, entity_data: EntityData) -> None:
|
def __init__(self, entity_data: EntityData) -> None:
|
||||||
"""Initialize the ZHA fan."""
|
"""Initialize the ZHA fan."""
|
||||||
|
@ -83,7 +83,6 @@ class ZwaveFan(ZWaveBaseEntity, FanEntity):
|
|||||||
| FanEntityFeature.TURN_OFF
|
| FanEntityFeature.TURN_OFF
|
||||||
| FanEntityFeature.TURN_ON
|
| FanEntityFeature.TURN_ON
|
||||||
)
|
)
|
||||||
_enable_turn_on_off_backwards_compatibility = False
|
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, config_entry: ConfigEntry, driver: Driver, info: ZwaveDiscoveryInfo
|
self, config_entry: ConfigEntry, driver: Driver, info: ZwaveDiscoveryInfo
|
||||||
|
@ -49,7 +49,6 @@ class ZWaveMeFan(ZWaveMeEntity, FanEntity):
|
|||||||
| FanEntityFeature.TURN_OFF
|
| FanEntityFeature.TURN_OFF
|
||||||
| FanEntityFeature.TURN_ON
|
| FanEntityFeature.TURN_ON
|
||||||
)
|
)
|
||||||
_enable_turn_on_off_backwards_compatibility = False
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def percentage(self) -> int:
|
def percentage(self) -> int:
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
"""Tests for fan platforms."""
|
"""Tests for fan platforms."""
|
||||||
|
|
||||||
from unittest.mock import patch
|
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant.components.fan import (
|
from homeassistant.components.fan import (
|
||||||
@ -13,23 +11,13 @@ from homeassistant.components.fan import (
|
|||||||
FanEntityFeature,
|
FanEntityFeature,
|
||||||
NotValidPresetModeError,
|
NotValidPresetModeError,
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import ConfigEntry
|
|
||||||
from homeassistant.const import SERVICE_TURN_OFF, SERVICE_TURN_ON
|
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
|
||||||
import homeassistant.helpers.entity_registry as er
|
import homeassistant.helpers.entity_registry as er
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
|
|
||||||
from .common import MockFan
|
from .common import MockFan
|
||||||
|
|
||||||
from tests.common import (
|
from tests.common import setup_test_component_platform
|
||||||
MockConfigEntry,
|
|
||||||
MockModule,
|
|
||||||
MockPlatform,
|
|
||||||
mock_integration,
|
|
||||||
mock_platform,
|
|
||||||
setup_test_component_platform,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class BaseFan(FanEntity):
|
class BaseFan(FanEntity):
|
||||||
@ -161,300 +149,3 @@ async def test_preset_mode_validation(
|
|||||||
with pytest.raises(NotValidPresetModeError) as exc:
|
with pytest.raises(NotValidPresetModeError) as exc:
|
||||||
await test_fan._valid_preset_mode_or_raise("invalid")
|
await test_fan._valid_preset_mode_or_raise("invalid")
|
||||||
assert exc.value.translation_key == "not_valid_preset_mode"
|
assert exc.value.translation_key == "not_valid_preset_mode"
|
||||||
|
|
||||||
|
|
||||||
def test_deprecated_supported_features_ints(caplog: pytest.LogCaptureFixture) -> None:
|
|
||||||
"""Test deprecated supported features ints."""
|
|
||||||
|
|
||||||
class MockFan(FanEntity):
|
|
||||||
@property
|
|
||||||
def supported_features(self) -> int:
|
|
||||||
"""Return supported features."""
|
|
||||||
return 1
|
|
||||||
|
|
||||||
entity = MockFan()
|
|
||||||
assert entity.supported_features is FanEntityFeature(1)
|
|
||||||
assert "MockFan" in caplog.text
|
|
||||||
assert "is using deprecated supported features values" in caplog.text
|
|
||||||
assert "Instead it should use" in caplog.text
|
|
||||||
assert "FanEntityFeature.SET_SPEED" in caplog.text
|
|
||||||
caplog.clear()
|
|
||||||
assert entity.supported_features is FanEntityFeature(1)
|
|
||||||
assert "is using deprecated supported features values" not in caplog.text
|
|
||||||
|
|
||||||
|
|
||||||
async def test_warning_not_implemented_turn_on_off_feature(
|
|
||||||
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, config_flow_fixture: None
|
|
||||||
) -> None:
|
|
||||||
"""Test adding feature flag and warn if missing when methods are set."""
|
|
||||||
|
|
||||||
called = []
|
|
||||||
|
|
||||||
class MockFanEntityTest(MockFan):
|
|
||||||
"""Mock Fan device."""
|
|
||||||
|
|
||||||
def turn_on(
|
|
||||||
self,
|
|
||||||
percentage: int | None = None,
|
|
||||||
preset_mode: str | None = None,
|
|
||||||
) -> None:
|
|
||||||
"""Turn on."""
|
|
||||||
called.append("turn_on")
|
|
||||||
|
|
||||||
def turn_off(self) -> None:
|
|
||||||
"""Turn off."""
|
|
||||||
called.append("turn_off")
|
|
||||||
|
|
||||||
async def async_setup_entry_init(
|
|
||||||
hass: HomeAssistant, config_entry: ConfigEntry
|
|
||||||
) -> bool:
|
|
||||||
"""Set up test config entry."""
|
|
||||||
await hass.config_entries.async_forward_entry_setups(config_entry, [DOMAIN])
|
|
||||||
return True
|
|
||||||
|
|
||||||
async def async_setup_entry_fan_platform(
|
|
||||||
hass: HomeAssistant,
|
|
||||||
config_entry: ConfigEntry,
|
|
||||||
async_add_entities: AddEntitiesCallback,
|
|
||||||
) -> None:
|
|
||||||
"""Set up test fan platform via config entry."""
|
|
||||||
async_add_entities([MockFanEntityTest(name="test", entity_id="fan.test")])
|
|
||||||
|
|
||||||
mock_integration(
|
|
||||||
hass,
|
|
||||||
MockModule(
|
|
||||||
"test",
|
|
||||||
async_setup_entry=async_setup_entry_init,
|
|
||||||
),
|
|
||||||
built_in=False,
|
|
||||||
)
|
|
||||||
mock_platform(
|
|
||||||
hass,
|
|
||||||
"test.fan",
|
|
||||||
MockPlatform(async_setup_entry=async_setup_entry_fan_platform),
|
|
||||||
)
|
|
||||||
|
|
||||||
with patch.object(
|
|
||||||
MockFanEntityTest, "__module__", "tests.custom_components.fan.test_init"
|
|
||||||
):
|
|
||||||
config_entry = MockConfigEntry(domain="test")
|
|
||||||
config_entry.add_to_hass(hass)
|
|
||||||
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
|
||||||
await hass.async_block_till_done()
|
|
||||||
|
|
||||||
state = hass.states.get("fan.test")
|
|
||||||
assert state is not None
|
|
||||||
|
|
||||||
assert (
|
|
||||||
"Entity fan.test (<class 'tests.custom_components.fan.test_init.test_warning_not_implemented_turn_on_off_feature.<locals>.MockFanEntityTest'>) "
|
|
||||||
"does not set FanEntityFeature.TURN_OFF but implements the turn_off method. Please report it to the author of the 'test' custom integration"
|
|
||||||
in caplog.text
|
|
||||||
)
|
|
||||||
assert (
|
|
||||||
"Entity fan.test (<class 'tests.custom_components.fan.test_init.test_warning_not_implemented_turn_on_off_feature.<locals>.MockFanEntityTest'>) "
|
|
||||||
"does not set FanEntityFeature.TURN_ON but implements the turn_on method. Please report it to the author of the 'test' custom integration"
|
|
||||||
in caplog.text
|
|
||||||
)
|
|
||||||
|
|
||||||
await hass.services.async_call(
|
|
||||||
DOMAIN,
|
|
||||||
SERVICE_TURN_ON,
|
|
||||||
{
|
|
||||||
"entity_id": "fan.test",
|
|
||||||
},
|
|
||||||
blocking=True,
|
|
||||||
)
|
|
||||||
await hass.services.async_call(
|
|
||||||
DOMAIN,
|
|
||||||
SERVICE_TURN_OFF,
|
|
||||||
{
|
|
||||||
"entity_id": "fan.test",
|
|
||||||
},
|
|
||||||
blocking=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
assert len(called) == 2
|
|
||||||
assert "turn_on" in called
|
|
||||||
assert "turn_off" in called
|
|
||||||
|
|
||||||
|
|
||||||
async def test_no_warning_implemented_turn_on_off_feature(
|
|
||||||
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, config_flow_fixture: None
|
|
||||||
) -> None:
|
|
||||||
"""Test no warning when feature flags are set."""
|
|
||||||
|
|
||||||
class MockFanEntityTest(MockFan):
|
|
||||||
"""Mock Fan device."""
|
|
||||||
|
|
||||||
_attr_supported_features = (
|
|
||||||
FanEntityFeature.DIRECTION
|
|
||||||
| FanEntityFeature.OSCILLATE
|
|
||||||
| FanEntityFeature.SET_SPEED
|
|
||||||
| FanEntityFeature.PRESET_MODE
|
|
||||||
| FanEntityFeature.TURN_OFF
|
|
||||||
| FanEntityFeature.TURN_ON
|
|
||||||
)
|
|
||||||
|
|
||||||
async def async_setup_entry_init(
|
|
||||||
hass: HomeAssistant, config_entry: ConfigEntry
|
|
||||||
) -> bool:
|
|
||||||
"""Set up test config entry."""
|
|
||||||
await hass.config_entries.async_forward_entry_setups(config_entry, [DOMAIN])
|
|
||||||
return True
|
|
||||||
|
|
||||||
async def async_setup_entry_fan_platform(
|
|
||||||
hass: HomeAssistant,
|
|
||||||
config_entry: ConfigEntry,
|
|
||||||
async_add_entities: AddEntitiesCallback,
|
|
||||||
) -> None:
|
|
||||||
"""Set up test fan platform via config entry."""
|
|
||||||
async_add_entities([MockFanEntityTest(name="test", entity_id="fan.test")])
|
|
||||||
|
|
||||||
mock_integration(
|
|
||||||
hass,
|
|
||||||
MockModule(
|
|
||||||
"test",
|
|
||||||
async_setup_entry=async_setup_entry_init,
|
|
||||||
),
|
|
||||||
built_in=False,
|
|
||||||
)
|
|
||||||
mock_platform(
|
|
||||||
hass,
|
|
||||||
"test.fan",
|
|
||||||
MockPlatform(async_setup_entry=async_setup_entry_fan_platform),
|
|
||||||
)
|
|
||||||
|
|
||||||
with patch.object(
|
|
||||||
MockFanEntityTest, "__module__", "tests.custom_components.fan.test_init"
|
|
||||||
):
|
|
||||||
config_entry = MockConfigEntry(domain="test")
|
|
||||||
config_entry.add_to_hass(hass)
|
|
||||||
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
|
||||||
await hass.async_block_till_done()
|
|
||||||
|
|
||||||
state = hass.states.get("fan.test")
|
|
||||||
assert state is not None
|
|
||||||
|
|
||||||
assert "does not set FanEntityFeature.TURN_OFF" not in caplog.text
|
|
||||||
assert "does not set FanEntityFeature.TURN_ON" not in caplog.text
|
|
||||||
|
|
||||||
|
|
||||||
async def test_no_warning_integration_has_migrated(
|
|
||||||
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, config_flow_fixture: None
|
|
||||||
) -> None:
|
|
||||||
"""Test no warning when integration migrated using `_enable_turn_on_off_backwards_compatibility`."""
|
|
||||||
|
|
||||||
class MockFanEntityTest(MockFan):
|
|
||||||
"""Mock Fan device."""
|
|
||||||
|
|
||||||
_enable_turn_on_off_backwards_compatibility = False
|
|
||||||
_attr_supported_features = (
|
|
||||||
FanEntityFeature.DIRECTION
|
|
||||||
| FanEntityFeature.OSCILLATE
|
|
||||||
| FanEntityFeature.SET_SPEED
|
|
||||||
| FanEntityFeature.PRESET_MODE
|
|
||||||
)
|
|
||||||
|
|
||||||
async def async_setup_entry_init(
|
|
||||||
hass: HomeAssistant, config_entry: ConfigEntry
|
|
||||||
) -> bool:
|
|
||||||
"""Set up test config entry."""
|
|
||||||
await hass.config_entries.async_forward_entry_setups(config_entry, [DOMAIN])
|
|
||||||
return True
|
|
||||||
|
|
||||||
async def async_setup_entry_fan_platform(
|
|
||||||
hass: HomeAssistant,
|
|
||||||
config_entry: ConfigEntry,
|
|
||||||
async_add_entities: AddEntitiesCallback,
|
|
||||||
) -> None:
|
|
||||||
"""Set up test fan platform via config entry."""
|
|
||||||
async_add_entities([MockFanEntityTest(name="test", entity_id="fan.test")])
|
|
||||||
|
|
||||||
mock_integration(
|
|
||||||
hass,
|
|
||||||
MockModule(
|
|
||||||
"test",
|
|
||||||
async_setup_entry=async_setup_entry_init,
|
|
||||||
),
|
|
||||||
built_in=False,
|
|
||||||
)
|
|
||||||
mock_platform(
|
|
||||||
hass,
|
|
||||||
"test.fan",
|
|
||||||
MockPlatform(async_setup_entry=async_setup_entry_fan_platform),
|
|
||||||
)
|
|
||||||
|
|
||||||
with patch.object(
|
|
||||||
MockFanEntityTest, "__module__", "tests.custom_components.fan.test_init"
|
|
||||||
):
|
|
||||||
config_entry = MockConfigEntry(domain="test")
|
|
||||||
config_entry.add_to_hass(hass)
|
|
||||||
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
|
||||||
await hass.async_block_till_done()
|
|
||||||
|
|
||||||
state = hass.states.get("fan.test")
|
|
||||||
assert state is not None
|
|
||||||
|
|
||||||
assert "does not set FanEntityFeature.TURN_OFF" not in caplog.text
|
|
||||||
assert "does not set FanEntityFeature.TURN_ON" not in caplog.text
|
|
||||||
|
|
||||||
|
|
||||||
async def test_no_warning_integration_implement_feature_flags(
|
|
||||||
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, config_flow_fixture: None
|
|
||||||
) -> None:
|
|
||||||
"""Test no warning when integration uses the correct feature flags."""
|
|
||||||
|
|
||||||
class MockFanEntityTest(MockFan):
|
|
||||||
"""Mock Fan device."""
|
|
||||||
|
|
||||||
_attr_supported_features = (
|
|
||||||
FanEntityFeature.DIRECTION
|
|
||||||
| FanEntityFeature.OSCILLATE
|
|
||||||
| FanEntityFeature.SET_SPEED
|
|
||||||
| FanEntityFeature.PRESET_MODE
|
|
||||||
| FanEntityFeature.TURN_OFF
|
|
||||||
| FanEntityFeature.TURN_ON
|
|
||||||
)
|
|
||||||
|
|
||||||
async def async_setup_entry_init(
|
|
||||||
hass: HomeAssistant, config_entry: ConfigEntry
|
|
||||||
) -> bool:
|
|
||||||
"""Set up test config entry."""
|
|
||||||
await hass.config_entries.async_forward_entry_setups(config_entry, [DOMAIN])
|
|
||||||
return True
|
|
||||||
|
|
||||||
async def async_setup_entry_fan_platform(
|
|
||||||
hass: HomeAssistant,
|
|
||||||
config_entry: ConfigEntry,
|
|
||||||
async_add_entities: AddEntitiesCallback,
|
|
||||||
) -> None:
|
|
||||||
"""Set up test fan platform via config entry."""
|
|
||||||
async_add_entities([MockFanEntityTest(name="test", entity_id="fan.test")])
|
|
||||||
|
|
||||||
mock_integration(
|
|
||||||
hass,
|
|
||||||
MockModule(
|
|
||||||
"test",
|
|
||||||
async_setup_entry=async_setup_entry_init,
|
|
||||||
),
|
|
||||||
built_in=False,
|
|
||||||
)
|
|
||||||
mock_platform(
|
|
||||||
hass,
|
|
||||||
"test.fan",
|
|
||||||
MockPlatform(async_setup_entry=async_setup_entry_fan_platform),
|
|
||||||
)
|
|
||||||
|
|
||||||
with patch.object(
|
|
||||||
MockFanEntityTest, "__module__", "tests.custom_components.fan.test_init"
|
|
||||||
):
|
|
||||||
config_entry = MockConfigEntry(domain="test")
|
|
||||||
config_entry.add_to_hass(hass)
|
|
||||||
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
|
||||||
await hass.async_block_till_done()
|
|
||||||
|
|
||||||
state = hass.states.get("fan.test")
|
|
||||||
assert state is not None
|
|
||||||
|
|
||||||
assert "does not set FanEntityFeature.TURN_OFF" not in caplog.text
|
|
||||||
assert "does not set FanEntityFeature.TURN_ON" not in caplog.text
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user