mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 14:17:45 +00:00
Use EntityFeature enum in components (c**) (#69341)
This commit is contained in:
parent
246f4e081a
commit
6343752f98
@ -10,11 +10,9 @@ from canary.api import (
|
|||||||
Location,
|
Location,
|
||||||
)
|
)
|
||||||
|
|
||||||
from homeassistant.components.alarm_control_panel import AlarmControlPanelEntity
|
from homeassistant.components.alarm_control_panel import (
|
||||||
from homeassistant.components.alarm_control_panel.const import (
|
AlarmControlPanelEntity,
|
||||||
SUPPORT_ALARM_ARM_AWAY,
|
AlarmControlPanelEntityFeature,
|
||||||
SUPPORT_ALARM_ARM_HOME,
|
|
||||||
SUPPORT_ALARM_ARM_NIGHT,
|
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
@ -54,7 +52,9 @@ class CanaryAlarm(
|
|||||||
"""Representation of a Canary alarm control panel."""
|
"""Representation of a Canary alarm control panel."""
|
||||||
|
|
||||||
_attr_supported_features = (
|
_attr_supported_features = (
|
||||||
SUPPORT_ALARM_ARM_HOME | SUPPORT_ALARM_ARM_AWAY | SUPPORT_ALARM_ARM_NIGHT
|
AlarmControlPanelEntityFeature.ARM_HOME
|
||||||
|
| AlarmControlPanelEntityFeature.ARM_AWAY
|
||||||
|
| AlarmControlPanelEntityFeature.ARM_NIGHT
|
||||||
)
|
)
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
|
@ -25,6 +25,7 @@ from homeassistant.components.media_player import (
|
|||||||
BrowseError,
|
BrowseError,
|
||||||
BrowseMedia,
|
BrowseMedia,
|
||||||
MediaPlayerEntity,
|
MediaPlayerEntity,
|
||||||
|
MediaPlayerEntityFeature,
|
||||||
async_process_play_media_url,
|
async_process_play_media_url,
|
||||||
)
|
)
|
||||||
from homeassistant.components.media_player.const import (
|
from homeassistant.components.media_player.const import (
|
||||||
@ -33,18 +34,6 @@ from homeassistant.components.media_player.const import (
|
|||||||
MEDIA_TYPE_MOVIE,
|
MEDIA_TYPE_MOVIE,
|
||||||
MEDIA_TYPE_MUSIC,
|
MEDIA_TYPE_MUSIC,
|
||||||
MEDIA_TYPE_TVSHOW,
|
MEDIA_TYPE_TVSHOW,
|
||||||
SUPPORT_BROWSE_MEDIA,
|
|
||||||
SUPPORT_NEXT_TRACK,
|
|
||||||
SUPPORT_PAUSE,
|
|
||||||
SUPPORT_PLAY,
|
|
||||||
SUPPORT_PLAY_MEDIA,
|
|
||||||
SUPPORT_PREVIOUS_TRACK,
|
|
||||||
SUPPORT_SEEK,
|
|
||||||
SUPPORT_STOP,
|
|
||||||
SUPPORT_TURN_OFF,
|
|
||||||
SUPPORT_TURN_ON,
|
|
||||||
SUPPORT_VOLUME_MUTE,
|
|
||||||
SUPPORT_VOLUME_SET,
|
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
@ -83,8 +72,6 @@ APP_IDS_UNRELIABLE_MEDIA_INFO = ("Netflix",)
|
|||||||
|
|
||||||
CAST_SPLASH = "https://www.home-assistant.io/images/cast/splash.png"
|
CAST_SPLASH = "https://www.home-assistant.io/images/cast/splash.png"
|
||||||
|
|
||||||
SUPPORT_CAST = SUPPORT_PLAY_MEDIA | SUPPORT_TURN_OFF
|
|
||||||
|
|
||||||
ENTITY_SCHEMA = vol.All(
|
ENTITY_SCHEMA = vol.All(
|
||||||
vol.Schema(
|
vol.Schema(
|
||||||
{
|
{
|
||||||
@ -805,30 +792,42 @@ class CastMediaPlayerEntity(CastDevice, MediaPlayerEntity):
|
|||||||
@property
|
@property
|
||||||
def supported_features(self):
|
def supported_features(self):
|
||||||
"""Flag media player features that are supported."""
|
"""Flag media player features that are supported."""
|
||||||
support = SUPPORT_CAST
|
support = (
|
||||||
|
MediaPlayerEntityFeature.PLAY_MEDIA | MediaPlayerEntityFeature.TURN_OFF
|
||||||
|
)
|
||||||
media_status = self._media_status()[0]
|
media_status = self._media_status()[0]
|
||||||
|
|
||||||
if self._chromecast and self._chromecast.cast_type in (
|
if self._chromecast and self._chromecast.cast_type in (
|
||||||
pychromecast.const.CAST_TYPE_CHROMECAST,
|
pychromecast.const.CAST_TYPE_CHROMECAST,
|
||||||
pychromecast.const.CAST_TYPE_AUDIO,
|
pychromecast.const.CAST_TYPE_AUDIO,
|
||||||
):
|
):
|
||||||
support |= SUPPORT_TURN_ON
|
support |= MediaPlayerEntityFeature.TURN_ON
|
||||||
|
|
||||||
if (
|
if (
|
||||||
self.cast_status
|
self.cast_status
|
||||||
and self.cast_status.volume_control_type != VOLUME_CONTROL_TYPE_FIXED
|
and self.cast_status.volume_control_type != VOLUME_CONTROL_TYPE_FIXED
|
||||||
):
|
):
|
||||||
support |= SUPPORT_VOLUME_MUTE | SUPPORT_VOLUME_SET
|
support |= (
|
||||||
|
MediaPlayerEntityFeature.VOLUME_MUTE
|
||||||
|
| MediaPlayerEntityFeature.VOLUME_SET
|
||||||
|
)
|
||||||
|
|
||||||
if media_status and self.app_id != CAST_APP_ID_HOMEASSISTANT_LOVELACE:
|
if media_status and self.app_id != CAST_APP_ID_HOMEASSISTANT_LOVELACE:
|
||||||
support |= SUPPORT_PAUSE | SUPPORT_PLAY | SUPPORT_STOP
|
support |= (
|
||||||
|
MediaPlayerEntityFeature.PAUSE
|
||||||
|
| MediaPlayerEntityFeature.PLAY
|
||||||
|
| MediaPlayerEntityFeature.STOP
|
||||||
|
)
|
||||||
if media_status.supports_queue_next:
|
if media_status.supports_queue_next:
|
||||||
support |= SUPPORT_PREVIOUS_TRACK | SUPPORT_NEXT_TRACK
|
support |= (
|
||||||
|
MediaPlayerEntityFeature.PREVIOUS_TRACK
|
||||||
|
| MediaPlayerEntityFeature.NEXT_TRACK
|
||||||
|
)
|
||||||
if media_status.supports_seek:
|
if media_status.supports_seek:
|
||||||
support |= SUPPORT_SEEK
|
support |= MediaPlayerEntityFeature.SEEK
|
||||||
|
|
||||||
if "media_source" in self.hass.config.components:
|
if "media_source" in self.hass.config.components:
|
||||||
support |= SUPPORT_BROWSE_MEDIA
|
support |= MediaPlayerEntityFeature.BROWSE_MEDIA
|
||||||
|
|
||||||
return support
|
return support
|
||||||
|
|
||||||
|
@ -4,20 +4,16 @@ from __future__ import annotations
|
|||||||
from pychannels import Channels
|
from pychannels import Channels
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.media_player import PLATFORM_SCHEMA, MediaPlayerEntity
|
from homeassistant.components.media_player import (
|
||||||
|
PLATFORM_SCHEMA,
|
||||||
|
MediaPlayerEntity,
|
||||||
|
MediaPlayerEntityFeature,
|
||||||
|
)
|
||||||
from homeassistant.components.media_player.const import (
|
from homeassistant.components.media_player.const import (
|
||||||
MEDIA_TYPE_CHANNEL,
|
MEDIA_TYPE_CHANNEL,
|
||||||
MEDIA_TYPE_EPISODE,
|
MEDIA_TYPE_EPISODE,
|
||||||
MEDIA_TYPE_MOVIE,
|
MEDIA_TYPE_MOVIE,
|
||||||
MEDIA_TYPE_TVSHOW,
|
MEDIA_TYPE_TVSHOW,
|
||||||
SUPPORT_NEXT_TRACK,
|
|
||||||
SUPPORT_PAUSE,
|
|
||||||
SUPPORT_PLAY,
|
|
||||||
SUPPORT_PLAY_MEDIA,
|
|
||||||
SUPPORT_PREVIOUS_TRACK,
|
|
||||||
SUPPORT_SELECT_SOURCE,
|
|
||||||
SUPPORT_STOP,
|
|
||||||
SUPPORT_VOLUME_MUTE,
|
|
||||||
)
|
)
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
ATTR_SECONDS,
|
ATTR_SECONDS,
|
||||||
@ -39,17 +35,6 @@ DATA_CHANNELS = "channels"
|
|||||||
DEFAULT_NAME = "Channels"
|
DEFAULT_NAME = "Channels"
|
||||||
DEFAULT_PORT = 57000
|
DEFAULT_PORT = 57000
|
||||||
|
|
||||||
FEATURE_SUPPORT = (
|
|
||||||
SUPPORT_PLAY
|
|
||||||
| SUPPORT_PAUSE
|
|
||||||
| SUPPORT_STOP
|
|
||||||
| SUPPORT_VOLUME_MUTE
|
|
||||||
| SUPPORT_NEXT_TRACK
|
|
||||||
| SUPPORT_PREVIOUS_TRACK
|
|
||||||
| SUPPORT_PLAY_MEDIA
|
|
||||||
| SUPPORT_SELECT_SOURCE
|
|
||||||
)
|
|
||||||
|
|
||||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
||||||
{
|
{
|
||||||
vol.Required(CONF_HOST): cv.string,
|
vol.Required(CONF_HOST): cv.string,
|
||||||
@ -91,6 +76,17 @@ async def async_setup_platform(
|
|||||||
class ChannelsPlayer(MediaPlayerEntity):
|
class ChannelsPlayer(MediaPlayerEntity):
|
||||||
"""Representation of a Channels instance."""
|
"""Representation of a Channels instance."""
|
||||||
|
|
||||||
|
_attr_supported_features = (
|
||||||
|
MediaPlayerEntityFeature.PLAY
|
||||||
|
| MediaPlayerEntityFeature.PAUSE
|
||||||
|
| MediaPlayerEntityFeature.STOP
|
||||||
|
| MediaPlayerEntityFeature.VOLUME_MUTE
|
||||||
|
| MediaPlayerEntityFeature.NEXT_TRACK
|
||||||
|
| MediaPlayerEntityFeature.PREVIOUS_TRACK
|
||||||
|
| MediaPlayerEntityFeature.PLAY_MEDIA
|
||||||
|
| MediaPlayerEntityFeature.SELECT_SOURCE
|
||||||
|
)
|
||||||
|
|
||||||
def __init__(self, name, host, port):
|
def __init__(self, name, host, port):
|
||||||
"""Initialize the Channels app."""
|
"""Initialize the Channels app."""
|
||||||
|
|
||||||
@ -215,11 +211,6 @@ class ChannelsPlayer(MediaPlayerEntity):
|
|||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@property
|
|
||||||
def supported_features(self):
|
|
||||||
"""Flag of media commands that are supported."""
|
|
||||||
return FEATURE_SUPPORT
|
|
||||||
|
|
||||||
def mute_volume(self, mute):
|
def mute_volume(self, mute):
|
||||||
"""Mute (true) or unmute (false) player."""
|
"""Mute (true) or unmute (false) player."""
|
||||||
if mute != self.muted:
|
if mute != self.muted:
|
||||||
|
@ -7,17 +7,12 @@ import time
|
|||||||
from clementineremote import ClementineRemote
|
from clementineremote import ClementineRemote
|
||||||
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,
|
||||||
MEDIA_TYPE_MUSIC,
|
MediaPlayerEntity,
|
||||||
SUPPORT_NEXT_TRACK,
|
MediaPlayerEntityFeature,
|
||||||
SUPPORT_PAUSE,
|
|
||||||
SUPPORT_PLAY,
|
|
||||||
SUPPORT_PREVIOUS_TRACK,
|
|
||||||
SUPPORT_SELECT_SOURCE,
|
|
||||||
SUPPORT_VOLUME_SET,
|
|
||||||
SUPPORT_VOLUME_STEP,
|
|
||||||
)
|
)
|
||||||
|
from homeassistant.components.media_player.const import MEDIA_TYPE_MUSIC
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_ACCESS_TOKEN,
|
CONF_ACCESS_TOKEN,
|
||||||
CONF_HOST,
|
CONF_HOST,
|
||||||
@ -37,16 +32,6 @@ DEFAULT_PORT = 5500
|
|||||||
|
|
||||||
SCAN_INTERVAL = timedelta(seconds=5)
|
SCAN_INTERVAL = timedelta(seconds=5)
|
||||||
|
|
||||||
SUPPORT_CLEMENTINE = (
|
|
||||||
SUPPORT_PAUSE
|
|
||||||
| SUPPORT_VOLUME_STEP
|
|
||||||
| SUPPORT_PREVIOUS_TRACK
|
|
||||||
| SUPPORT_VOLUME_SET
|
|
||||||
| SUPPORT_NEXT_TRACK
|
|
||||||
| SUPPORT_SELECT_SOURCE
|
|
||||||
| SUPPORT_PLAY
|
|
||||||
)
|
|
||||||
|
|
||||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
||||||
{
|
{
|
||||||
vol.Required(CONF_HOST): cv.string,
|
vol.Required(CONF_HOST): cv.string,
|
||||||
@ -78,7 +63,15 @@ class ClementineDevice(MediaPlayerEntity):
|
|||||||
"""Representation of Clementine Player."""
|
"""Representation of Clementine Player."""
|
||||||
|
|
||||||
_attr_media_content_type = MEDIA_TYPE_MUSIC
|
_attr_media_content_type = MEDIA_TYPE_MUSIC
|
||||||
_attr_supported_features = SUPPORT_CLEMENTINE
|
_attr_supported_features = (
|
||||||
|
MediaPlayerEntityFeature.PAUSE
|
||||||
|
| MediaPlayerEntityFeature.VOLUME_STEP
|
||||||
|
| MediaPlayerEntityFeature.PREVIOUS_TRACK
|
||||||
|
| MediaPlayerEntityFeature.VOLUME_SET
|
||||||
|
| MediaPlayerEntityFeature.NEXT_TRACK
|
||||||
|
| MediaPlayerEntityFeature.SELECT_SOURCE
|
||||||
|
| MediaPlayerEntityFeature.PLAY
|
||||||
|
)
|
||||||
|
|
||||||
def __init__(self, client, name):
|
def __init__(self, client, name):
|
||||||
"""Initialize the Clementine device."""
|
"""Initialize the Clementine device."""
|
||||||
|
@ -6,19 +6,14 @@ import logging
|
|||||||
from pycmus import exceptions, remote
|
from pycmus import exceptions, remote
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.media_player import PLATFORM_SCHEMA, MediaPlayerEntity
|
from homeassistant.components.media_player import (
|
||||||
|
PLATFORM_SCHEMA,
|
||||||
|
MediaPlayerEntity,
|
||||||
|
MediaPlayerEntityFeature,
|
||||||
|
)
|
||||||
from homeassistant.components.media_player.const import (
|
from homeassistant.components.media_player.const import (
|
||||||
MEDIA_TYPE_MUSIC,
|
MEDIA_TYPE_MUSIC,
|
||||||
MEDIA_TYPE_PLAYLIST,
|
MEDIA_TYPE_PLAYLIST,
|
||||||
SUPPORT_NEXT_TRACK,
|
|
||||||
SUPPORT_PAUSE,
|
|
||||||
SUPPORT_PLAY,
|
|
||||||
SUPPORT_PLAY_MEDIA,
|
|
||||||
SUPPORT_PREVIOUS_TRACK,
|
|
||||||
SUPPORT_SEEK,
|
|
||||||
SUPPORT_TURN_OFF,
|
|
||||||
SUPPORT_TURN_ON,
|
|
||||||
SUPPORT_VOLUME_SET,
|
|
||||||
)
|
)
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_HOST,
|
CONF_HOST,
|
||||||
@ -39,18 +34,6 @@ _LOGGER = logging.getLogger(__name__)
|
|||||||
DEFAULT_NAME = "cmus"
|
DEFAULT_NAME = "cmus"
|
||||||
DEFAULT_PORT = 3000
|
DEFAULT_PORT = 3000
|
||||||
|
|
||||||
SUPPORT_CMUS = (
|
|
||||||
SUPPORT_PAUSE
|
|
||||||
| SUPPORT_VOLUME_SET
|
|
||||||
| SUPPORT_TURN_OFF
|
|
||||||
| SUPPORT_TURN_ON
|
|
||||||
| SUPPORT_PREVIOUS_TRACK
|
|
||||||
| SUPPORT_NEXT_TRACK
|
|
||||||
| SUPPORT_PLAY_MEDIA
|
|
||||||
| SUPPORT_SEEK
|
|
||||||
| SUPPORT_PLAY
|
|
||||||
)
|
|
||||||
|
|
||||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
||||||
{
|
{
|
||||||
vol.Inclusive(CONF_HOST, "remote"): cv.string,
|
vol.Inclusive(CONF_HOST, "remote"): cv.string,
|
||||||
@ -109,7 +92,17 @@ class CmusDevice(MediaPlayerEntity):
|
|||||||
"""Representation of a running cmus."""
|
"""Representation of a running cmus."""
|
||||||
|
|
||||||
_attr_media_content_type = MEDIA_TYPE_MUSIC
|
_attr_media_content_type = MEDIA_TYPE_MUSIC
|
||||||
_attr_supported_features = SUPPORT_CMUS
|
_attr_supported_features = (
|
||||||
|
MediaPlayerEntityFeature.PAUSE
|
||||||
|
| MediaPlayerEntityFeature.VOLUME_SET
|
||||||
|
| MediaPlayerEntityFeature.TURN_OFF
|
||||||
|
| MediaPlayerEntityFeature.TURN_ON
|
||||||
|
| MediaPlayerEntityFeature.PREVIOUS_TRACK
|
||||||
|
| MediaPlayerEntityFeature.NEXT_TRACK
|
||||||
|
| MediaPlayerEntityFeature.PLAY_MEDIA
|
||||||
|
| MediaPlayerEntityFeature.SEEK
|
||||||
|
| MediaPlayerEntityFeature.PLAY
|
||||||
|
)
|
||||||
|
|
||||||
def __init__(self, device, name, server):
|
def __init__(self, device, name, server):
|
||||||
"""Initialize the CMUS device."""
|
"""Initialize the CMUS device."""
|
||||||
|
@ -13,7 +13,7 @@ from pycomfoconnect import (
|
|||||||
SENSOR_FAN_SPEED_MODE,
|
SENSOR_FAN_SPEED_MODE,
|
||||||
)
|
)
|
||||||
|
|
||||||
from homeassistant.components.fan import SUPPORT_SET_SPEED, FanEntity
|
from homeassistant.components.fan import FanEntity, FanEntityFeature
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
@ -53,6 +53,7 @@ def setup_platform(
|
|||||||
class ComfoConnectFan(FanEntity):
|
class ComfoConnectFan(FanEntity):
|
||||||
"""Representation of the ComfoConnect fan platform."""
|
"""Representation of the ComfoConnect fan platform."""
|
||||||
|
|
||||||
|
_attr_supported_features = FanEntityFeature.SET_SPEED
|
||||||
current_speed = None
|
current_speed = None
|
||||||
|
|
||||||
def __init__(self, ccb: ComfoConnectBridge) -> None:
|
def __init__(self, ccb: ComfoConnectBridge) -> None:
|
||||||
@ -101,11 +102,6 @@ class ComfoConnectFan(FanEntity):
|
|||||||
"""Return the icon to use in the frontend."""
|
"""Return the icon to use in the frontend."""
|
||||||
return "mdi:air-conditioner"
|
return "mdi:air-conditioner"
|
||||||
|
|
||||||
@property
|
|
||||||
def supported_features(self) -> int:
|
|
||||||
"""Flag supported features."""
|
|
||||||
return SUPPORT_SET_SPEED
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def percentage(self) -> int | None:
|
def percentage(self) -> int | None:
|
||||||
"""Return the current speed percentage."""
|
"""Return the current speed percentage."""
|
||||||
|
@ -11,10 +11,7 @@ import voluptuous as vol
|
|||||||
import homeassistant.components.alarm_control_panel as alarm
|
import homeassistant.components.alarm_control_panel as alarm
|
||||||
from homeassistant.components.alarm_control_panel import (
|
from homeassistant.components.alarm_control_panel import (
|
||||||
PLATFORM_SCHEMA as PARENT_PLATFORM_SCHEMA,
|
PLATFORM_SCHEMA as PARENT_PLATFORM_SCHEMA,
|
||||||
)
|
AlarmControlPanelEntityFeature,
|
||||||
from homeassistant.components.alarm_control_panel.const import (
|
|
||||||
SUPPORT_ALARM_ARM_AWAY,
|
|
||||||
SUPPORT_ALARM_ARM_HOME,
|
|
||||||
)
|
)
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_CODE,
|
CONF_CODE,
|
||||||
@ -75,6 +72,11 @@ def setup_platform(
|
|||||||
class Concord232Alarm(alarm.AlarmControlPanelEntity):
|
class Concord232Alarm(alarm.AlarmControlPanelEntity):
|
||||||
"""Representation of the Concord232-based alarm panel."""
|
"""Representation of the Concord232-based alarm panel."""
|
||||||
|
|
||||||
|
_attr_supported_features = (
|
||||||
|
AlarmControlPanelEntityFeature.ARM_HOME
|
||||||
|
| AlarmControlPanelEntityFeature.ARM_AWAY
|
||||||
|
)
|
||||||
|
|
||||||
def __init__(self, url, name, code, mode):
|
def __init__(self, url, name, code, mode):
|
||||||
"""Initialize the Concord232 alarm panel."""
|
"""Initialize the Concord232 alarm panel."""
|
||||||
|
|
||||||
@ -101,11 +103,6 @@ class Concord232Alarm(alarm.AlarmControlPanelEntity):
|
|||||||
"""Return the state of the device."""
|
"""Return the state of the device."""
|
||||||
return self._state
|
return self._state
|
||||||
|
|
||||||
@property
|
|
||||||
def supported_features(self) -> int:
|
|
||||||
"""Return the list of supported features."""
|
|
||||||
return SUPPORT_ALARM_ARM_HOME | SUPPORT_ALARM_ARM_AWAY
|
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
"""Update values from API."""
|
"""Update values from API."""
|
||||||
try:
|
try:
|
||||||
|
@ -13,8 +13,8 @@ from homeassistant.components.light import (
|
|||||||
ATTR_TRANSITION,
|
ATTR_TRANSITION,
|
||||||
COLOR_MODE_BRIGHTNESS,
|
COLOR_MODE_BRIGHTNESS,
|
||||||
COLOR_MODE_ONOFF,
|
COLOR_MODE_ONOFF,
|
||||||
SUPPORT_TRANSITION,
|
|
||||||
LightEntity,
|
LightEntity,
|
||||||
|
LightEntityFeature,
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import CONF_SCAN_INTERVAL
|
from homeassistant.const import CONF_SCAN_INTERVAL
|
||||||
@ -195,7 +195,7 @@ class Control4Light(Control4Entity, LightEntity):
|
|||||||
def supported_features(self) -> int:
|
def supported_features(self) -> int:
|
||||||
"""Flag supported features."""
|
"""Flag supported features."""
|
||||||
if self._is_dimmer:
|
if self._is_dimmer:
|
||||||
return SUPPORT_TRANSITION
|
return LightEntityFeature.TRANSITION
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
async def async_turn_on(self, **kwargs) -> None:
|
async def async_turn_on(self, **kwargs) -> None:
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
"""CoolMasterNet platform to control of CoolMasterNet Climate Devices."""
|
"""CoolMasterNet platform to control of CoolMasterNet Climate Devices."""
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
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 (
|
||||||
HVAC_MODE_COOL,
|
HVAC_MODE_COOL,
|
||||||
HVAC_MODE_DRY,
|
HVAC_MODE_DRY,
|
||||||
@ -9,8 +9,6 @@ from homeassistant.components.climate.const import (
|
|||||||
HVAC_MODE_HEAT,
|
HVAC_MODE_HEAT,
|
||||||
HVAC_MODE_HEAT_COOL,
|
HVAC_MODE_HEAT_COOL,
|
||||||
HVAC_MODE_OFF,
|
HVAC_MODE_OFF,
|
||||||
SUPPORT_FAN_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
|
||||||
@ -21,8 +19,6 @@ from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
|||||||
|
|
||||||
from .const import CONF_SUPPORTED_MODES, DATA_COORDINATOR, DATA_INFO, DOMAIN
|
from .const import CONF_SUPPORTED_MODES, DATA_COORDINATOR, DATA_INFO, DOMAIN
|
||||||
|
|
||||||
SUPPORT_FLAGS = SUPPORT_TARGET_TEMPERATURE | SUPPORT_FAN_MODE
|
|
||||||
|
|
||||||
CM_TO_HA_STATE = {
|
CM_TO_HA_STATE = {
|
||||||
"heat": HVAC_MODE_HEAT,
|
"heat": HVAC_MODE_HEAT,
|
||||||
"cool": HVAC_MODE_COOL,
|
"cool": HVAC_MODE_COOL,
|
||||||
@ -65,6 +61,10 @@ async def async_setup_entry(
|
|||||||
class CoolmasterClimate(CoordinatorEntity, ClimateEntity):
|
class CoolmasterClimate(CoordinatorEntity, ClimateEntity):
|
||||||
"""Representation of a coolmaster climate device."""
|
"""Representation of a coolmaster climate device."""
|
||||||
|
|
||||||
|
_attr_supported_features = (
|
||||||
|
ClimateEntityFeature.TARGET_TEMPERATURE | ClimateEntityFeature.FAN_MODE
|
||||||
|
)
|
||||||
|
|
||||||
def __init__(self, coordinator, unit_id, unit, supported_modes, info):
|
def __init__(self, coordinator, unit_id, unit, supported_modes, info):
|
||||||
"""Initialize the climate device."""
|
"""Initialize the climate device."""
|
||||||
super().__init__(coordinator)
|
super().__init__(coordinator)
|
||||||
@ -94,11 +94,6 @@ class CoolmasterClimate(CoordinatorEntity, ClimateEntity):
|
|||||||
"""Return unique ID for this device."""
|
"""Return unique ID for this device."""
|
||||||
return self._unit_id
|
return self._unit_id
|
||||||
|
|
||||||
@property
|
|
||||||
def supported_features(self):
|
|
||||||
"""Return the list of supported features."""
|
|
||||||
return SUPPORT_FLAGS
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
"""Return the name of the climate device."""
|
"""Return the name of the climate device."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user