mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 19:27:45 +00:00
Use EntityFeature enum in components (v**) (#69465)
* Use EntityFeature enum in vallox * Use EntityFeature enum in velbus * Use EntityFeature enum in velux * Use EntityFeature enum in venstar * Use EntityFeature enum in vera * Use EntityFeature enum in verisure * Use EntityFeature enum in vesync * Use EntityFeature enum in vicare * Use EntityFeature enum in vivotek * Use EntityFeature enum in vizio * Use EntityFeature enum in vlc * Use EntityFeature enum in vlc_telnet * Use EntityFeature enum in volumio
This commit is contained in:
parent
10a1b1f734
commit
f194f7809b
@ -9,8 +9,8 @@ from vallox_websocket_api import Vallox
|
|||||||
from vallox_websocket_api.exceptions import ValloxApiException
|
from vallox_websocket_api.exceptions import ValloxApiException
|
||||||
|
|
||||||
from homeassistant.components.fan import (
|
from homeassistant.components.fan import (
|
||||||
SUPPORT_PRESET_MODE,
|
|
||||||
FanEntity,
|
FanEntity,
|
||||||
|
FanEntityFeature,
|
||||||
NotValidPresetModeError,
|
NotValidPresetModeError,
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
@ -83,6 +83,8 @@ async def async_setup_entry(
|
|||||||
class ValloxFan(CoordinatorEntity[ValloxDataUpdateCoordinator], FanEntity):
|
class ValloxFan(CoordinatorEntity[ValloxDataUpdateCoordinator], FanEntity):
|
||||||
"""Representation of the fan."""
|
"""Representation of the fan."""
|
||||||
|
|
||||||
|
_attr_supported_features = FanEntityFeature.PRESET_MODE
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
name: str,
|
name: str,
|
||||||
@ -98,11 +100,6 @@ class ValloxFan(CoordinatorEntity[ValloxDataUpdateCoordinator], FanEntity):
|
|||||||
|
|
||||||
self._attr_unique_id = str(self.coordinator.data.get_uuid())
|
self._attr_unique_id = str(self.coordinator.data.get_uuid())
|
||||||
|
|
||||||
@property
|
|
||||||
def supported_features(self) -> int:
|
|
||||||
"""Flag supported features."""
|
|
||||||
return SUPPORT_PRESET_MODE
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def preset_modes(self) -> list[str]:
|
def preset_modes(self) -> list[str]:
|
||||||
"""Return a list of available preset modes."""
|
"""Return a list of available preset modes."""
|
||||||
|
@ -5,12 +5,8 @@ from typing import Any
|
|||||||
|
|
||||||
from velbusaio.channels import Temperature as VelbusTemp
|
from velbusaio.channels import Temperature as VelbusTemp
|
||||||
|
|
||||||
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_HEAT
|
||||||
HVAC_MODE_HEAT,
|
|
||||||
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
|
from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
@ -38,7 +34,9 @@ class VelbusClimate(VelbusEntity, ClimateEntity):
|
|||||||
"""Representation of a Velbus thermostat."""
|
"""Representation of a Velbus thermostat."""
|
||||||
|
|
||||||
_channel: VelbusTemp
|
_channel: VelbusTemp
|
||||||
_attr_supported_features = SUPPORT_TARGET_TEMPERATURE | SUPPORT_PRESET_MODE
|
_attr_supported_features = (
|
||||||
|
ClimateEntityFeature.TARGET_TEMPERATURE | ClimateEntityFeature.PRESET_MODE
|
||||||
|
)
|
||||||
_attr_temperature_unit = TEMP_CELSIUS
|
_attr_temperature_unit = TEMP_CELSIUS
|
||||||
_attr_hvac_mode = HVAC_MODE_HEAT
|
_attr_hvac_mode = HVAC_MODE_HEAT
|
||||||
_attr_hvac_modes = [HVAC_MODE_HEAT]
|
_attr_hvac_modes = [HVAC_MODE_HEAT]
|
||||||
|
@ -7,11 +7,8 @@ from velbusaio.channels import Blind as VelbusBlind
|
|||||||
|
|
||||||
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.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
@ -45,10 +42,17 @@ class VelbusCover(VelbusEntity, CoverEntity):
|
|||||||
super().__init__(channel)
|
super().__init__(channel)
|
||||||
if self._channel.support_position():
|
if self._channel.support_position():
|
||||||
self._attr_supported_features = (
|
self._attr_supported_features = (
|
||||||
SUPPORT_OPEN | SUPPORT_CLOSE | SUPPORT_STOP | SUPPORT_SET_POSITION
|
CoverEntityFeature.OPEN
|
||||||
|
| CoverEntityFeature.CLOSE
|
||||||
|
| CoverEntityFeature.STOP
|
||||||
|
| CoverEntityFeature.SET_POSITION
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
self._attr_supported_features = SUPPORT_OPEN | SUPPORT_CLOSE | SUPPORT_STOP
|
self._attr_supported_features = (
|
||||||
|
CoverEntityFeature.OPEN
|
||||||
|
| CoverEntityFeature.CLOSE
|
||||||
|
| CoverEntityFeature.STOP
|
||||||
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_closed(self) -> bool | None:
|
def is_closed(self) -> bool | None:
|
||||||
|
@ -7,16 +7,9 @@ from pyvlx.opening_device import Awning, Blind, GarageDoor, Gate, RollerShutter,
|
|||||||
from homeassistant.components.cover import (
|
from homeassistant.components.cover import (
|
||||||
ATTR_POSITION,
|
ATTR_POSITION,
|
||||||
ATTR_TILT_POSITION,
|
ATTR_TILT_POSITION,
|
||||||
SUPPORT_CLOSE,
|
|
||||||
SUPPORT_CLOSE_TILT,
|
|
||||||
SUPPORT_OPEN,
|
|
||||||
SUPPORT_OPEN_TILT,
|
|
||||||
SUPPORT_SET_POSITION,
|
|
||||||
SUPPORT_SET_TILT_POSITION,
|
|
||||||
SUPPORT_STOP,
|
|
||||||
SUPPORT_STOP_TILT,
|
|
||||||
CoverDeviceClass,
|
CoverDeviceClass,
|
||||||
CoverEntity,
|
CoverEntity,
|
||||||
|
CoverEntityFeature,
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
@ -46,14 +39,17 @@ class VeluxCover(VeluxEntity, CoverEntity):
|
|||||||
def supported_features(self):
|
def supported_features(self):
|
||||||
"""Flag supported features."""
|
"""Flag supported features."""
|
||||||
supported_features = (
|
supported_features = (
|
||||||
SUPPORT_OPEN | SUPPORT_CLOSE | SUPPORT_SET_POSITION | SUPPORT_STOP
|
CoverEntityFeature.OPEN
|
||||||
|
| CoverEntityFeature.CLOSE
|
||||||
|
| CoverEntityFeature.SET_POSITION
|
||||||
|
| CoverEntityFeature.STOP
|
||||||
)
|
)
|
||||||
if self.current_cover_tilt_position is not None:
|
if self.current_cover_tilt_position is not None:
|
||||||
supported_features |= (
|
supported_features |= (
|
||||||
SUPPORT_OPEN_TILT
|
CoverEntityFeature.OPEN_TILT
|
||||||
| SUPPORT_CLOSE_TILT
|
| CoverEntityFeature.CLOSE_TILT
|
||||||
| SUPPORT_SET_TILT_POSITION
|
| CoverEntityFeature.SET_TILT_POSITION
|
||||||
| SUPPORT_STOP_TILT
|
| CoverEntityFeature.STOP_TILT
|
||||||
)
|
)
|
||||||
return supported_features
|
return supported_features
|
||||||
|
|
||||||
|
@ -3,7 +3,11 @@ from __future__ import annotations
|
|||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.climate import PLATFORM_SCHEMA, ClimateEntity
|
from homeassistant.components.climate import (
|
||||||
|
PLATFORM_SCHEMA,
|
||||||
|
ClimateEntity,
|
||||||
|
ClimateEntityFeature,
|
||||||
|
)
|
||||||
from homeassistant.components.climate.const import (
|
from homeassistant.components.climate.const import (
|
||||||
ATTR_HVAC_MODE,
|
ATTR_HVAC_MODE,
|
||||||
ATTR_TARGET_TEMP_HIGH,
|
ATTR_TARGET_TEMP_HIGH,
|
||||||
@ -20,11 +24,6 @@ from homeassistant.components.climate.const import (
|
|||||||
HVAC_MODE_OFF,
|
HVAC_MODE_OFF,
|
||||||
PRESET_AWAY,
|
PRESET_AWAY,
|
||||||
PRESET_NONE,
|
PRESET_NONE,
|
||||||
SUPPORT_FAN_MODE,
|
|
||||||
SUPPORT_PRESET_MODE,
|
|
||||||
SUPPORT_TARGET_HUMIDITY,
|
|
||||||
SUPPORT_TARGET_TEMPERATURE,
|
|
||||||
SUPPORT_TARGET_TEMPERATURE_RANGE,
|
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry
|
from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
@ -134,13 +133,17 @@ class VenstarThermostat(VenstarEntity, ClimateEntity):
|
|||||||
@property
|
@property
|
||||||
def supported_features(self):
|
def supported_features(self):
|
||||||
"""Return the list of supported features."""
|
"""Return the list of supported features."""
|
||||||
features = SUPPORT_TARGET_TEMPERATURE | SUPPORT_FAN_MODE | SUPPORT_PRESET_MODE
|
features = (
|
||||||
|
ClimateEntityFeature.TARGET_TEMPERATURE
|
||||||
|
| ClimateEntityFeature.FAN_MODE
|
||||||
|
| ClimateEntityFeature.PRESET_MODE
|
||||||
|
)
|
||||||
|
|
||||||
if self._client.mode == self._client.MODE_AUTO:
|
if self._client.mode == self._client.MODE_AUTO:
|
||||||
features |= SUPPORT_TARGET_TEMPERATURE_RANGE
|
features |= ClimateEntityFeature.TARGET_TEMPERATURE_RANGE
|
||||||
|
|
||||||
if self._client.hum_setpoint is not None:
|
if self._client.hum_setpoint is not None:
|
||||||
features |= SUPPORT_TARGET_HUMIDITY
|
features |= ClimateEntityFeature.TARGET_HUMIDITY
|
||||||
|
|
||||||
return features
|
return features
|
||||||
|
|
||||||
|
@ -5,7 +5,11 @@ from typing import Any
|
|||||||
|
|
||||||
import pyvera as veraApi
|
import pyvera as veraApi
|
||||||
|
|
||||||
from homeassistant.components.climate import ENTITY_ID_FORMAT, ClimateEntity
|
from homeassistant.components.climate import (
|
||||||
|
ENTITY_ID_FORMAT,
|
||||||
|
ClimateEntity,
|
||||||
|
ClimateEntityFeature,
|
||||||
|
)
|
||||||
from homeassistant.components.climate.const import (
|
from homeassistant.components.climate.const import (
|
||||||
FAN_AUTO,
|
FAN_AUTO,
|
||||||
FAN_ON,
|
FAN_ON,
|
||||||
@ -13,8 +17,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 (
|
from homeassistant.const import (
|
||||||
@ -31,7 +33,6 @@ from .common import ControllerData, get_controller_data
|
|||||||
|
|
||||||
FAN_OPERATION_LIST = [FAN_ON, FAN_AUTO]
|
FAN_OPERATION_LIST = [FAN_ON, FAN_AUTO]
|
||||||
|
|
||||||
SUPPORT_FLAGS = SUPPORT_TARGET_TEMPERATURE | SUPPORT_FAN_MODE
|
|
||||||
SUPPORT_HVAC = [HVAC_MODE_COOL, HVAC_MODE_HEAT, HVAC_MODE_HEAT_COOL, HVAC_MODE_OFF]
|
SUPPORT_HVAC = [HVAC_MODE_COOL, HVAC_MODE_HEAT, HVAC_MODE_HEAT_COOL, HVAC_MODE_OFF]
|
||||||
|
|
||||||
|
|
||||||
@ -54,6 +55,10 @@ async def async_setup_entry(
|
|||||||
class VeraThermostat(VeraDevice[veraApi.VeraThermostat], ClimateEntity):
|
class VeraThermostat(VeraDevice[veraApi.VeraThermostat], ClimateEntity):
|
||||||
"""Representation of a Vera Thermostat."""
|
"""Representation of a Vera Thermostat."""
|
||||||
|
|
||||||
|
_attr_supported_features = (
|
||||||
|
ClimateEntityFeature.TARGET_TEMPERATURE | ClimateEntityFeature.FAN_MODE
|
||||||
|
)
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, vera_device: veraApi.VeraThermostat, controller_data: ControllerData
|
self, vera_device: veraApi.VeraThermostat, controller_data: ControllerData
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -61,11 +66,6 @@ class VeraThermostat(VeraDevice[veraApi.VeraThermostat], ClimateEntity):
|
|||||||
VeraDevice.__init__(self, vera_device, controller_data)
|
VeraDevice.__init__(self, vera_device, controller_data)
|
||||||
self.entity_id = ENTITY_ID_FORMAT.format(self.vera_id)
|
self.entity_id = ENTITY_ID_FORMAT.format(self.vera_id)
|
||||||
|
|
||||||
@property
|
|
||||||
def supported_features(self) -> int:
|
|
||||||
"""Return the list of supported features."""
|
|
||||||
return SUPPORT_FLAGS
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def hvac_mode(self) -> str:
|
def hvac_mode(self) -> str:
|
||||||
"""Return hvac operation ie. heat, cool mode.
|
"""Return hvac operation ie. heat, cool mode.
|
||||||
|
@ -6,10 +6,7 @@ import asyncio
|
|||||||
from homeassistant.components.alarm_control_panel import (
|
from homeassistant.components.alarm_control_panel import (
|
||||||
FORMAT_NUMBER,
|
FORMAT_NUMBER,
|
||||||
AlarmControlPanelEntity,
|
AlarmControlPanelEntity,
|
||||||
)
|
AlarmControlPanelEntityFeature,
|
||||||
from homeassistant.components.alarm_control_panel.const import (
|
|
||||||
SUPPORT_ALARM_ARM_AWAY,
|
|
||||||
SUPPORT_ALARM_ARM_HOME,
|
|
||||||
)
|
)
|
||||||
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,7 +34,10 @@ class VerisureAlarm(
|
|||||||
|
|
||||||
_attr_code_format = FORMAT_NUMBER
|
_attr_code_format = FORMAT_NUMBER
|
||||||
_attr_name = "Verisure Alarm"
|
_attr_name = "Verisure Alarm"
|
||||||
_attr_supported_features = SUPPORT_ALARM_ARM_HOME | SUPPORT_ALARM_ARM_AWAY
|
_attr_supported_features = (
|
||||||
|
AlarmControlPanelEntityFeature.ARM_HOME
|
||||||
|
| AlarmControlPanelEntityFeature.ARM_AWAY
|
||||||
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_info(self) -> DeviceInfo:
|
def device_info(self) -> DeviceInfo:
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
import logging
|
import logging
|
||||||
import math
|
import math
|
||||||
|
|
||||||
from homeassistant.components.fan import SUPPORT_SET_SPEED, FanEntity
|
from homeassistant.components.fan import FanEntity, FanEntityFeature
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||||
@ -83,16 +83,13 @@ def _setup_entities(devices, async_add_entities):
|
|||||||
class VeSyncFanHA(VeSyncDevice, FanEntity):
|
class VeSyncFanHA(VeSyncDevice, FanEntity):
|
||||||
"""Representation of a VeSync fan."""
|
"""Representation of a VeSync fan."""
|
||||||
|
|
||||||
|
_attr_supported_features = FanEntityFeature.SET_SPEED
|
||||||
|
|
||||||
def __init__(self, fan):
|
def __init__(self, fan):
|
||||||
"""Initialize the VeSync fan device."""
|
"""Initialize the VeSync fan device."""
|
||||||
super().__init__(fan)
|
super().__init__(fan)
|
||||||
self.smartfan = fan
|
self.smartfan = fan
|
||||||
|
|
||||||
@property
|
|
||||||
def supported_features(self):
|
|
||||||
"""Flag supported features."""
|
|
||||||
return SUPPORT_SET_SPEED
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def percentage(self):
|
def percentage(self):
|
||||||
"""Return the current speed."""
|
"""Return the current speed."""
|
||||||
|
@ -10,7 +10,7 @@ from PyViCare.PyViCareUtils import (
|
|||||||
import requests
|
import requests
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
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,
|
||||||
@ -20,8 +20,6 @@ from homeassistant.components.climate.const import (
|
|||||||
PRESET_COMFORT,
|
PRESET_COMFORT,
|
||||||
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 (
|
from homeassistant.const import (
|
||||||
@ -72,8 +70,6 @@ VICARE_HOLD_MODE_OFF = "off"
|
|||||||
VICARE_TEMP_HEATING_MIN = 3
|
VICARE_TEMP_HEATING_MIN = 3
|
||||||
VICARE_TEMP_HEATING_MAX = 37
|
VICARE_TEMP_HEATING_MAX = 37
|
||||||
|
|
||||||
SUPPORT_FLAGS_HEATING = SUPPORT_TARGET_TEMPERATURE | SUPPORT_PRESET_MODE
|
|
||||||
|
|
||||||
VICARE_TO_HA_HVAC_HEATING = {
|
VICARE_TO_HA_HVAC_HEATING = {
|
||||||
VICARE_MODE_DHW: HVAC_MODE_OFF,
|
VICARE_MODE_DHW: HVAC_MODE_OFF,
|
||||||
VICARE_MODE_HEATING: HVAC_MODE_HEAT,
|
VICARE_MODE_HEATING: HVAC_MODE_HEAT,
|
||||||
@ -151,6 +147,10 @@ async def async_setup_entry(
|
|||||||
class ViCareClimate(ClimateEntity):
|
class ViCareClimate(ClimateEntity):
|
||||||
"""Representation of the ViCare heating climate device."""
|
"""Representation of the ViCare heating climate device."""
|
||||||
|
|
||||||
|
_attr_supported_features = (
|
||||||
|
ClimateEntityFeature.TARGET_TEMPERATURE | ClimateEntityFeature.PRESET_MODE
|
||||||
|
)
|
||||||
|
|
||||||
def __init__(self, name, api, circuit, device_config, heating_type):
|
def __init__(self, name, api, circuit, device_config, heating_type):
|
||||||
"""Initialize the climate device."""
|
"""Initialize the climate device."""
|
||||||
self._name = name
|
self._name = name
|
||||||
@ -249,11 +249,6 @@ class ViCareClimate(ClimateEntity):
|
|||||||
except PyViCareInvalidDataError as invalid_data_exception:
|
except PyViCareInvalidDataError as invalid_data_exception:
|
||||||
_LOGGER.error("Invalid data from Vicare server: %s", invalid_data_exception)
|
_LOGGER.error("Invalid data from Vicare server: %s", invalid_data_exception)
|
||||||
|
|
||||||
@property
|
|
||||||
def supported_features(self):
|
|
||||||
"""Return the list of supported features."""
|
|
||||||
return SUPPORT_FLAGS_HEATING
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
"""Return the name of the climate device."""
|
"""Return the name of the climate device."""
|
||||||
|
@ -10,8 +10,8 @@ from PyViCare.PyViCareUtils import (
|
|||||||
import requests
|
import requests
|
||||||
|
|
||||||
from homeassistant.components.water_heater import (
|
from homeassistant.components.water_heater import (
|
||||||
SUPPORT_TARGET_TEMPERATURE,
|
|
||||||
WaterHeaterEntity,
|
WaterHeaterEntity,
|
||||||
|
WaterHeaterEntityFeature,
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
@ -45,8 +45,6 @@ VICARE_TEMP_WATER_MAX = 60
|
|||||||
OPERATION_MODE_ON = "on"
|
OPERATION_MODE_ON = "on"
|
||||||
OPERATION_MODE_OFF = "off"
|
OPERATION_MODE_OFF = "off"
|
||||||
|
|
||||||
SUPPORT_FLAGS_HEATER = SUPPORT_TARGET_TEMPERATURE
|
|
||||||
|
|
||||||
VICARE_TO_HA_HVAC_DHW = {
|
VICARE_TO_HA_HVAC_DHW = {
|
||||||
VICARE_MODE_DHW: OPERATION_MODE_ON,
|
VICARE_MODE_DHW: OPERATION_MODE_ON,
|
||||||
VICARE_MODE_DHWANDHEATING: OPERATION_MODE_ON,
|
VICARE_MODE_DHWANDHEATING: OPERATION_MODE_ON,
|
||||||
@ -101,6 +99,8 @@ async def async_setup_entry(
|
|||||||
class ViCareWater(WaterHeaterEntity):
|
class ViCareWater(WaterHeaterEntity):
|
||||||
"""Representation of the ViCare domestic hot water device."""
|
"""Representation of the ViCare domestic hot water device."""
|
||||||
|
|
||||||
|
_attr_supported_features = WaterHeaterEntityFeature.TARGET_TEMPERATURE
|
||||||
|
|
||||||
def __init__(self, name, api, circuit, device_config, heating_type):
|
def __init__(self, name, api, circuit, device_config, heating_type):
|
||||||
"""Initialize the DHW water_heater device."""
|
"""Initialize the DHW water_heater device."""
|
||||||
self._name = name
|
self._name = name
|
||||||
@ -155,11 +155,6 @@ class ViCareWater(WaterHeaterEntity):
|
|||||||
"configuration_url": "https://developer.viessmann.com/",
|
"configuration_url": "https://developer.viessmann.com/",
|
||||||
}
|
}
|
||||||
|
|
||||||
@property
|
|
||||||
def supported_features(self):
|
|
||||||
"""Return the list of supported features."""
|
|
||||||
return SUPPORT_FLAGS_HEATER
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
"""Return the name of the water_heater device."""
|
"""Return the name of the water_heater device."""
|
||||||
|
@ -4,7 +4,7 @@ from __future__ import annotations
|
|||||||
from libpyvivotek import VivotekCamera
|
from libpyvivotek import VivotekCamera
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.camera import PLATFORM_SCHEMA, SUPPORT_STREAM, Camera
|
from homeassistant.components.camera import PLATFORM_SCHEMA, Camera, CameraEntityFeature
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_AUTHENTICATION,
|
CONF_AUTHENTICATION,
|
||||||
CONF_IP_ADDRESS,
|
CONF_IP_ADDRESS,
|
||||||
@ -76,6 +76,8 @@ def setup_platform(
|
|||||||
class VivotekCam(Camera):
|
class VivotekCam(Camera):
|
||||||
"""A Vivotek IP camera."""
|
"""A Vivotek IP camera."""
|
||||||
|
|
||||||
|
_attr_supported_features = CameraEntityFeature.STREAM
|
||||||
|
|
||||||
def __init__(self, config, cam, stream_source):
|
def __init__(self, config, cam, stream_source):
|
||||||
"""Initialize a Vivotek camera."""
|
"""Initialize a Vivotek camera."""
|
||||||
super().__init__()
|
super().__init__()
|
||||||
@ -87,11 +89,6 @@ class VivotekCam(Camera):
|
|||||||
self._name = config[CONF_NAME]
|
self._name = config[CONF_NAME]
|
||||||
self._stream_source = stream_source
|
self._stream_source = stream_source
|
||||||
|
|
||||||
@property
|
|
||||||
def supported_features(self):
|
|
||||||
"""Return supported features for this camera."""
|
|
||||||
return SUPPORT_STREAM
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def frame_interval(self):
|
def frame_interval(self):
|
||||||
"""Return the interval between frames of the mjpeg stream."""
|
"""Return the interval between frames of the mjpeg stream."""
|
||||||
|
@ -10,9 +10,9 @@ from pyvizio.api.apps import find_app_name
|
|||||||
from pyvizio.const import APP_HOME, INPUT_APPS, NO_APP_RUNNING, UNKNOWN_APP
|
from pyvizio.const import APP_HOME, INPUT_APPS, NO_APP_RUNNING, UNKNOWN_APP
|
||||||
|
|
||||||
from homeassistant.components.media_player import (
|
from homeassistant.components.media_player import (
|
||||||
SUPPORT_SELECT_SOUND_MODE,
|
|
||||||
MediaPlayerDeviceClass,
|
MediaPlayerDeviceClass,
|
||||||
MediaPlayerEntity,
|
MediaPlayerEntity,
|
||||||
|
MediaPlayerEntityFeature,
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
@ -229,7 +229,9 @@ class VizioDevice(MediaPlayerEntity):
|
|||||||
self._attr_is_volume_muted = None
|
self._attr_is_volume_muted = None
|
||||||
|
|
||||||
if VIZIO_SOUND_MODE in audio_settings:
|
if VIZIO_SOUND_MODE in audio_settings:
|
||||||
self._attr_supported_features |= SUPPORT_SELECT_SOUND_MODE
|
self._attr_supported_features |= (
|
||||||
|
MediaPlayerEntityFeature.SELECT_SOUND_MODE
|
||||||
|
)
|
||||||
self._attr_sound_mode = audio_settings[VIZIO_SOUND_MODE]
|
self._attr_sound_mode = audio_settings[VIZIO_SOUND_MODE]
|
||||||
if not self._attr_sound_mode_list:
|
if not self._attr_sound_mode_list:
|
||||||
self._attr_sound_mode_list = await self._device.get_setting_options(
|
self._attr_sound_mode_list = await self._device.get_setting_options(
|
||||||
@ -238,8 +240,10 @@ class VizioDevice(MediaPlayerEntity):
|
|||||||
log_api_exception=False,
|
log_api_exception=False,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
# Explicitly remove SUPPORT_SELECT_SOUND_MODE from supported features
|
# Explicitly remove MediaPlayerEntityFeature.SELECT_SOUND_MODE from supported features
|
||||||
self._attr_supported_features &= ~SUPPORT_SELECT_SOUND_MODE
|
self._attr_supported_features &= (
|
||||||
|
~MediaPlayerEntityFeature.SELECT_SOUND_MODE
|
||||||
|
)
|
||||||
|
|
||||||
if input_ := await self._device.get_current_input(log_api_exception=False):
|
if input_ := await self._device.get_current_input(log_api_exception=False):
|
||||||
self._current_input = input_
|
self._current_input = input_
|
||||||
|
@ -6,16 +6,12 @@ import logging
|
|||||||
import vlc
|
import vlc
|
||||||
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_PAUSE,
|
MediaPlayerEntityFeature,
|
||||||
SUPPORT_PLAY,
|
|
||||||
SUPPORT_PLAY_MEDIA,
|
|
||||||
SUPPORT_STOP,
|
|
||||||
SUPPORT_VOLUME_MUTE,
|
|
||||||
SUPPORT_VOLUME_SET,
|
|
||||||
)
|
)
|
||||||
|
from homeassistant.components.media_player.const import MEDIA_TYPE_MUSIC
|
||||||
from homeassistant.const import CONF_NAME, STATE_IDLE, STATE_PAUSED, STATE_PLAYING
|
from homeassistant.const import CONF_NAME, STATE_IDLE, STATE_PAUSED, STATE_PLAYING
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
@ -28,15 +24,6 @@ _LOGGER = logging.getLogger(__name__)
|
|||||||
CONF_ARGUMENTS = "arguments"
|
CONF_ARGUMENTS = "arguments"
|
||||||
DEFAULT_NAME = "Vlc"
|
DEFAULT_NAME = "Vlc"
|
||||||
|
|
||||||
SUPPORT_VLC = (
|
|
||||||
SUPPORT_PAUSE
|
|
||||||
| SUPPORT_VOLUME_SET
|
|
||||||
| SUPPORT_VOLUME_MUTE
|
|
||||||
| SUPPORT_PLAY_MEDIA
|
|
||||||
| SUPPORT_PLAY
|
|
||||||
| SUPPORT_STOP
|
|
||||||
)
|
|
||||||
|
|
||||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
||||||
{
|
{
|
||||||
vol.Optional(CONF_ARGUMENTS, default=""): cv.string,
|
vol.Optional(CONF_ARGUMENTS, default=""): cv.string,
|
||||||
@ -60,6 +47,15 @@ def setup_platform(
|
|||||||
class VlcDevice(MediaPlayerEntity):
|
class VlcDevice(MediaPlayerEntity):
|
||||||
"""Representation of a vlc player."""
|
"""Representation of a vlc player."""
|
||||||
|
|
||||||
|
_attr_supported_features = (
|
||||||
|
MediaPlayerEntityFeature.PAUSE
|
||||||
|
| MediaPlayerEntityFeature.VOLUME_SET
|
||||||
|
| MediaPlayerEntityFeature.VOLUME_MUTE
|
||||||
|
| MediaPlayerEntityFeature.PLAY_MEDIA
|
||||||
|
| MediaPlayerEntityFeature.PLAY
|
||||||
|
| MediaPlayerEntityFeature.STOP
|
||||||
|
)
|
||||||
|
|
||||||
def __init__(self, name, arguments):
|
def __init__(self, name, arguments):
|
||||||
"""Initialize the vlc device."""
|
"""Initialize the vlc device."""
|
||||||
self._instance = vlc.Instance(arguments)
|
self._instance = vlc.Instance(arguments)
|
||||||
@ -112,11 +108,6 @@ class VlcDevice(MediaPlayerEntity):
|
|||||||
"""Boolean if volume is currently muted."""
|
"""Boolean if volume is currently muted."""
|
||||||
return self._muted
|
return self._muted
|
||||||
|
|
||||||
@property
|
|
||||||
def supported_features(self):
|
|
||||||
"""Flag media player features that are supported."""
|
|
||||||
return SUPPORT_VLC
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def media_content_type(self):
|
def media_content_type(self):
|
||||||
"""Content type of current playing media."""
|
"""Content type of current playing media."""
|
||||||
|
@ -14,23 +14,10 @@ from homeassistant.components import media_source
|
|||||||
from homeassistant.components.media_player import (
|
from homeassistant.components.media_player import (
|
||||||
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 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_SHUFFLE_SET,
|
|
||||||
SUPPORT_STOP,
|
|
||||||
SUPPORT_VOLUME_MUTE,
|
|
||||||
SUPPORT_VOLUME_SET,
|
|
||||||
)
|
|
||||||
from homeassistant.config_entries import SOURCE_HASSIO, ConfigEntry
|
from homeassistant.config_entries import SOURCE_HASSIO, ConfigEntry
|
||||||
from homeassistant.const import CONF_NAME, STATE_IDLE, STATE_PAUSED, STATE_PLAYING
|
from homeassistant.const import CONF_NAME, STATE_IDLE, STATE_PAUSED, STATE_PLAYING
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
@ -44,21 +31,6 @@ from .const import DATA_AVAILABLE, DATA_VLC, DEFAULT_NAME, DOMAIN, LOGGER
|
|||||||
|
|
||||||
MAX_VOLUME = 500
|
MAX_VOLUME = 500
|
||||||
|
|
||||||
SUPPORT_VLC = (
|
|
||||||
SUPPORT_CLEAR_PLAYLIST
|
|
||||||
| SUPPORT_NEXT_TRACK
|
|
||||||
| SUPPORT_PAUSE
|
|
||||||
| SUPPORT_PLAY
|
|
||||||
| SUPPORT_PLAY_MEDIA
|
|
||||||
| SUPPORT_PREVIOUS_TRACK
|
|
||||||
| SUPPORT_SEEK
|
|
||||||
| SUPPORT_SHUFFLE_SET
|
|
||||||
| SUPPORT_STOP
|
|
||||||
| SUPPORT_VOLUME_MUTE
|
|
||||||
| SUPPORT_VOLUME_SET
|
|
||||||
| SUPPORT_BROWSE_MEDIA
|
|
||||||
)
|
|
||||||
|
|
||||||
_T = TypeVar("_T", bound="VlcDevice")
|
_T = TypeVar("_T", bound="VlcDevice")
|
||||||
_P = ParamSpec("_P")
|
_P = ParamSpec("_P")
|
||||||
|
|
||||||
@ -99,6 +71,21 @@ def catch_vlc_errors(
|
|||||||
class VlcDevice(MediaPlayerEntity):
|
class VlcDevice(MediaPlayerEntity):
|
||||||
"""Representation of a vlc player."""
|
"""Representation of a vlc player."""
|
||||||
|
|
||||||
|
_attr_supported_features = (
|
||||||
|
MediaPlayerEntityFeature.CLEAR_PLAYLIST
|
||||||
|
| MediaPlayerEntityFeature.NEXT_TRACK
|
||||||
|
| MediaPlayerEntityFeature.PAUSE
|
||||||
|
| MediaPlayerEntityFeature.PLAY
|
||||||
|
| MediaPlayerEntityFeature.PLAY_MEDIA
|
||||||
|
| MediaPlayerEntityFeature.PREVIOUS_TRACK
|
||||||
|
| MediaPlayerEntityFeature.SEEK
|
||||||
|
| MediaPlayerEntityFeature.SHUFFLE_SET
|
||||||
|
| MediaPlayerEntityFeature.STOP
|
||||||
|
| MediaPlayerEntityFeature.VOLUME_MUTE
|
||||||
|
| MediaPlayerEntityFeature.VOLUME_SET
|
||||||
|
| MediaPlayerEntityFeature.BROWSE_MEDIA
|
||||||
|
)
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, config_entry: ConfigEntry, vlc: Client, name: str, available: bool
|
self, config_entry: ConfigEntry, vlc: Client, name: str, available: bool
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -214,11 +201,6 @@ class VlcDevice(MediaPlayerEntity):
|
|||||||
"""Boolean if volume is currently muted."""
|
"""Boolean if volume is currently muted."""
|
||||||
return self._muted
|
return self._muted
|
||||||
|
|
||||||
@property
|
|
||||||
def supported_features(self) -> int:
|
|
||||||
"""Flag media player features that are supported."""
|
|
||||||
return SUPPORT_VLC
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def media_content_type(self) -> str:
|
def media_content_type(self) -> str:
|
||||||
"""Content type of current playing media."""
|
"""Content type of current playing media."""
|
||||||
|
@ -6,26 +6,14 @@ Volumio rest API: https://volumio.github.io/docs/API/REST_API.html
|
|||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import json
|
import json
|
||||||
|
|
||||||
from homeassistant.components.media_player import MediaPlayerEntity
|
from homeassistant.components.media_player import (
|
||||||
|
MediaPlayerEntity,
|
||||||
|
MediaPlayerEntityFeature,
|
||||||
|
)
|
||||||
from homeassistant.components.media_player.const import (
|
from homeassistant.components.media_player.const import (
|
||||||
MEDIA_TYPE_MUSIC,
|
MEDIA_TYPE_MUSIC,
|
||||||
REPEAT_MODE_ALL,
|
REPEAT_MODE_ALL,
|
||||||
REPEAT_MODE_OFF,
|
REPEAT_MODE_OFF,
|
||||||
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_VOLUME_MUTE,
|
|
||||||
SUPPORT_VOLUME_SET,
|
|
||||||
SUPPORT_VOLUME_STEP,
|
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
@ -43,24 +31,6 @@ from homeassistant.util import Throttle
|
|||||||
from .browse_media import browse_node, browse_top_level
|
from .browse_media import browse_node, browse_top_level
|
||||||
from .const import DATA_INFO, DATA_VOLUMIO, DOMAIN
|
from .const import DATA_INFO, DATA_VOLUMIO, DOMAIN
|
||||||
|
|
||||||
SUPPORT_VOLUMIO = (
|
|
||||||
SUPPORT_PAUSE
|
|
||||||
| SUPPORT_VOLUME_SET
|
|
||||||
| SUPPORT_VOLUME_MUTE
|
|
||||||
| SUPPORT_PREVIOUS_TRACK
|
|
||||||
| SUPPORT_NEXT_TRACK
|
|
||||||
| SUPPORT_SEEK
|
|
||||||
| SUPPORT_STOP
|
|
||||||
| SUPPORT_PLAY
|
|
||||||
| SUPPORT_PLAY_MEDIA
|
|
||||||
| SUPPORT_VOLUME_STEP
|
|
||||||
| SUPPORT_SELECT_SOURCE
|
|
||||||
| SUPPORT_REPEAT_SET
|
|
||||||
| SUPPORT_SHUFFLE_SET
|
|
||||||
| SUPPORT_CLEAR_PLAYLIST
|
|
||||||
| SUPPORT_BROWSE_MEDIA
|
|
||||||
)
|
|
||||||
|
|
||||||
PLAYLIST_UPDATE_INTERVAL = timedelta(seconds=15)
|
PLAYLIST_UPDATE_INTERVAL = timedelta(seconds=15)
|
||||||
|
|
||||||
|
|
||||||
@ -84,6 +54,24 @@ async def async_setup_entry(
|
|||||||
class Volumio(MediaPlayerEntity):
|
class Volumio(MediaPlayerEntity):
|
||||||
"""Volumio Player Object."""
|
"""Volumio Player Object."""
|
||||||
|
|
||||||
|
_attr_supported_features = (
|
||||||
|
MediaPlayerEntityFeature.PAUSE
|
||||||
|
| MediaPlayerEntityFeature.VOLUME_SET
|
||||||
|
| MediaPlayerEntityFeature.VOLUME_MUTE
|
||||||
|
| MediaPlayerEntityFeature.PREVIOUS_TRACK
|
||||||
|
| MediaPlayerEntityFeature.NEXT_TRACK
|
||||||
|
| MediaPlayerEntityFeature.SEEK
|
||||||
|
| MediaPlayerEntityFeature.STOP
|
||||||
|
| MediaPlayerEntityFeature.PLAY
|
||||||
|
| MediaPlayerEntityFeature.PLAY_MEDIA
|
||||||
|
| MediaPlayerEntityFeature.VOLUME_STEP
|
||||||
|
| MediaPlayerEntityFeature.SELECT_SOURCE
|
||||||
|
| MediaPlayerEntityFeature.REPEAT_SET
|
||||||
|
| MediaPlayerEntityFeature.SHUFFLE_SET
|
||||||
|
| MediaPlayerEntityFeature.CLEAR_PLAYLIST
|
||||||
|
| MediaPlayerEntityFeature.BROWSE_MEDIA
|
||||||
|
)
|
||||||
|
|
||||||
def __init__(self, volumio, uid, name, info):
|
def __init__(self, volumio, uid, name, info):
|
||||||
"""Initialize the media player."""
|
"""Initialize the media player."""
|
||||||
self._volumio = volumio
|
self._volumio = volumio
|
||||||
@ -203,11 +191,6 @@ class Volumio(MediaPlayerEntity):
|
|||||||
"""Name of the current input source."""
|
"""Name of the current input source."""
|
||||||
return self._currentplaylist
|
return self._currentplaylist
|
||||||
|
|
||||||
@property
|
|
||||||
def supported_features(self):
|
|
||||||
"""Flag of media commands that are supported."""
|
|
||||||
return SUPPORT_VOLUMIO
|
|
||||||
|
|
||||||
async def async_media_next_track(self):
|
async def async_media_next_track(self):
|
||||||
"""Send media_next command to media player."""
|
"""Send media_next command to media player."""
|
||||||
await self._volumio.next()
|
await self._volumio.next()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user