Use EntityFeature enum in components (m**) (#69414)

* Use EntityFeature in melcloud

* Use EntityFeature in mystrom

* Use EntityFeature in mysensors

* Use EntityFeature in myq

* Use EntityFeature in mpd

* Use EntityFeature in monoprice

* Use EntityFeature in moehlenhoff_alpha2

* Use EntityFeature in modern_forms

* Use EntityFeature in modbus

* Use EntityFeature in melissa

* Use EntityFeature in mediaroom

* Use EntityFeature in maxcube

* Use EntityFeature in manual_mqtt

* Fix maxcube tests

* Revert "Use EntityFeature in modbus"

This reverts commit 56cf9d900d.

* Revert "Use EntityFeature in myq"

This reverts commit 44a31b1a03.

* Revert "Use EntityFeature in mystrom"

This reverts commit 7260ee0384.

* Revert "Revert "Use EntityFeature in modbus""

This reverts commit 916a612a60.

* Revert "Revert "Use EntityFeature in myq""

This reverts commit a6be42fa17.
This commit is contained in:
epenet 2022-04-06 17:33:41 +02:00 committed by GitHub
parent 8e090a8c04
commit 5e2cc2b9b0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 109 additions and 160 deletions

View file

@ -10,12 +10,7 @@ import voluptuous as vol
from homeassistant.components import mqtt
import homeassistant.components.alarm_control_panel as alarm
from homeassistant.components.alarm_control_panel.const import (
SUPPORT_ALARM_ARM_AWAY,
SUPPORT_ALARM_ARM_HOME,
SUPPORT_ALARM_ARM_NIGHT,
SUPPORT_ALARM_TRIGGER,
)
from homeassistant.components.alarm_control_panel import AlarmControlPanelEntityFeature
from homeassistant.const import (
CONF_CODE,
CONF_DELAY_TIME,
@ -209,6 +204,13 @@ class ManualMQTTAlarm(alarm.AlarmControlPanelEntity):
A trigger_time of zero disables the alarm_trigger service.
"""
_attr_supported_features = (
AlarmControlPanelEntityFeature.ARM_HOME
| AlarmControlPanelEntityFeature.ARM_AWAY
| AlarmControlPanelEntityFeature.ARM_NIGHT
| AlarmControlPanelEntityFeature.TRIGGER
)
def __init__(
self,
hass,
@ -293,16 +295,6 @@ class ManualMQTTAlarm(alarm.AlarmControlPanelEntity):
return self._state
@property
def supported_features(self) -> int:
"""Return the list of supported features."""
return (
SUPPORT_ALARM_ARM_HOME
| SUPPORT_ALARM_ARM_AWAY
| SUPPORT_ALARM_ARM_NIGHT
| SUPPORT_ALARM_TRIGGER
)
@property
def _active_state(self):
"""Get the current state."""

View file

@ -11,7 +11,7 @@ from maxcube.device import (
MAX_DEVICE_MODE_VACATION,
)
from homeassistant.components.climate import ClimateEntity
from homeassistant.components.climate import ClimateEntity, ClimateEntityFeature
from homeassistant.components.climate.const import (
CURRENT_HVAC_HEAT,
CURRENT_HVAC_IDLE,
@ -24,8 +24,6 @@ from homeassistant.components.climate.const import (
PRESET_COMFORT,
PRESET_ECO,
PRESET_NONE,
SUPPORT_PRESET_MODE,
SUPPORT_TARGET_TEMPERATURE,
)
from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS
from homeassistant.core import HomeAssistant
@ -50,8 +48,6 @@ MIN_TEMPERATURE = 5.0
# Largest Value without fully opening
MAX_TEMPERATURE = 30.0
SUPPORT_FLAGS = SUPPORT_TARGET_TEMPERATURE | SUPPORT_PRESET_MODE
def setup_platform(
hass: HomeAssistant,
@ -73,13 +69,16 @@ def setup_platform(
class MaxCubeClimate(ClimateEntity):
"""MAX! Cube ClimateEntity."""
_attr_supported_features = (
ClimateEntityFeature.TARGET_TEMPERATURE | ClimateEntityFeature.PRESET_MODE
)
def __init__(self, handler, device):
"""Initialize MAX! Cube ClimateEntity."""
room = handler.cube.room_by_id(device.room_id)
self._attr_name = f"{room.name} {device.name}"
self._cubehandle = handler
self._device = device
self._attr_supported_features = SUPPORT_FLAGS
self._attr_should_poll = True
self._attr_unique_id = self._device.serial
self._attr_temperature_unit = TEMP_CELSIUS

View file

@ -12,20 +12,12 @@ from pymediaroom import (
)
import voluptuous as vol
from homeassistant.components.media_player import PLATFORM_SCHEMA, MediaPlayerEntity
from homeassistant.components.media_player.const import (
MEDIA_TYPE_CHANNEL,
SUPPORT_NEXT_TRACK,
SUPPORT_PAUSE,
SUPPORT_PLAY,
SUPPORT_PLAY_MEDIA,
SUPPORT_PREVIOUS_TRACK,
SUPPORT_STOP,
SUPPORT_TURN_OFF,
SUPPORT_TURN_ON,
SUPPORT_VOLUME_MUTE,
SUPPORT_VOLUME_STEP,
from homeassistant.components.media_player import (
PLATFORM_SCHEMA,
MediaPlayerEntity,
MediaPlayerEntityFeature,
)
from homeassistant.components.media_player.const import MEDIA_TYPE_CHANNEL
from homeassistant.const import (
CONF_HOST,
CONF_NAME,
@ -54,18 +46,7 @@ DISCOVERY_MEDIAROOM = "mediaroom_discovery_installed"
MEDIA_TYPE_MEDIAROOM = "mediaroom"
SIGNAL_STB_NOTIFY = "mediaroom_stb_discovered"
SUPPORT_MEDIAROOM = (
SUPPORT_PAUSE
| SUPPORT_TURN_ON
| SUPPORT_TURN_OFF
| SUPPORT_VOLUME_STEP
| SUPPORT_VOLUME_MUTE
| SUPPORT_PLAY_MEDIA
| SUPPORT_STOP
| SUPPORT_NEXT_TRACK
| SUPPORT_PREVIOUS_TRACK
| SUPPORT_PLAY
)
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
{
@ -136,6 +117,19 @@ async def async_setup_platform(
class MediaroomDevice(MediaPlayerEntity):
"""Representation of a Mediaroom set-up-box on the network."""
_attr_supported_features = (
MediaPlayerEntityFeature.PAUSE
| MediaPlayerEntityFeature.TURN_ON
| MediaPlayerEntityFeature.TURN_OFF
| MediaPlayerEntityFeature.VOLUME_STEP
| MediaPlayerEntityFeature.VOLUME_MUTE
| MediaPlayerEntityFeature.PLAY_MEDIA
| MediaPlayerEntityFeature.STOP
| MediaPlayerEntityFeature.NEXT_TRACK
| MediaPlayerEntityFeature.PREVIOUS_TRACK
| MediaPlayerEntityFeature.PLAY
)
def set_state(self, mediaroom_state):
"""Map pymediaroom state to HA state."""
@ -242,11 +236,6 @@ class MediaroomDevice(MediaPlayerEntity):
"""Return the state of the device."""
return self._state
@property
def supported_features(self):
"""Flag media player features that are supported."""
return SUPPORT_MEDIAROOM
@property
def media_content_type(self):
"""Return the content type of current playing media."""

View file

@ -14,7 +14,7 @@ from pymelcloud.atw_device import (
)
import voluptuous as vol
from homeassistant.components.climate import ClimateEntity
from homeassistant.components.climate import ClimateEntity, ClimateEntityFeature
from homeassistant.components.climate.const import (
ATTR_HVAC_MODE,
DEFAULT_MAX_TEMP,
@ -25,9 +25,6 @@ from homeassistant.components.climate.const import (
HVAC_MODE_HEAT,
HVAC_MODE_HEAT_COOL,
HVAC_MODE_OFF,
SUPPORT_FAN_MODE,
SUPPORT_SWING_MODE,
SUPPORT_TARGET_TEMPERATURE,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS
@ -128,7 +125,9 @@ class AtaDeviceClimate(MelCloudClimate):
"""Air-to-Air climate device."""
_attr_supported_features = (
SUPPORT_FAN_MODE | SUPPORT_TARGET_TEMPERATURE | SUPPORT_SWING_MODE
ClimateEntityFeature.FAN_MODE
| ClimateEntityFeature.TARGET_TEMPERATURE
| ClimateEntityFeature.SWING_MODE
)
def __init__(self, device: MelCloudDevice, ata_device: AtaDevice) -> None:
@ -296,7 +295,7 @@ class AtwDeviceZoneClimate(MelCloudClimate):
_attr_max_temp = 30
_attr_min_temp = 10
_attr_supported_features = SUPPORT_TARGET_TEMPERATURE
_attr_supported_features = ClimateEntityFeature.TARGET_TEMPERATURE
def __init__(
self, device: MelCloudDevice, atw_device: AtwDevice, atw_zone: Zone

View file

@ -9,9 +9,8 @@ from pymelcloud.atw_device import (
from pymelcloud.device import PROPERTY_POWER
from homeassistant.components.water_heater import (
SUPPORT_OPERATION_MODE,
SUPPORT_TARGET_TEMPERATURE,
WaterHeaterEntity,
WaterHeaterEntityFeature,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import TEMP_CELSIUS
@ -39,6 +38,11 @@ async def async_setup_entry(
class AtwWaterHeater(WaterHeaterEntity):
"""Air-to-Water water heater."""
_attr_supported_features = (
WaterHeaterEntityFeature.TARGET_TEMPERATURE
| WaterHeaterEntityFeature.OPERATION_MODE
)
def __init__(self, api: MelCloudDevice, device: AtwDevice) -> None:
"""Initialize water heater device."""
self._api = api
@ -117,11 +121,6 @@ class AtwWaterHeater(WaterHeaterEntity):
"""Set new target operation mode."""
await self._device.set({PROPERTY_OPERATION_MODE: operation_mode})
@property
def supported_features(self):
"""Return the list of supported features."""
return SUPPORT_TARGET_TEMPERATURE | SUPPORT_OPERATION_MODE
@property
def min_temp(self) -> float | None:
"""Return the minimum temperature."""

View file

@ -3,7 +3,7 @@ from __future__ import annotations
import logging
from homeassistant.components.climate import ClimateEntity
from homeassistant.components.climate import ClimateEntity, ClimateEntityFeature
from homeassistant.components.climate.const import (
FAN_AUTO,
FAN_HIGH,
@ -15,8 +15,6 @@ from homeassistant.components.climate.const import (
HVAC_MODE_FAN_ONLY,
HVAC_MODE_HEAT,
HVAC_MODE_OFF,
SUPPORT_FAN_MODE,
SUPPORT_TARGET_TEMPERATURE,
)
from homeassistant.const import ATTR_TEMPERATURE, PRECISION_WHOLE, TEMP_CELSIUS
from homeassistant.core import HomeAssistant
@ -27,8 +25,6 @@ from . import DATA_MELISSA
_LOGGER = logging.getLogger(__name__)
SUPPORT_FLAGS = SUPPORT_FAN_MODE | SUPPORT_TARGET_TEMPERATURE
OP_MODES = [
HVAC_MODE_HEAT,
HVAC_MODE_COOL,
@ -62,6 +58,10 @@ async def async_setup_platform(
class MelissaClimate(ClimateEntity):
"""Representation of a Melissa Climate device."""
_attr_supported_features = (
ClimateEntityFeature.FAN_MODE | ClimateEntityFeature.TARGET_TEMPERATURE
)
def __init__(self, api, serial_number, init_data):
"""Initialize the climate device."""
self._name = init_data["name"]
@ -147,11 +147,6 @@ class MelissaClimate(ClimateEntity):
"""Return the maximum supported temperature for the thermostat."""
return 30
@property
def supported_features(self):
"""Return the list of supported features."""
return SUPPORT_FLAGS
async def async_set_temperature(self, **kwargs):
"""Set new target temperature."""
temp = kwargs.get(ATTR_TEMPERATURE)

View file

@ -5,11 +5,8 @@ from datetime import datetime
import struct
from typing import Any
from homeassistant.components.climate import ClimateEntity
from homeassistant.components.climate.const import (
HVAC_MODE_AUTO,
SUPPORT_TARGET_TEMPERATURE,
)
from homeassistant.components.climate import ClimateEntity, ClimateEntityFeature
from homeassistant.components.climate.const import HVAC_MODE_AUTO
from homeassistant.const import (
ATTR_TEMPERATURE,
CONF_NAME,
@ -63,6 +60,8 @@ async def async_setup_platform(
class ModbusThermostat(BaseStructPlatform, RestoreEntity, ClimateEntity):
"""Representation of a Modbus Thermostat."""
_attr_supported_features = ClimateEntityFeature.TARGET_TEMPERATURE
def __init__(
self,
hub: ModbusHub,
@ -73,7 +72,6 @@ class ModbusThermostat(BaseStructPlatform, RestoreEntity, ClimateEntity):
self._target_temperature_register = config[CONF_TARGET_TEMP]
self._unit = config[CONF_TEMPERATURE_UNIT]
self._attr_supported_features = SUPPORT_TARGET_TEMPERATURE
self._attr_hvac_mode = HVAC_MODE_AUTO
self._attr_hvac_modes = [HVAC_MODE_AUTO]
self._attr_current_temperature = None

View file

@ -4,7 +4,7 @@ from __future__ import annotations
from datetime import datetime
from typing import Any
from homeassistant.components.cover import SUPPORT_CLOSE, SUPPORT_OPEN, CoverEntity
from homeassistant.components.cover import CoverEntity, CoverEntityFeature
from homeassistant.const import (
CONF_COVERS,
CONF_NAME,
@ -59,6 +59,8 @@ async def async_setup_platform(
class ModbusCover(BasePlatform, CoverEntity, RestoreEntity):
"""Representation of a Modbus cover."""
_attr_supported_features = CoverEntityFeature.OPEN | CoverEntityFeature.CLOSE
def __init__(
self,
hub: ModbusHub,
@ -73,7 +75,6 @@ class ModbusCover(BasePlatform, CoverEntity, RestoreEntity):
self._status_register = config.get(CONF_STATUS_REGISTER)
self._status_register_type = config[CONF_STATUS_REGISTER_TYPE]
self._attr_supported_features = SUPPORT_OPEN | SUPPORT_CLOSE
self._attr_is_closed = False
# If we read cover status from coil, and not from optional status register,

View file

@ -6,7 +6,7 @@ from typing import Any
from aiomodernforms.const import FAN_POWER_OFF, FAN_POWER_ON
import voluptuous as vol
from homeassistant.components.fan import SUPPORT_DIRECTION, SUPPORT_SET_SPEED, FanEntity
from homeassistant.components.fan import FanEntity, FanEntityFeature
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.helpers import entity_platform
@ -72,6 +72,8 @@ class ModernFormsFanEntity(FanEntity, ModernFormsDeviceEntity):
SPEED_RANGE = (1, 6) # off is not included
_attr_supported_features = FanEntityFeature.DIRECTION | FanEntityFeature.SET_SPEED
def __init__(
self, entry_id: str, coordinator: ModernFormsDataUpdateCoordinator
) -> None:
@ -83,11 +85,6 @@ class ModernFormsFanEntity(FanEntity, ModernFormsDeviceEntity):
)
self._attr_unique_id = f"{self.coordinator.data.info.mac_address}"
@property
def supported_features(self) -> int:
"""Flag supported features."""
return SUPPORT_DIRECTION | SUPPORT_SET_SPEED
@property
def percentage(self) -> int | None:
"""Return the current speed percentage."""

View file

@ -1,15 +1,13 @@
"""Support for Alpha2 room control unit via Alpha2 base."""
import logging
from homeassistant.components.climate import ClimateEntity
from homeassistant.components.climate import ClimateEntity, ClimateEntityFeature
from homeassistant.components.climate.const import (
CURRENT_HVAC_COOL,
CURRENT_HVAC_HEAT,
CURRENT_HVAC_IDLE,
HVAC_MODE_COOL,
HVAC_MODE_HEAT,
SUPPORT_PRESET_MODE,
SUPPORT_TARGET_TEMPERATURE,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS
@ -43,7 +41,9 @@ class Alpha2Climate(CoordinatorEntity[Alpha2BaseCoordinator], ClimateEntity):
target_temperature_step = 0.2
_attr_supported_features = SUPPORT_TARGET_TEMPERATURE | SUPPORT_PRESET_MODE
_attr_supported_features = (
ClimateEntityFeature.TARGET_TEMPERATURE | ClimateEntityFeature.PRESET_MODE
)
_attr_hvac_modes = [HVAC_MODE_HEAT, HVAC_MODE_COOL]
_attr_temperature_unit = TEMP_CELSIUS
_attr_preset_modes = [PRESET_AUTO, PRESET_DAY, PRESET_NIGHT]

View file

@ -4,14 +4,9 @@ import logging
from serial import SerialException
from homeassistant import core
from homeassistant.components.media_player import MediaPlayerEntity
from homeassistant.components.media_player.const import (
SUPPORT_SELECT_SOURCE,
SUPPORT_TURN_OFF,
SUPPORT_TURN_ON,
SUPPORT_VOLUME_MUTE,
SUPPORT_VOLUME_SET,
SUPPORT_VOLUME_STEP,
from homeassistant.components.media_player import (
MediaPlayerEntity,
MediaPlayerEntityFeature,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_PORT, STATE_OFF, STATE_ON
@ -33,15 +28,6 @@ _LOGGER = logging.getLogger(__name__)
PARALLEL_UPDATES = 1
SUPPORT_MONOPRICE = (
SUPPORT_VOLUME_MUTE
| SUPPORT_VOLUME_SET
| SUPPORT_VOLUME_STEP
| SUPPORT_TURN_ON
| SUPPORT_TURN_OFF
| SUPPORT_SELECT_SOURCE
)
@core.callback
def _get_sources_from_dict(data):
@ -127,6 +113,15 @@ async def async_setup_entry(
class MonopriceZone(MediaPlayerEntity):
"""Representation of a Monoprice amplifier zone."""
_attr_supported_features = (
MediaPlayerEntityFeature.VOLUME_MUTE
| MediaPlayerEntityFeature.VOLUME_SET
| MediaPlayerEntityFeature.VOLUME_STEP
| MediaPlayerEntityFeature.TURN_ON
| MediaPlayerEntityFeature.TURN_OFF
| MediaPlayerEntityFeature.SELECT_SOURCE
)
def __init__(self, monoprice, sources, namespace, zone_id):
"""Initialize new zone."""
self._monoprice = monoprice
@ -211,11 +206,6 @@ class MonopriceZone(MediaPlayerEntity):
"""Boolean if volume is currently muted."""
return self._mute
@property
def supported_features(self):
"""Return flag of media commands that are supported."""
return SUPPORT_MONOPRICE
@property
def media_title(self):
"""Return the current source as medial title."""

View file

@ -12,7 +12,11 @@ from mpd.asyncio import MPDClient
import voluptuous as vol
from homeassistant.components import media_source
from homeassistant.components.media_player import PLATFORM_SCHEMA, MediaPlayerEntity
from homeassistant.components.media_player import (
PLATFORM_SCHEMA,
MediaPlayerEntity,
MediaPlayerEntityFeature,
)
from homeassistant.components.media_player.browse_media import (
async_process_play_media_url,
)
@ -22,23 +26,6 @@ from homeassistant.components.media_player.const import (
REPEAT_MODE_ALL,
REPEAT_MODE_OFF,
REPEAT_MODE_ONE,
SUPPORT_BROWSE_MEDIA,
SUPPORT_CLEAR_PLAYLIST,
SUPPORT_NEXT_TRACK,
SUPPORT_PAUSE,
SUPPORT_PLAY,
SUPPORT_PLAY_MEDIA,
SUPPORT_PREVIOUS_TRACK,
SUPPORT_REPEAT_SET,
SUPPORT_SEEK,
SUPPORT_SELECT_SOURCE,
SUPPORT_SHUFFLE_SET,
SUPPORT_STOP,
SUPPORT_TURN_OFF,
SUPPORT_TURN_ON,
SUPPORT_VOLUME_MUTE,
SUPPORT_VOLUME_SET,
SUPPORT_VOLUME_STEP,
)
from homeassistant.const import (
CONF_HOST,
@ -64,19 +51,19 @@ DEFAULT_PORT = 6600
PLAYLIST_UPDATE_INTERVAL = timedelta(seconds=120)
SUPPORT_MPD = (
SUPPORT_PAUSE
| SUPPORT_PREVIOUS_TRACK
| SUPPORT_NEXT_TRACK
| SUPPORT_PLAY_MEDIA
| SUPPORT_PLAY
| SUPPORT_CLEAR_PLAYLIST
| SUPPORT_REPEAT_SET
| SUPPORT_SHUFFLE_SET
| SUPPORT_SEEK
| SUPPORT_STOP
| SUPPORT_TURN_OFF
| SUPPORT_TURN_ON
| SUPPORT_BROWSE_MEDIA
MediaPlayerEntityFeature.PAUSE
| MediaPlayerEntityFeature.PREVIOUS_TRACK
| MediaPlayerEntityFeature.NEXT_TRACK
| MediaPlayerEntityFeature.PLAY_MEDIA
| MediaPlayerEntityFeature.PLAY
| MediaPlayerEntityFeature.CLEAR_PLAYLIST
| MediaPlayerEntityFeature.REPEAT_SET
| MediaPlayerEntityFeature.SHUFFLE_SET
| MediaPlayerEntityFeature.SEEK
| MediaPlayerEntityFeature.STOP
| MediaPlayerEntityFeature.TURN_OFF
| MediaPlayerEntityFeature.TURN_ON
| MediaPlayerEntityFeature.BROWSE_MEDIA
)
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
@ -373,9 +360,13 @@ class MpdDevice(MediaPlayerEntity):
supported = SUPPORT_MPD
if "volume" in self._status:
supported |= SUPPORT_VOLUME_SET | SUPPORT_VOLUME_STEP | SUPPORT_VOLUME_MUTE
supported |= (
MediaPlayerEntityFeature.VOLUME_SET
| MediaPlayerEntityFeature.VOLUME_STEP
| MediaPlayerEntityFeature.VOLUME_MUTE
)
if self._playlists is not None:
supported |= SUPPORT_SELECT_SOURCE
supported |= MediaPlayerEntityFeature.SELECT_SOURCE
return supported

View file

@ -3,10 +3,9 @@ from pymyq.const import DEVICE_TYPE_GATE as MYQ_DEVICE_TYPE_GATE
from pymyq.errors import MyQError
from homeassistant.components.cover import (
SUPPORT_CLOSE,
SUPPORT_OPEN,
CoverDeviceClass,
CoverEntity,
CoverEntityFeature,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import STATE_CLOSED, STATE_CLOSING, STATE_OPEN, STATE_OPENING
@ -36,7 +35,7 @@ async def async_setup_entry(
class MyQCover(MyQEntity, CoverEntity):
"""Representation of a MyQ cover."""
_attr_supported_features = SUPPORT_OPEN | SUPPORT_CLOSE
_attr_supported_features = CoverEntityFeature.OPEN | CoverEntityFeature.CLOSE
def __init__(self, coordinator, device):
"""Initialize with API object, device id."""

View file

@ -4,7 +4,7 @@ from __future__ import annotations
from typing import Any
from homeassistant.components import mysensors
from homeassistant.components.climate import ClimateEntity
from homeassistant.components.climate import ClimateEntity, ClimateEntityFeature
from homeassistant.components.climate.const import (
ATTR_TARGET_TEMP_HIGH,
ATTR_TARGET_TEMP_LOW,
@ -12,9 +12,6 @@ from homeassistant.components.climate.const import (
HVAC_MODE_COOL,
HVAC_MODE_HEAT,
HVAC_MODE_OFF,
SUPPORT_FAN_MODE,
SUPPORT_TARGET_TEMPERATURE,
SUPPORT_TARGET_TEMPERATURE_RANGE,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import (
@ -84,14 +81,14 @@ class MySensorsHVAC(mysensors.device.MySensorsEntity, ClimateEntity):
features = 0
set_req = self.gateway.const.SetReq
if set_req.V_HVAC_SPEED in self._values:
features = features | SUPPORT_FAN_MODE
features = features | ClimateEntityFeature.FAN_MODE
if (
set_req.V_HVAC_SETPOINT_COOL in self._values
and set_req.V_HVAC_SETPOINT_HEAT in self._values
):
features = features | SUPPORT_TARGET_TEMPERATURE_RANGE
features = features | ClimateEntityFeature.TARGET_TEMPERATURE_RANGE
else:
features = features | SUPPORT_TARGET_TEMPERATURE
features = features | ClimateEntityFeature.TARGET_TEMPERATURE
return features
@property

View file

@ -39,6 +39,7 @@ from homeassistant.components.climate.const import (
SERVICE_SET_HVAC_MODE,
SERVICE_SET_PRESET_MODE,
SERVICE_SET_TEMPERATURE,
ClimateEntityFeature,
)
from homeassistant.components.maxcube.climate import (
MAX_TEMPERATURE,
@ -46,7 +47,6 @@ from homeassistant.components.maxcube.climate import (
OFF_TEMPERATURE,
ON_TEMPERATURE,
PRESET_ON,
SUPPORT_FLAGS,
)
from homeassistant.const import (
ATTR_ENTITY_ID,
@ -89,7 +89,10 @@ async def test_setup_thermostat(hass, cube: MaxCube):
PRESET_ON,
]
assert state.attributes.get(ATTR_PRESET_MODE) == PRESET_NONE
assert state.attributes.get(ATTR_SUPPORTED_FEATURES) == SUPPORT_FLAGS
assert (
state.attributes.get(ATTR_SUPPORTED_FEATURES)
== ClimateEntityFeature.TARGET_TEMPERATURE | ClimateEntityFeature.PRESET_MODE
)
assert state.attributes.get(ATTR_MAX_TEMP) == MAX_TEMPERATURE
assert state.attributes.get(ATTR_MIN_TEMP) == 5.0
assert state.attributes.get(ATTR_CURRENT_TEMPERATURE) == 19.0