Use EntityFeature enum in components (n**) (#69432)
parent
2cc3bfa056
commit
96819fff74
homeassistant/components
ness_alarm
netatmo
nexia
nuheat
nuki
|
@ -4,14 +4,10 @@ from __future__ import annotations
|
|||
from nad_receiver import NADReceiver, NADReceiverTCP, NADReceiverTelnet
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.media_player import PLATFORM_SCHEMA, 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 (
|
||||
PLATFORM_SCHEMA,
|
||||
MediaPlayerEntity,
|
||||
MediaPlayerEntityFeature,
|
||||
)
|
||||
from homeassistant.const import (
|
||||
CONF_HOST,
|
||||
|
@ -35,12 +31,12 @@ DEFAULT_MAX_VOLUME = -20
|
|||
DEFAULT_VOLUME_STEP = 4
|
||||
|
||||
SUPPORT_NAD = (
|
||||
SUPPORT_VOLUME_SET
|
||||
| SUPPORT_VOLUME_MUTE
|
||||
| SUPPORT_TURN_ON
|
||||
| SUPPORT_TURN_OFF
|
||||
| SUPPORT_VOLUME_STEP
|
||||
| SUPPORT_SELECT_SOURCE
|
||||
MediaPlayerEntityFeature.VOLUME_SET
|
||||
| MediaPlayerEntityFeature.VOLUME_MUTE
|
||||
| MediaPlayerEntityFeature.TURN_ON
|
||||
| MediaPlayerEntityFeature.TURN_OFF
|
||||
| MediaPlayerEntityFeature.VOLUME_STEP
|
||||
| MediaPlayerEntityFeature.SELECT_SOURCE
|
||||
)
|
||||
|
||||
CONF_SERIAL_PORT = "serial_port" # for NADReceiver
|
||||
|
@ -90,6 +86,8 @@ def setup_platform(
|
|||
class NAD(MediaPlayerEntity):
|
||||
"""Representation of a NAD Receiver."""
|
||||
|
||||
_attr_supported_features = SUPPORT_NAD
|
||||
|
||||
def __init__(self, config):
|
||||
"""Initialize the NAD Receiver device."""
|
||||
self.config = config
|
||||
|
@ -134,11 +132,6 @@ class NAD(MediaPlayerEntity):
|
|||
"""Boolean if volume is currently muted."""
|
||||
return self._mute
|
||||
|
||||
@property
|
||||
def supported_features(self):
|
||||
"""Flag media player features that are supported."""
|
||||
return SUPPORT_NAD
|
||||
|
||||
def turn_off(self):
|
||||
"""Turn the media player off."""
|
||||
self._nad_receiver.main_power("=", "Off")
|
||||
|
@ -227,6 +220,8 @@ class NAD(MediaPlayerEntity):
|
|||
class NADtcp(MediaPlayerEntity):
|
||||
"""Representation of a NAD Digital amplifier."""
|
||||
|
||||
_attr_supported_features = SUPPORT_NAD
|
||||
|
||||
def __init__(self, config):
|
||||
"""Initialize the amplifier."""
|
||||
self._name = config[CONF_NAME]
|
||||
|
@ -261,11 +256,6 @@ class NADtcp(MediaPlayerEntity):
|
|||
"""Boolean if volume is currently muted."""
|
||||
return self._mute
|
||||
|
||||
@property
|
||||
def supported_features(self):
|
||||
"""Flag media player features that are supported."""
|
||||
return SUPPORT_NAD
|
||||
|
||||
def turn_off(self):
|
||||
"""Turn the media player off."""
|
||||
self._nad_receiver.power_off()
|
||||
|
|
|
@ -6,11 +6,7 @@ import logging
|
|||
from nessclient import ArmingState
|
||||
|
||||
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_TRIGGER,
|
||||
)
|
||||
from homeassistant.components.alarm_control_panel import AlarmControlPanelEntityFeature
|
||||
from homeassistant.const import (
|
||||
STATE_ALARM_ARMED_AWAY,
|
||||
STATE_ALARM_ARMING,
|
||||
|
@ -45,6 +41,12 @@ async def async_setup_platform(
|
|||
class NessAlarmPanel(alarm.AlarmControlPanelEntity):
|
||||
"""Representation of a Ness alarm panel."""
|
||||
|
||||
_attr_supported_features = (
|
||||
AlarmControlPanelEntityFeature.ARM_HOME
|
||||
| AlarmControlPanelEntityFeature.ARM_AWAY
|
||||
| AlarmControlPanelEntityFeature.TRIGGER
|
||||
)
|
||||
|
||||
def __init__(self, client, name):
|
||||
"""Initialize the alarm panel."""
|
||||
self._client = client
|
||||
|
@ -79,11 +81,6 @@ class NessAlarmPanel(alarm.AlarmControlPanelEntity):
|
|||
"""Return the state of the device."""
|
||||
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_TRIGGER
|
||||
|
||||
async def async_alarm_disarm(self, code=None):
|
||||
"""Send disarm command."""
|
||||
await self._client.disarm(code)
|
||||
|
|
|
@ -8,7 +8,7 @@ import aiohttp
|
|||
import pyatmo
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.camera import SUPPORT_STREAM, Camera
|
||||
from homeassistant.components.camera import Camera, CameraEntityFeature
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.exceptions import HomeAssistantError, PlatformNotReady
|
||||
|
@ -112,6 +112,8 @@ async def async_setup_entry(
|
|||
class NetatmoCamera(NetatmoBase, Camera):
|
||||
"""Representation of a Netatmo camera."""
|
||||
|
||||
_attr_supported_features = CameraEntityFeature.STREAM
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
data_handler: NetatmoDataHandler,
|
||||
|
@ -217,11 +219,6 @@ class NetatmoCamera(NetatmoBase, Camera):
|
|||
"""Return True if entity is available."""
|
||||
return bool(self._alim_status == "on" or self._status == "disconnected")
|
||||
|
||||
@property
|
||||
def supported_features(self) -> int:
|
||||
"""Return supported features."""
|
||||
return SUPPORT_STREAM
|
||||
|
||||
@property
|
||||
def brand(self) -> str:
|
||||
"""Return the camera brand."""
|
||||
|
|
|
@ -7,7 +7,7 @@ from typing import Any
|
|||
import pyatmo
|
||||
import voluptuous as vol
|
||||
|
||||
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,
|
||||
|
@ -17,8 +17,6 @@ from homeassistant.components.climate.const import (
|
|||
HVAC_MODE_OFF,
|
||||
PRESET_AWAY,
|
||||
PRESET_BOOST,
|
||||
SUPPORT_PRESET_MODE,
|
||||
SUPPORT_TARGET_TEMPERATURE,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import (
|
||||
|
@ -69,8 +67,6 @@ PRESET_FROST_GUARD = "Frost Guard"
|
|||
PRESET_SCHEDULE = "Schedule"
|
||||
PRESET_MANUAL = "Manual"
|
||||
|
||||
SUPPORT_FLAGS = SUPPORT_TARGET_TEMPERATURE | SUPPORT_PRESET_MODE
|
||||
SUPPORT_HVAC = [HVAC_MODE_HEAT, HVAC_MODE_AUTO, HVAC_MODE_OFF]
|
||||
SUPPORT_PRESET = [PRESET_AWAY, PRESET_BOOST, PRESET_FROST_GUARD, PRESET_SCHEDULE]
|
||||
|
||||
STATE_NETATMO_SCHEDULE = "schedule"
|
||||
|
@ -175,7 +171,9 @@ class NetatmoThermostat(NetatmoBase, ClimateEntity):
|
|||
_attr_hvac_mode = HVAC_MODE_AUTO
|
||||
_attr_max_temp = DEFAULT_MAX_TEMP
|
||||
_attr_preset_modes = SUPPORT_PRESET
|
||||
_attr_supported_features = SUPPORT_FLAGS
|
||||
_attr_supported_features = (
|
||||
ClimateEntityFeature.TARGET_TEMPERATURE | ClimateEntityFeature.PRESET_MODE
|
||||
)
|
||||
_attr_target_temperature_step = PRECISION_HALVES
|
||||
_attr_temperature_unit = TEMP_CELSIUS
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ from nexia.util import find_humidity_setpoint
|
|||
from nexia.zone import NexiaThermostatZone
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.climate import ClimateEntity
|
||||
from homeassistant.components.climate import ClimateEntity, ClimateEntityFeature
|
||||
from homeassistant.components.climate.const import (
|
||||
ATTR_HUMIDITY,
|
||||
ATTR_HVAC_MODE,
|
||||
|
@ -33,12 +33,6 @@ from homeassistant.components.climate.const import (
|
|||
HVAC_MODE_HEAT,
|
||||
HVAC_MODE_HEAT_COOL,
|
||||
HVAC_MODE_OFF,
|
||||
SUPPORT_AUX_HEAT,
|
||||
SUPPORT_FAN_MODE,
|
||||
SUPPORT_PRESET_MODE,
|
||||
SUPPORT_TARGET_HUMIDITY,
|
||||
SUPPORT_TARGET_TEMPERATURE,
|
||||
SUPPORT_TARGET_TEMPERATURE_RANGE,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS, TEMP_FAHRENHEIT
|
||||
|
@ -116,10 +110,10 @@ HVAC_MODES = [
|
|||
]
|
||||
|
||||
NEXIA_SUPPORTED = (
|
||||
SUPPORT_TARGET_TEMPERATURE_RANGE
|
||||
| SUPPORT_TARGET_TEMPERATURE
|
||||
| SUPPORT_FAN_MODE
|
||||
| SUPPORT_PRESET_MODE
|
||||
ClimateEntityFeature.TARGET_TEMPERATURE_RANGE
|
||||
| ClimateEntityFeature.TARGET_TEMPERATURE
|
||||
| ClimateEntityFeature.FAN_MODE
|
||||
| ClimateEntityFeature.PRESET_MODE
|
||||
)
|
||||
|
||||
|
||||
|
@ -177,9 +171,9 @@ class NexiaZone(NexiaThermostatZoneEntity, ClimateEntity):
|
|||
self._has_dehumidify_support = self._thermostat.has_dehumidify_support()
|
||||
supported = NEXIA_SUPPORTED
|
||||
if self._has_humidify_support or self._has_dehumidify_support:
|
||||
supported |= SUPPORT_TARGET_HUMIDITY
|
||||
supported |= ClimateEntityFeature.TARGET_HUMIDITY
|
||||
if self._has_emergency_heat:
|
||||
supported |= SUPPORT_AUX_HEAT
|
||||
supported |= ClimateEntityFeature.AUX_HEAT
|
||||
self._attr_supported_features = supported
|
||||
self._attr_preset_modes = self._zone.get_presets()
|
||||
self._attr_fan_modes = self._thermostat.get_fan_modes()
|
||||
|
|
|
@ -11,15 +11,13 @@ from nuheat.util import (
|
|||
nuheat_to_fahrenheit,
|
||||
)
|
||||
|
||||
from homeassistant.components.climate import ClimateEntity
|
||||
from homeassistant.components.climate import ClimateEntity, ClimateEntityFeature
|
||||
from homeassistant.components.climate.const import (
|
||||
ATTR_HVAC_MODE,
|
||||
CURRENT_HVAC_HEAT,
|
||||
CURRENT_HVAC_IDLE,
|
||||
HVAC_MODE_AUTO,
|
||||
HVAC_MODE_HEAT,
|
||||
SUPPORT_PRESET_MODE,
|
||||
SUPPORT_TARGET_TEMPERATURE,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS, TEMP_FAHRENHEIT
|
||||
|
@ -63,8 +61,6 @@ SCHEDULE_MODE_TO_PRESET_MODE_MAP = {
|
|||
value: key for key, value in PRESET_MODE_TO_SCHEDULE_MODE_MAP.items()
|
||||
}
|
||||
|
||||
SUPPORT_FLAGS = SUPPORT_TARGET_TEMPERATURE | SUPPORT_PRESET_MODE
|
||||
|
||||
|
||||
async def async_setup_entry(
|
||||
hass: HomeAssistant,
|
||||
|
@ -86,6 +82,10 @@ async def async_setup_entry(
|
|||
class NuHeatThermostat(CoordinatorEntity, ClimateEntity):
|
||||
"""Representation of a NuHeat Thermostat."""
|
||||
|
||||
_attr_supported_features = (
|
||||
ClimateEntityFeature.TARGET_TEMPERATURE | ClimateEntityFeature.PRESET_MODE
|
||||
)
|
||||
|
||||
def __init__(self, coordinator, thermostat, temperature_unit):
|
||||
"""Initialize the thermostat."""
|
||||
super().__init__(coordinator)
|
||||
|
@ -99,11 +99,6 @@ class NuHeatThermostat(CoordinatorEntity, ClimateEntity):
|
|||
"""Return the name of the thermostat."""
|
||||
return self._thermostat.room
|
||||
|
||||
@property
|
||||
def supported_features(self):
|
||||
"""Return the list of supported features."""
|
||||
return SUPPORT_FLAGS
|
||||
|
||||
@property
|
||||
def temperature_unit(self):
|
||||
"""Return the unit of measurement."""
|
||||
|
|
|
@ -4,7 +4,7 @@ from abc import ABC, abstractmethod
|
|||
from pynuki.constants import MODE_OPENER_CONTINUOUS
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.lock import SUPPORT_OPEN, LockEntity
|
||||
from homeassistant.components.lock import LockEntity, LockEntityFeature
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import config_validation as cv, entity_platform
|
||||
|
@ -60,6 +60,8 @@ async def async_setup_entry(
|
|||
class NukiDeviceEntity(NukiEntity, LockEntity, ABC):
|
||||
"""Representation of a Nuki device."""
|
||||
|
||||
_attr_supported_features = LockEntityFeature.OPEN
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
"""Return the name of the lock."""
|
||||
|
@ -84,11 +86,6 @@ class NukiDeviceEntity(NukiEntity, LockEntity, ABC):
|
|||
}
|
||||
return data
|
||||
|
||||
@property
|
||||
def supported_features(self):
|
||||
"""Flag supported features."""
|
||||
return SUPPORT_OPEN
|
||||
|
||||
@property
|
||||
def available(self) -> bool:
|
||||
"""Return True if entity is available."""
|
||||
|
|
|
@ -11,10 +11,7 @@ import voluptuous as vol
|
|||
import homeassistant.components.alarm_control_panel as alarm
|
||||
from homeassistant.components.alarm_control_panel import (
|
||||
PLATFORM_SCHEMA as PARENT_PLATFORM_SCHEMA,
|
||||
)
|
||||
from homeassistant.components.alarm_control_panel.const import (
|
||||
SUPPORT_ALARM_ARM_AWAY,
|
||||
SUPPORT_ALARM_ARM_HOME,
|
||||
AlarmControlPanelEntityFeature,
|
||||
)
|
||||
from homeassistant.const import (
|
||||
CONF_HOST,
|
||||
|
@ -95,6 +92,11 @@ async def async_setup_platform(
|
|||
class NX584Alarm(alarm.AlarmControlPanelEntity):
|
||||
"""Representation of a NX584-based alarm panel."""
|
||||
|
||||
_attr_supported_features = (
|
||||
AlarmControlPanelEntityFeature.ARM_HOME
|
||||
| AlarmControlPanelEntityFeature.ARM_AWAY
|
||||
)
|
||||
|
||||
def __init__(self, name, alarm_client, url):
|
||||
"""Init the nx584 alarm panel."""
|
||||
self._name = name
|
||||
|
@ -117,11 +119,6 @@ class NX584Alarm(alarm.AlarmControlPanelEntity):
|
|||
"""Return the state of the device."""
|
||||
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):
|
||||
"""Process new events from panel."""
|
||||
try:
|
||||
|
|
Loading…
Reference in New Issue