Use EntityFeature enum in components (b**) (#69336)

pull/69376/head
epenet 2022-04-05 23:53:45 +02:00 committed by GitHub
parent 6343752f98
commit 8af37235ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 97 additions and 122 deletions

View File

@ -3,7 +3,7 @@ from __future__ import annotations
import asyncio import asyncio
from homeassistant.components.climate import ClimateEntity from homeassistant.components.climate import ClimateEntity, ClimateEntityFeature
from homeassistant.components.climate.const import ( from homeassistant.components.climate.const import (
CURRENT_HVAC_HEAT, CURRENT_HVAC_HEAT,
CURRENT_HVAC_IDLE, CURRENT_HVAC_IDLE,
@ -14,9 +14,6 @@ from homeassistant.components.climate.const import (
HVAC_MODE_AUTO, HVAC_MODE_AUTO,
HVAC_MODE_HEAT, HVAC_MODE_HEAT,
HVAC_MODE_OFF, HVAC_MODE_OFF,
SUPPORT_FAN_MODE,
SUPPORT_PRESET_MODE,
SUPPORT_TARGET_TEMPERATURE,
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ( from homeassistant.const import (
@ -79,9 +76,11 @@ class BalboaSpaClimate(BalboaEntity, ClimateEntity):
} }
scale = self._client.get_tempscale() scale = self._client.get_tempscale()
self._attr_preset_modes = self._client.get_heatmode_stringlist() self._attr_preset_modes = self._client.get_heatmode_stringlist()
self._attr_supported_features = SUPPORT_TARGET_TEMPERATURE | SUPPORT_PRESET_MODE self._attr_supported_features = (
ClimateEntityFeature.TARGET_TEMPERATURE | ClimateEntityFeature.PRESET_MODE
)
if self._client.have_blower(): if self._client.have_blower():
self._attr_supported_features |= SUPPORT_FAN_MODE self._attr_supported_features |= ClimateEntityFeature.FAN_MODE
self._attr_min_temp = self._client.tmin[self._client.TEMPRANGE_LOW][scale] self._attr_min_temp = self._client.tmin[self._client.TEMPRANGE_LOW][scale]
self._attr_max_temp = self._client.tmax[self._client.TEMPRANGE_HIGH][scale] self._attr_max_temp = self._client.tmax[self._client.TEMPRANGE_HIGH][scale]
self._attr_temperature_unit = TEMP_FAHRENHEIT self._attr_temperature_unit = TEMP_FAHRENHEIT

View File

@ -8,11 +8,10 @@ from pyblackbird import get_blackbird
from serial import SerialException from serial import SerialException
import voluptuous as vol import voluptuous as vol
from homeassistant.components.media_player import PLATFORM_SCHEMA, MediaPlayerEntity from homeassistant.components.media_player import (
from homeassistant.components.media_player.const import ( PLATFORM_SCHEMA,
SUPPORT_SELECT_SOURCE, MediaPlayerEntity,
SUPPORT_TURN_OFF, MediaPlayerEntityFeature,
SUPPORT_TURN_ON,
) )
from homeassistant.const import ( from homeassistant.const import (
ATTR_ENTITY_ID, ATTR_ENTITY_ID,
@ -32,8 +31,6 @@ from .const import DOMAIN, SERVICE_SETALLZONES
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
SUPPORT_BLACKBIRD = SUPPORT_TURN_ON | SUPPORT_TURN_OFF | SUPPORT_SELECT_SOURCE
MEDIA_PLAYER_SCHEMA = vol.Schema({ATTR_ENTITY_ID: cv.comp_entity_ids}) MEDIA_PLAYER_SCHEMA = vol.Schema({ATTR_ENTITY_ID: cv.comp_entity_ids})
ZONE_SCHEMA = vol.Schema({vol.Required(CONF_NAME): cv.string}) ZONE_SCHEMA = vol.Schema({vol.Required(CONF_NAME): cv.string})
@ -141,7 +138,11 @@ def setup_platform(
class BlackbirdZone(MediaPlayerEntity): class BlackbirdZone(MediaPlayerEntity):
"""Representation of a Blackbird matrix zone.""" """Representation of a Blackbird matrix zone."""
_attr_supported_features = SUPPORT_BLACKBIRD _attr_supported_features = (
MediaPlayerEntityFeature.TURN_ON
| MediaPlayerEntityFeature.TURN_OFF
| MediaPlayerEntityFeature.SELECT_SOURCE
)
def __init__(self, blackbird, sources, zone_id, zone_name): def __init__(self, blackbird, sources, zone_id, zone_name):
"""Initialize new zone.""" """Initialize new zone."""

View File

@ -1,12 +1,11 @@
"""BleBox climate entity.""" """BleBox climate entity."""
from homeassistant.components.climate import ClimateEntity from homeassistant.components.climate import ClimateEntity, ClimateEntityFeature
from homeassistant.components.climate.const import ( from homeassistant.components.climate.const import (
CURRENT_HVAC_HEAT, CURRENT_HVAC_HEAT,
CURRENT_HVAC_IDLE, CURRENT_HVAC_IDLE,
CURRENT_HVAC_OFF, CURRENT_HVAC_OFF,
HVAC_MODE_HEAT, HVAC_MODE_HEAT,
HVAC_MODE_OFF, HVAC_MODE_OFF,
SUPPORT_TARGET_TEMPERATURE,
) )
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
@ -31,7 +30,7 @@ async def async_setup_entry(
class BleBoxClimateEntity(BleBoxEntity, ClimateEntity): class BleBoxClimateEntity(BleBoxEntity, ClimateEntity):
"""Representation of a BleBox climate feature (saunaBox).""" """Representation of a BleBox climate feature (saunaBox)."""
_attr_supported_features = SUPPORT_TARGET_TEMPERATURE _attr_supported_features = ClimateEntityFeature.TARGET_TEMPERATURE
_attr_hvac_modes = [HVAC_MODE_OFF, HVAC_MODE_HEAT] _attr_hvac_modes = [HVAC_MODE_OFF, HVAC_MODE_HEAT]
_attr_temperature_unit = TEMP_CELSIUS _attr_temperature_unit = TEMP_CELSIUS

View File

@ -1,11 +1,8 @@
"""BleBox cover entity.""" """BleBox cover entity."""
from homeassistant.components.cover import ( from homeassistant.components.cover import (
ATTR_POSITION, ATTR_POSITION,
SUPPORT_CLOSE,
SUPPORT_OPEN,
SUPPORT_SET_POSITION,
SUPPORT_STOP,
CoverEntity, CoverEntity,
CoverEntityFeature,
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import STATE_CLOSED, STATE_CLOSING, STATE_OPENING from homeassistant.const import STATE_CLOSED, STATE_CLOSING, STATE_OPENING
@ -35,9 +32,11 @@ class BleBoxCoverEntity(BleBoxEntity, CoverEntity):
"""Initialize a BleBox cover feature.""" """Initialize a BleBox cover feature."""
super().__init__(feature) super().__init__(feature)
self._attr_device_class = BLEBOX_TO_HASS_DEVICE_CLASSES[feature.device_class] self._attr_device_class = BLEBOX_TO_HASS_DEVICE_CLASSES[feature.device_class]
position = SUPPORT_SET_POSITION if feature.is_slider else 0 position = CoverEntityFeature.SET_POSITION if feature.is_slider else 0
stop = SUPPORT_STOP if feature.has_stop else 0 stop = CoverEntityFeature.STOP if feature.has_stop else 0
self._attr_supported_features = position | stop | SUPPORT_OPEN | SUPPORT_CLOSE self._attr_supported_features = (
position | stop | CoverEntityFeature.OPEN | CoverEntityFeature.CLOSE
)
@property @property
def current_cover_position(self): def current_cover_position(self):

View File

@ -1,8 +1,10 @@
"""Support for Blink Alarm Control Panel.""" """Support for Blink Alarm Control Panel."""
import logging import logging
from homeassistant.components.alarm_control_panel import AlarmControlPanelEntity from homeassistant.components.alarm_control_panel import (
from homeassistant.components.alarm_control_panel.const import SUPPORT_ALARM_ARM_AWAY AlarmControlPanelEntity,
AlarmControlPanelEntityFeature,
)
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ( from homeassistant.const import (
ATTR_ATTRIBUTION, ATTR_ATTRIBUTION,
@ -36,7 +38,7 @@ class BlinkSyncModule(AlarmControlPanelEntity):
"""Representation of a Blink Alarm Control Panel.""" """Representation of a Blink Alarm Control Panel."""
_attr_icon = ICON _attr_icon = ICON
_attr_supported_features = SUPPORT_ALARM_ARM_AWAY _attr_supported_features = AlarmControlPanelEntityFeature.ARM_AWAY
def __init__(self, data, name, sync): def __init__(self, data, name, sync):
"""Initialize the alarm control panel.""" """Initialize the alarm control panel."""

View File

@ -16,27 +16,17 @@ import voluptuous as vol
import xmltodict import xmltodict
from homeassistant.components import media_source 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 ( from homeassistant.components.media_player.browse_media import (
async_process_play_media_url, async_process_play_media_url,
) )
from homeassistant.components.media_player.const import ( from homeassistant.components.media_player.const import (
ATTR_MEDIA_ENQUEUE, ATTR_MEDIA_ENQUEUE,
MEDIA_TYPE_MUSIC, MEDIA_TYPE_MUSIC,
SUPPORT_BROWSE_MEDIA,
SUPPORT_CLEAR_PLAYLIST,
SUPPORT_NEXT_TRACK,
SUPPORT_PAUSE,
SUPPORT_PLAY,
SUPPORT_PLAY_MEDIA,
SUPPORT_PREVIOUS_TRACK,
SUPPORT_SEEK,
SUPPORT_SELECT_SOURCE,
SUPPORT_SHUFFLE_SET,
SUPPORT_STOP,
SUPPORT_VOLUME_MUTE,
SUPPORT_VOLUME_SET,
SUPPORT_VOLUME_STEP,
) )
from homeassistant.const import ( from homeassistant.const import (
ATTR_ENTITY_ID, ATTR_ENTITY_ID,
@ -803,34 +793,41 @@ class BluesoundPlayer(MediaPlayerEntity):
return 0 return 0
if self.is_grouped and not self.is_master: if self.is_grouped and not self.is_master:
return SUPPORT_VOLUME_STEP | SUPPORT_VOLUME_SET | SUPPORT_VOLUME_MUTE return (
MediaPlayerEntityFeature.VOLUME_STEP
| MediaPlayerEntityFeature.VOLUME_SET
| MediaPlayerEntityFeature.VOLUME_MUTE
)
supported = SUPPORT_CLEAR_PLAYLIST | SUPPORT_BROWSE_MEDIA supported = (
MediaPlayerEntityFeature.CLEAR_PLAYLIST
| MediaPlayerEntityFeature.BROWSE_MEDIA
)
if self._status.get("indexing", "0") == "0": if self._status.get("indexing", "0") == "0":
supported = ( supported = (
supported supported
| SUPPORT_PAUSE | MediaPlayerEntityFeature.PAUSE
| SUPPORT_PREVIOUS_TRACK | MediaPlayerEntityFeature.PREVIOUS_TRACK
| SUPPORT_NEXT_TRACK | MediaPlayerEntityFeature.NEXT_TRACK
| SUPPORT_PLAY_MEDIA | MediaPlayerEntityFeature.PLAY_MEDIA
| SUPPORT_STOP | MediaPlayerEntityFeature.STOP
| SUPPORT_PLAY | MediaPlayerEntityFeature.PLAY
| SUPPORT_SELECT_SOURCE | MediaPlayerEntityFeature.SELECT_SOURCE
| SUPPORT_SHUFFLE_SET | MediaPlayerEntityFeature.SHUFFLE_SET
) )
current_vol = self.volume_level current_vol = self.volume_level
if current_vol is not None and current_vol >= 0: if current_vol is not None and current_vol >= 0:
supported = ( supported = (
supported supported
| SUPPORT_VOLUME_STEP | MediaPlayerEntityFeature.VOLUME_STEP
| SUPPORT_VOLUME_SET | MediaPlayerEntityFeature.VOLUME_SET
| SUPPORT_VOLUME_MUTE | MediaPlayerEntityFeature.VOLUME_MUTE
) )
if self._status.get("canSeek", "") == "1": if self._status.get("canSeek", "") == "1":
supported = supported | SUPPORT_SEEK supported = supported | MediaPlayerEntityFeature.SEEK
return supported return supported

View File

@ -6,14 +6,9 @@ from typing import Any
from bond_api import Action, BPUPSubscriptions, DeviceType from bond_api import Action, BPUPSubscriptions, DeviceType
from homeassistant.components.cover import ( from homeassistant.components.cover import (
SUPPORT_CLOSE,
SUPPORT_CLOSE_TILT,
SUPPORT_OPEN,
SUPPORT_OPEN_TILT,
SUPPORT_STOP,
SUPPORT_STOP_TILT,
CoverDeviceClass, CoverDeviceClass,
CoverEntity, CoverEntity,
CoverEntityFeature,
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
@ -56,18 +51,18 @@ class BondCover(BondEntity, CoverEntity):
super().__init__(hub, device, bpup_subs) super().__init__(hub, device, bpup_subs)
supported_features = 0 supported_features = 0
if self._device.supports_open(): if self._device.supports_open():
supported_features |= SUPPORT_OPEN supported_features |= CoverEntityFeature.OPEN
if self._device.supports_close(): if self._device.supports_close():
supported_features |= SUPPORT_CLOSE supported_features |= CoverEntityFeature.CLOSE
if self._device.supports_tilt_open(): if self._device.supports_tilt_open():
supported_features |= SUPPORT_OPEN_TILT supported_features |= CoverEntityFeature.OPEN_TILT
if self._device.supports_tilt_close(): if self._device.supports_tilt_close():
supported_features |= SUPPORT_CLOSE_TILT supported_features |= CoverEntityFeature.CLOSE_TILT
if self._device.supports_hold(): if self._device.supports_hold():
if self._device.supports_open() or self._device.supports_close(): if self._device.supports_open() or self._device.supports_close():
supported_features |= SUPPORT_STOP supported_features |= CoverEntityFeature.STOP
if self._device.supports_tilt_open() or self._device.supports_tilt_close(): if self._device.supports_tilt_open() or self._device.supports_tilt_close():
supported_features |= SUPPORT_STOP_TILT supported_features |= CoverEntityFeature.STOP_TILT
self._attr_supported_features = supported_features self._attr_supported_features = supported_features
def _apply_state(self, state: dict) -> None: def _apply_state(self, state: dict) -> None:

View File

@ -12,9 +12,8 @@ import voluptuous as vol
from homeassistant.components.fan import ( from homeassistant.components.fan import (
DIRECTION_FORWARD, DIRECTION_FORWARD,
DIRECTION_REVERSE, DIRECTION_REVERSE,
SUPPORT_DIRECTION,
SUPPORT_SET_SPEED,
FanEntity, FanEntity,
FanEntityFeature,
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
@ -90,9 +89,9 @@ class BondFan(BondEntity, FanEntity):
"""Flag supported features.""" """Flag supported features."""
features = 0 features = 0
if self._device.supports_speed(): if self._device.supports_speed():
features |= SUPPORT_SET_SPEED features |= FanEntityFeature.SET_SPEED
if self._device.supports_direction(): if self._device.supports_direction():
features |= SUPPORT_DIRECTION features |= FanEntityFeature.DIRECTION
return features return features

View File

@ -3,12 +3,9 @@ from boschshcpy import SHCSession, SHCShutterControl
from homeassistant.components.cover import ( from homeassistant.components.cover import (
ATTR_POSITION, ATTR_POSITION,
SUPPORT_CLOSE,
SUPPORT_OPEN,
SUPPORT_SET_POSITION,
SUPPORT_STOP,
CoverDeviceClass, CoverDeviceClass,
CoverEntity, CoverEntity,
CoverEntityFeature,
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
@ -46,7 +43,10 @@ class ShutterControlCover(SHCEntity, CoverEntity):
_attr_device_class = CoverDeviceClass.SHUTTER _attr_device_class = CoverDeviceClass.SHUTTER
_attr_supported_features = ( _attr_supported_features = (
SUPPORT_OPEN | SUPPORT_CLOSE | SUPPORT_STOP | SUPPORT_SET_POSITION CoverEntityFeature.OPEN
| CoverEntityFeature.CLOSE
| CoverEntityFeature.STOP
| CoverEntityFeature.SET_POSITION
) )
@property @property

View File

@ -1,24 +1,10 @@
"""Support for interface with a Bravia TV.""" """Support for interface with a Bravia TV."""
from __future__ import annotations from __future__ import annotations
from typing import Final
from homeassistant.components.media_player import ( from homeassistant.components.media_player import (
MediaPlayerDeviceClass, MediaPlayerDeviceClass,
MediaPlayerEntity, MediaPlayerEntity,
) MediaPlayerEntityFeature,
from homeassistant.components.media_player.const import (
SUPPORT_NEXT_TRACK,
SUPPORT_PAUSE,
SUPPORT_PLAY,
SUPPORT_PREVIOUS_TRACK,
SUPPORT_SELECT_SOURCE,
SUPPORT_STOP,
SUPPORT_TURN_OFF,
SUPPORT_TURN_ON,
SUPPORT_VOLUME_MUTE,
SUPPORT_VOLUME_SET,
SUPPORT_VOLUME_STEP,
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import STATE_OFF, STATE_PAUSED, STATE_PLAYING from homeassistant.const import STATE_OFF, STATE_PAUSED, STATE_PLAYING
@ -30,20 +16,6 @@ from homeassistant.helpers.update_coordinator import CoordinatorEntity
from . import BraviaTVCoordinator from . import BraviaTVCoordinator
from .const import ATTR_MANUFACTURER, DEFAULT_NAME, DOMAIN from .const import ATTR_MANUFACTURER, DEFAULT_NAME, DOMAIN
SUPPORT_BRAVIA: Final = (
SUPPORT_PAUSE
| SUPPORT_VOLUME_STEP
| SUPPORT_VOLUME_MUTE
| SUPPORT_VOLUME_SET
| SUPPORT_PREVIOUS_TRACK
| SUPPORT_NEXT_TRACK
| SUPPORT_TURN_ON
| SUPPORT_TURN_OFF
| SUPPORT_SELECT_SOURCE
| SUPPORT_PLAY
| SUPPORT_STOP
)
async def async_setup_entry( async def async_setup_entry(
hass: HomeAssistant, hass: HomeAssistant,
@ -71,7 +43,19 @@ class BraviaTVMediaPlayer(CoordinatorEntity[BraviaTVCoordinator], MediaPlayerEnt
"""Representation of a Bravia TV Media Player.""" """Representation of a Bravia TV Media Player."""
_attr_device_class = MediaPlayerDeviceClass.TV _attr_device_class = MediaPlayerDeviceClass.TV
_attr_supported_features = SUPPORT_BRAVIA _attr_supported_features = (
MediaPlayerEntityFeature.PAUSE
| MediaPlayerEntityFeature.VOLUME_STEP
| MediaPlayerEntityFeature.VOLUME_MUTE
| MediaPlayerEntityFeature.VOLUME_SET
| MediaPlayerEntityFeature.PREVIOUS_TRACK
| MediaPlayerEntityFeature.NEXT_TRACK
| MediaPlayerEntityFeature.TURN_ON
| MediaPlayerEntityFeature.TURN_OFF
| MediaPlayerEntityFeature.SELECT_SOURCE
| MediaPlayerEntityFeature.PLAY
| MediaPlayerEntityFeature.STOP
)
def __init__( def __init__(
self, self,

View File

@ -27,9 +27,8 @@ from homeassistant.components.remote import (
SERVICE_DELETE_COMMAND, SERVICE_DELETE_COMMAND,
SERVICE_LEARN_COMMAND, SERVICE_LEARN_COMMAND,
SERVICE_SEND_COMMAND, SERVICE_SEND_COMMAND,
SUPPORT_DELETE_COMMAND,
SUPPORT_LEARN_COMMAND,
RemoteEntity, RemoteEntity,
RemoteEntityFeature,
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ATTR_COMMAND, STATE_OFF from homeassistant.const import ATTR_COMMAND, STATE_OFF
@ -117,7 +116,9 @@ class BroadlinkRemote(BroadlinkEntity, RemoteEntity, RestoreEntity):
self._attr_name = f"{device.name} Remote" self._attr_name = f"{device.name} Remote"
self._attr_is_on = True self._attr_is_on = True
self._attr_supported_features = SUPPORT_LEARN_COMMAND | SUPPORT_DELETE_COMMAND self._attr_supported_features = (
RemoteEntityFeature.LEARN_COMMAND | RemoteEntityFeature.DELETE_COMMAND
)
self._attr_unique_id = device.unique_id self._attr_unique_id = device.unique_id
def _extract_codes(self, commands, device=None): def _extract_codes(self, commands, device=None):

View File

@ -9,11 +9,9 @@ from brunt import BruntClientAsync, Thing
from homeassistant.components.cover import ( from homeassistant.components.cover import (
ATTR_POSITION, ATTR_POSITION,
SUPPORT_CLOSE,
SUPPORT_OPEN,
SUPPORT_SET_POSITION,
CoverDeviceClass, CoverDeviceClass,
CoverEntity, CoverEntity,
CoverEntityFeature,
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
@ -37,8 +35,6 @@ from .const import (
REGULAR_INTERVAL, REGULAR_INTERVAL,
) )
COVER_FEATURES = SUPPORT_OPEN | SUPPORT_CLOSE | SUPPORT_SET_POSITION
async def async_setup_entry( async def async_setup_entry(
hass: HomeAssistant, hass: HomeAssistant,
@ -62,6 +58,12 @@ class BruntDevice(CoordinatorEntity, CoverEntity):
Contains the common logic for all Brunt devices. Contains the common logic for all Brunt devices.
""" """
_attr_supported_features = (
CoverEntityFeature.OPEN
| CoverEntityFeature.CLOSE
| CoverEntityFeature.SET_POSITION
)
def __init__( def __init__(
self, self,
coordinator: DataUpdateCoordinator, coordinator: DataUpdateCoordinator,
@ -81,7 +83,6 @@ class BruntDevice(CoordinatorEntity, CoverEntity):
self._attr_name = self._thing.name self._attr_name = self._thing.name
self._attr_device_class = CoverDeviceClass.BLIND self._attr_device_class = CoverDeviceClass.BLIND
self._attr_supported_features = COVER_FEATURES
self._attr_attribution = ATTRIBUTION self._attr_attribution = ATTRIBUTION
self._attr_device_info = DeviceInfo( self._attr_device_info = DeviceInfo(
identifiers={(DOMAIN, self._attr_unique_id)}, identifiers={(DOMAIN, self._attr_unique_id)},

View File

@ -7,7 +7,7 @@ from typing import Any
from bsblan import BSBLan, BSBLanError, Info, State from bsblan import BSBLan, BSBLanError, Info, State
from homeassistant.components.climate import ClimateEntity from homeassistant.components.climate import ClimateEntity, ClimateEntityFeature
from homeassistant.components.climate.const import ( from homeassistant.components.climate.const import (
ATTR_HVAC_MODE, ATTR_HVAC_MODE,
ATTR_PRESET_MODE, ATTR_PRESET_MODE,
@ -16,8 +16,6 @@ from homeassistant.components.climate.const import (
HVAC_MODE_OFF, HVAC_MODE_OFF,
PRESET_ECO, PRESET_ECO,
PRESET_NONE, PRESET_NONE,
SUPPORT_PRESET_MODE,
SUPPORT_TARGET_TEMPERATURE,
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS, TEMP_FAHRENHEIT from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS, TEMP_FAHRENHEIT
@ -32,8 +30,6 @@ _LOGGER = logging.getLogger(__name__)
PARALLEL_UPDATES = 1 PARALLEL_UPDATES = 1
SCAN_INTERVAL = timedelta(seconds=20) SCAN_INTERVAL = timedelta(seconds=20)
SUPPORT_FLAGS = SUPPORT_TARGET_TEMPERATURE | SUPPORT_PRESET_MODE
HVAC_MODES = [ HVAC_MODES = [
HVAC_MODE_AUTO, HVAC_MODE_AUTO,
HVAC_MODE_HEAT, HVAC_MODE_HEAT,
@ -76,7 +72,9 @@ async def async_setup_entry(
class BSBLanClimate(ClimateEntity): class BSBLanClimate(ClimateEntity):
"""Defines a BSBLan climate device.""" """Defines a BSBLan climate device."""
_attr_supported_features = SUPPORT_FLAGS _attr_supported_features = (
ClimateEntityFeature.TARGET_TEMPERATURE | ClimateEntityFeature.PRESET_MODE
)
_attr_hvac_modes = HVAC_MODES _attr_hvac_modes = HVAC_MODES
_attr_preset_modes = PRESET_MODES _attr_preset_modes = PRESET_MODES