Use EntityFeature enum in components (p**) (#69434)
This commit is contained in:
parent
b8fc399882
commit
80a857c6c2
12 changed files with 137 additions and 206 deletions
|
@ -6,13 +6,10 @@ from datetime import timedelta
|
|||
from panacotta import PanasonicBD
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.media_player import PLATFORM_SCHEMA, MediaPlayerEntity
|
||||
from homeassistant.components.media_player.const import (
|
||||
SUPPORT_PAUSE,
|
||||
SUPPORT_PLAY,
|
||||
SUPPORT_STOP,
|
||||
SUPPORT_TURN_OFF,
|
||||
SUPPORT_TURN_ON,
|
||||
from homeassistant.components.media_player import (
|
||||
PLATFORM_SCHEMA,
|
||||
MediaPlayerEntity,
|
||||
MediaPlayerEntityFeature,
|
||||
)
|
||||
from homeassistant.const import (
|
||||
CONF_HOST,
|
||||
|
@ -31,9 +28,6 @@ DEFAULT_NAME = "Panasonic Blu-Ray"
|
|||
|
||||
SCAN_INTERVAL = timedelta(seconds=30)
|
||||
|
||||
SUPPORT_PANASONIC_BD = (
|
||||
SUPPORT_TURN_ON | SUPPORT_TURN_OFF | SUPPORT_PLAY | SUPPORT_STOP | SUPPORT_PAUSE
|
||||
)
|
||||
|
||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
||||
{
|
||||
|
@ -59,6 +53,14 @@ def setup_platform(
|
|||
class PanasonicBluRay(MediaPlayerEntity):
|
||||
"""Representation of a Panasonic Blu-ray device."""
|
||||
|
||||
_attr_supported_features = (
|
||||
MediaPlayerEntityFeature.TURN_ON
|
||||
| MediaPlayerEntityFeature.TURN_OFF
|
||||
| MediaPlayerEntityFeature.PLAY
|
||||
| MediaPlayerEntityFeature.STOP
|
||||
| MediaPlayerEntityFeature.PAUSE
|
||||
)
|
||||
|
||||
def __init__(self, ip, name):
|
||||
"""Initialize the Panasonic Blue-ray device."""
|
||||
self._device = PanasonicBD(ip)
|
||||
|
@ -83,11 +85,6 @@ class PanasonicBluRay(MediaPlayerEntity):
|
|||
"""Return _state variable, containing the appropriate constant."""
|
||||
return self._state
|
||||
|
||||
@property
|
||||
def supported_features(self):
|
||||
"""Flag media player features that are supported."""
|
||||
return SUPPORT_PANASONIC_BD
|
||||
|
||||
@property
|
||||
def media_duration(self):
|
||||
"""Duration of current playing media in seconds."""
|
||||
|
|
|
@ -9,25 +9,12 @@ from homeassistant.components import media_source
|
|||
from homeassistant.components.media_player import (
|
||||
MediaPlayerDeviceClass,
|
||||
MediaPlayerEntity,
|
||||
MediaPlayerEntityFeature,
|
||||
)
|
||||
from homeassistant.components.media_player.browse_media import (
|
||||
async_process_play_media_url,
|
||||
)
|
||||
from homeassistant.components.media_player.const import (
|
||||
MEDIA_TYPE_URL,
|
||||
SUPPORT_BROWSE_MEDIA,
|
||||
SUPPORT_NEXT_TRACK,
|
||||
SUPPORT_PAUSE,
|
||||
SUPPORT_PLAY,
|
||||
SUPPORT_PLAY_MEDIA,
|
||||
SUPPORT_PREVIOUS_TRACK,
|
||||
SUPPORT_STOP,
|
||||
SUPPORT_TURN_OFF,
|
||||
SUPPORT_TURN_ON,
|
||||
SUPPORT_VOLUME_MUTE,
|
||||
SUPPORT_VOLUME_SET,
|
||||
SUPPORT_VOLUME_STEP,
|
||||
)
|
||||
from homeassistant.components.media_player.const import MEDIA_TYPE_URL
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_NAME
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
@ -45,21 +32,6 @@ from .const import (
|
|||
DOMAIN,
|
||||
)
|
||||
|
||||
SUPPORT_VIERATV = (
|
||||
SUPPORT_PAUSE
|
||||
| SUPPORT_VOLUME_STEP
|
||||
| SUPPORT_VOLUME_SET
|
||||
| SUPPORT_VOLUME_MUTE
|
||||
| SUPPORT_PREVIOUS_TRACK
|
||||
| SUPPORT_NEXT_TRACK
|
||||
| SUPPORT_TURN_OFF
|
||||
| SUPPORT_TURN_ON
|
||||
| SUPPORT_PLAY
|
||||
| SUPPORT_PLAY_MEDIA
|
||||
| SUPPORT_STOP
|
||||
| SUPPORT_BROWSE_MEDIA
|
||||
)
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
|
@ -83,6 +55,21 @@ async def async_setup_entry(
|
|||
class PanasonicVieraTVEntity(MediaPlayerEntity):
|
||||
"""Representation of a Panasonic Viera TV."""
|
||||
|
||||
_attr_supported_features = (
|
||||
MediaPlayerEntityFeature.PAUSE
|
||||
| MediaPlayerEntityFeature.VOLUME_STEP
|
||||
| MediaPlayerEntityFeature.VOLUME_SET
|
||||
| MediaPlayerEntityFeature.VOLUME_MUTE
|
||||
| MediaPlayerEntityFeature.PREVIOUS_TRACK
|
||||
| MediaPlayerEntityFeature.NEXT_TRACK
|
||||
| MediaPlayerEntityFeature.TURN_OFF
|
||||
| MediaPlayerEntityFeature.TURN_ON
|
||||
| MediaPlayerEntityFeature.PLAY
|
||||
| MediaPlayerEntityFeature.PLAY_MEDIA
|
||||
| MediaPlayerEntityFeature.STOP
|
||||
| MediaPlayerEntityFeature.BROWSE_MEDIA
|
||||
)
|
||||
|
||||
def __init__(self, remote, name, device_info):
|
||||
"""Initialize the entity."""
|
||||
self._remote = remote
|
||||
|
@ -138,11 +125,6 @@ class PanasonicVieraTVEntity(MediaPlayerEntity):
|
|||
"""Boolean if volume is currently muted."""
|
||||
return self._remote.muted
|
||||
|
||||
@property
|
||||
def supported_features(self):
|
||||
"""Flag media player features that are supported."""
|
||||
return SUPPORT_VIERATV
|
||||
|
||||
async def async_update(self):
|
||||
"""Retrieve the latest data."""
|
||||
await self._remote.async_update()
|
||||
|
|
|
@ -11,16 +11,11 @@ import signal
|
|||
import pexpect
|
||||
|
||||
from homeassistant import util
|
||||
from homeassistant.components.media_player import MediaPlayerEntity
|
||||
from homeassistant.components.media_player.const import (
|
||||
MEDIA_TYPE_MUSIC,
|
||||
SUPPORT_NEXT_TRACK,
|
||||
SUPPORT_PAUSE,
|
||||
SUPPORT_PLAY,
|
||||
SUPPORT_SELECT_SOURCE,
|
||||
SUPPORT_TURN_OFF,
|
||||
SUPPORT_TURN_ON,
|
||||
from homeassistant.components.media_player import (
|
||||
MediaPlayerEntity,
|
||||
MediaPlayerEntityFeature,
|
||||
)
|
||||
from homeassistant.components.media_player.const import MEDIA_TYPE_MUSIC
|
||||
from homeassistant.const import (
|
||||
EVENT_HOMEASSISTANT_STOP,
|
||||
SERVICE_MEDIA_NEXT_TRACK,
|
||||
|
@ -39,16 +34,6 @@ from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
|||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
# SUPPORT_VOLUME_SET is close to available but we need volume up/down
|
||||
# controls in the GUI.
|
||||
PANDORA_SUPPORT = (
|
||||
SUPPORT_PAUSE
|
||||
| SUPPORT_TURN_ON
|
||||
| SUPPORT_TURN_OFF
|
||||
| SUPPORT_NEXT_TRACK
|
||||
| SUPPORT_SELECT_SOURCE
|
||||
| SUPPORT_PLAY
|
||||
)
|
||||
|
||||
CMD_MAP = {
|
||||
SERVICE_MEDIA_NEXT_TRACK: "n",
|
||||
|
@ -85,6 +70,17 @@ def setup_platform(
|
|||
class PandoraMediaPlayer(MediaPlayerEntity):
|
||||
"""A media player that uses the Pianobar interface to Pandora."""
|
||||
|
||||
# MediaPlayerEntityFeature.VOLUME_SET is close to available but we need volume up/down
|
||||
# controls in the GUI.
|
||||
_attr_supported_features = (
|
||||
MediaPlayerEntityFeature.PAUSE
|
||||
| MediaPlayerEntityFeature.TURN_ON
|
||||
| MediaPlayerEntityFeature.TURN_OFF
|
||||
| MediaPlayerEntityFeature.NEXT_TRACK
|
||||
| MediaPlayerEntityFeature.SELECT_SOURCE
|
||||
| MediaPlayerEntityFeature.PLAY
|
||||
)
|
||||
|
||||
def __init__(self, name):
|
||||
"""Initialize the Pandora device."""
|
||||
self._name = name
|
||||
|
@ -172,11 +168,6 @@ class PandoraMediaPlayer(MediaPlayerEntity):
|
|||
self._send_pianobar_command(SERVICE_MEDIA_NEXT_TRACK)
|
||||
self.schedule_update_ha_state()
|
||||
|
||||
@property
|
||||
def supported_features(self):
|
||||
"""Flag media player features that are supported."""
|
||||
return PANDORA_SUPPORT
|
||||
|
||||
@property
|
||||
def source(self):
|
||||
"""Name of the current input source."""
|
||||
|
|
|
@ -7,6 +7,7 @@ from homeassistant.components.media_player import (
|
|||
BrowseMedia,
|
||||
MediaPlayerDeviceClass,
|
||||
MediaPlayerEntity,
|
||||
MediaPlayerEntityFeature,
|
||||
)
|
||||
from homeassistant.components.media_player.const import (
|
||||
MEDIA_CLASS_APP,
|
||||
|
@ -16,19 +17,6 @@ from homeassistant.components.media_player.const import (
|
|||
MEDIA_TYPE_APPS,
|
||||
MEDIA_TYPE_CHANNEL,
|
||||
MEDIA_TYPE_CHANNELS,
|
||||
SUPPORT_BROWSE_MEDIA,
|
||||
SUPPORT_NEXT_TRACK,
|
||||
SUPPORT_PAUSE,
|
||||
SUPPORT_PLAY,
|
||||
SUPPORT_PLAY_MEDIA,
|
||||
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.components.media_player.errors import BrowseError
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
|
@ -42,18 +30,18 @@ from . import LOGGER as _LOGGER, PhilipsTVDataUpdateCoordinator
|
|||
from .const import DOMAIN
|
||||
|
||||
SUPPORT_PHILIPS_JS = (
|
||||
SUPPORT_TURN_OFF
|
||||
| SUPPORT_VOLUME_STEP
|
||||
| SUPPORT_VOLUME_SET
|
||||
| SUPPORT_VOLUME_MUTE
|
||||
| SUPPORT_SELECT_SOURCE
|
||||
| SUPPORT_NEXT_TRACK
|
||||
| SUPPORT_PREVIOUS_TRACK
|
||||
| SUPPORT_PLAY_MEDIA
|
||||
| SUPPORT_BROWSE_MEDIA
|
||||
| SUPPORT_PLAY
|
||||
| SUPPORT_PAUSE
|
||||
| SUPPORT_STOP
|
||||
MediaPlayerEntityFeature.TURN_OFF
|
||||
| MediaPlayerEntityFeature.VOLUME_STEP
|
||||
| MediaPlayerEntityFeature.VOLUME_SET
|
||||
| MediaPlayerEntityFeature.VOLUME_MUTE
|
||||
| MediaPlayerEntityFeature.SELECT_SOURCE
|
||||
| MediaPlayerEntityFeature.NEXT_TRACK
|
||||
| MediaPlayerEntityFeature.PREVIOUS_TRACK
|
||||
| MediaPlayerEntityFeature.PLAY_MEDIA
|
||||
| MediaPlayerEntityFeature.BROWSE_MEDIA
|
||||
| MediaPlayerEntityFeature.PLAY
|
||||
| MediaPlayerEntityFeature.PAUSE
|
||||
| MediaPlayerEntityFeature.STOP
|
||||
)
|
||||
|
||||
CONF_ON_ACTION = "turn_on_action"
|
||||
|
@ -128,7 +116,7 @@ class PhilipsTVMediaPlayer(
|
|||
if self.coordinator.turn_on or (
|
||||
self._tv.on and self._tv.powerstate is not None
|
||||
):
|
||||
supports |= SUPPORT_TURN_ON
|
||||
supports |= MediaPlayerEntityFeature.TURN_ON
|
||||
return supports
|
||||
|
||||
@property
|
||||
|
|
|
@ -6,16 +6,10 @@ import telnetlib
|
|||
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.media_player import PLATFORM_SCHEMA, MediaPlayerEntity
|
||||
from homeassistant.components.media_player.const import (
|
||||
SUPPORT_PAUSE,
|
||||
SUPPORT_PLAY,
|
||||
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,
|
||||
|
@ -39,16 +33,6 @@ DEFAULT_PORT = 23 # telnet default. Some Pioneer AVRs use 8102
|
|||
DEFAULT_TIMEOUT = None
|
||||
DEFAULT_SOURCES: dict[str, str] = {}
|
||||
|
||||
SUPPORT_PIONEER = (
|
||||
SUPPORT_PAUSE
|
||||
| SUPPORT_VOLUME_SET
|
||||
| SUPPORT_VOLUME_STEP
|
||||
| SUPPORT_VOLUME_MUTE
|
||||
| SUPPORT_TURN_ON
|
||||
| SUPPORT_TURN_OFF
|
||||
| SUPPORT_SELECT_SOURCE
|
||||
| SUPPORT_PLAY
|
||||
)
|
||||
|
||||
MAX_VOLUME = 185
|
||||
MAX_SOURCE_NUMBERS = 60
|
||||
|
@ -86,6 +70,17 @@ def setup_platform(
|
|||
class PioneerDevice(MediaPlayerEntity):
|
||||
"""Representation of a Pioneer device."""
|
||||
|
||||
_attr_supported_features = (
|
||||
MediaPlayerEntityFeature.PAUSE
|
||||
| MediaPlayerEntityFeature.VOLUME_SET
|
||||
| MediaPlayerEntityFeature.VOLUME_STEP
|
||||
| MediaPlayerEntityFeature.VOLUME_MUTE
|
||||
| MediaPlayerEntityFeature.TURN_ON
|
||||
| MediaPlayerEntityFeature.TURN_OFF
|
||||
| MediaPlayerEntityFeature.SELECT_SOURCE
|
||||
| MediaPlayerEntityFeature.PLAY
|
||||
)
|
||||
|
||||
def __init__(self, name, host, port, timeout, sources):
|
||||
"""Initialize the Pioneer device."""
|
||||
self._name = name
|
||||
|
@ -200,11 +195,6 @@ class PioneerDevice(MediaPlayerEntity):
|
|||
"""Boolean if volume is currently muted."""
|
||||
return self._muted
|
||||
|
||||
@property
|
||||
def supported_features(self):
|
||||
"""Flag media player features that are supported."""
|
||||
return SUPPORT_PIONEER
|
||||
|
||||
@property
|
||||
def source(self):
|
||||
"""Return the current input source."""
|
||||
|
|
|
@ -5,12 +5,10 @@ from pypjlink import MUTE_AUDIO, Projector
|
|||
from pypjlink.projector import ProjectorError
|
||||
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,
|
||||
from homeassistant.components.media_player import (
|
||||
PLATFORM_SCHEMA,
|
||||
MediaPlayerEntity,
|
||||
MediaPlayerEntityFeature,
|
||||
)
|
||||
from homeassistant.const import (
|
||||
CONF_HOST,
|
||||
|
@ -41,10 +39,6 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
|||
}
|
||||
)
|
||||
|
||||
SUPPORT_PJLINK = (
|
||||
SUPPORT_VOLUME_MUTE | SUPPORT_TURN_ON | SUPPORT_TURN_OFF | SUPPORT_SELECT_SOURCE
|
||||
)
|
||||
|
||||
|
||||
def setup_platform(
|
||||
hass: HomeAssistant,
|
||||
|
@ -80,6 +74,13 @@ def format_input_source(input_source_name, input_source_number):
|
|||
class PjLinkDevice(MediaPlayerEntity):
|
||||
"""Representation of a PJLink device."""
|
||||
|
||||
_attr_supported_features = (
|
||||
MediaPlayerEntityFeature.VOLUME_MUTE
|
||||
| MediaPlayerEntityFeature.TURN_ON
|
||||
| MediaPlayerEntityFeature.TURN_OFF
|
||||
| MediaPlayerEntityFeature.SELECT_SOURCE
|
||||
)
|
||||
|
||||
def __init__(self, host, port, name, encoding, password):
|
||||
"""Iinitialize the PJLink device."""
|
||||
self._host = host
|
||||
|
@ -160,11 +161,6 @@ class PjLinkDevice(MediaPlayerEntity):
|
|||
"""Return all available input sources."""
|
||||
return self._source_list
|
||||
|
||||
@property
|
||||
def supported_features(self):
|
||||
"""Return projector supported features."""
|
||||
return SUPPORT_PJLINK
|
||||
|
||||
def turn_off(self):
|
||||
"""Turn projector off."""
|
||||
with self.projector() as projector:
|
||||
|
|
|
@ -7,20 +7,12 @@ import logging
|
|||
import plexapi.exceptions
|
||||
import requests.exceptions
|
||||
|
||||
from homeassistant.components.media_player import DOMAIN as MP_DOMAIN, MediaPlayerEntity
|
||||
from homeassistant.components.media_player.const import (
|
||||
MEDIA_TYPE_MUSIC,
|
||||
SUPPORT_BROWSE_MEDIA,
|
||||
SUPPORT_NEXT_TRACK,
|
||||
SUPPORT_PAUSE,
|
||||
SUPPORT_PLAY,
|
||||
SUPPORT_PLAY_MEDIA,
|
||||
SUPPORT_PREVIOUS_TRACK,
|
||||
SUPPORT_SEEK,
|
||||
SUPPORT_STOP,
|
||||
SUPPORT_VOLUME_MUTE,
|
||||
SUPPORT_VOLUME_SET,
|
||||
from homeassistant.components.media_player import (
|
||||
DOMAIN as MP_DOMAIN,
|
||||
MediaPlayerEntity,
|
||||
MediaPlayerEntityFeature,
|
||||
)
|
||||
from homeassistant.components.media_player.const import MEDIA_TYPE_MUSIC
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import STATE_IDLE, STATE_PAUSED, STATE_PLAYING
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
|
@ -389,19 +381,21 @@ class PlexMediaPlayer(MediaPlayerEntity):
|
|||
"""Flag media player features that are supported."""
|
||||
if self.device and "playback" in self._device_protocol_capabilities:
|
||||
return (
|
||||
SUPPORT_PAUSE
|
||||
| SUPPORT_PREVIOUS_TRACK
|
||||
| SUPPORT_NEXT_TRACK
|
||||
| SUPPORT_STOP
|
||||
| SUPPORT_SEEK
|
||||
| SUPPORT_VOLUME_SET
|
||||
| SUPPORT_PLAY
|
||||
| SUPPORT_PLAY_MEDIA
|
||||
| SUPPORT_VOLUME_MUTE
|
||||
| SUPPORT_BROWSE_MEDIA
|
||||
MediaPlayerEntityFeature.PAUSE
|
||||
| MediaPlayerEntityFeature.PREVIOUS_TRACK
|
||||
| MediaPlayerEntityFeature.NEXT_TRACK
|
||||
| MediaPlayerEntityFeature.STOP
|
||||
| MediaPlayerEntityFeature.SEEK
|
||||
| MediaPlayerEntityFeature.VOLUME_SET
|
||||
| MediaPlayerEntityFeature.PLAY
|
||||
| MediaPlayerEntityFeature.PLAY_MEDIA
|
||||
| MediaPlayerEntityFeature.VOLUME_MUTE
|
||||
| MediaPlayerEntityFeature.BROWSE_MEDIA
|
||||
)
|
||||
|
||||
return SUPPORT_BROWSE_MEDIA | SUPPORT_PLAY_MEDIA
|
||||
return (
|
||||
MediaPlayerEntityFeature.BROWSE_MEDIA | MediaPlayerEntityFeature.PLAY_MEDIA
|
||||
)
|
||||
|
||||
def set_volume_level(self, volume):
|
||||
"""Set volume level, range 0..1."""
|
||||
|
|
|
@ -4,7 +4,7 @@ from __future__ import annotations
|
|||
from collections.abc import Mapping
|
||||
from typing import Any
|
||||
|
||||
from homeassistant.components.climate import ClimateEntity
|
||||
from homeassistant.components.climate import ClimateEntity, ClimateEntityFeature
|
||||
from homeassistant.components.climate.const import (
|
||||
CURRENT_HVAC_COOL,
|
||||
CURRENT_HVAC_HEAT,
|
||||
|
@ -12,8 +12,6 @@ from homeassistant.components.climate.const import (
|
|||
HVAC_MODE_AUTO,
|
||||
HVAC_MODE_COOL,
|
||||
HVAC_MODE_HEAT,
|
||||
SUPPORT_PRESET_MODE,
|
||||
SUPPORT_TARGET_TEMPERATURE,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS
|
||||
|
@ -57,9 +55,9 @@ class PlugwiseClimateEntity(PlugwiseEntity, ClimateEntity):
|
|||
self._attr_name = self.device.get("name")
|
||||
|
||||
# Determine preset modes
|
||||
self._attr_supported_features = SUPPORT_TARGET_TEMPERATURE
|
||||
self._attr_supported_features = ClimateEntityFeature.TARGET_TEMPERATURE
|
||||
if presets := self.device.get("presets"):
|
||||
self._attr_supported_features |= SUPPORT_PRESET_MODE
|
||||
self._attr_supported_features |= ClimateEntityFeature.PRESET_MODE
|
||||
self._attr_preset_modes = list(presets)
|
||||
|
||||
# Determine hvac modes and current hvac mode
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
"""Support for Minut Point."""
|
||||
import logging
|
||||
|
||||
from homeassistant.components.alarm_control_panel import DOMAIN, AlarmControlPanelEntity
|
||||
from homeassistant.components.alarm_control_panel.const import SUPPORT_ALARM_ARM_AWAY
|
||||
from homeassistant.components.alarm_control_panel import (
|
||||
DOMAIN,
|
||||
AlarmControlPanelEntity,
|
||||
AlarmControlPanelEntityFeature,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import (
|
||||
STATE_ALARM_ARMED_AWAY,
|
||||
|
@ -46,6 +49,8 @@ async def async_setup_entry(
|
|||
class MinutPointAlarmControl(AlarmControlPanelEntity):
|
||||
"""The platform class required by Home Assistant."""
|
||||
|
||||
_attr_supported_features = AlarmControlPanelEntityFeature.ARM_AWAY
|
||||
|
||||
def __init__(self, point_client, home_id):
|
||||
"""Initialize the entity."""
|
||||
self._client = point_client
|
||||
|
@ -96,11 +101,6 @@ class MinutPointAlarmControl(AlarmControlPanelEntity):
|
|||
"""Return state of the device."""
|
||||
return EVENT_MAP.get(self._home["alarm_status"], STATE_ALARM_ARMED_AWAY)
|
||||
|
||||
@property
|
||||
def supported_features(self) -> int:
|
||||
"""Return the list of supported features."""
|
||||
return SUPPORT_ALARM_ARM_AWAY
|
||||
|
||||
@property
|
||||
def changed_by(self):
|
||||
"""Return the user the last change was triggered by."""
|
||||
|
|
|
@ -4,7 +4,11 @@ from __future__ import annotations
|
|||
import proliphix
|
||||
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 (
|
||||
CURRENT_HVAC_COOL,
|
||||
CURRENT_HVAC_HEAT,
|
||||
|
@ -13,7 +17,6 @@ from homeassistant.components.climate.const import (
|
|||
HVAC_MODE_COOL,
|
||||
HVAC_MODE_HEAT,
|
||||
HVAC_MODE_OFF,
|
||||
SUPPORT_TARGET_TEMPERATURE,
|
||||
)
|
||||
from homeassistant.const import (
|
||||
ATTR_TEMPERATURE,
|
||||
|
@ -59,16 +62,13 @@ def setup_platform(
|
|||
class ProliphixThermostat(ClimateEntity):
|
||||
"""Representation a Proliphix thermostat."""
|
||||
|
||||
_attr_supported_features = ClimateEntityFeature.TARGET_TEMPERATURE
|
||||
|
||||
def __init__(self, pdp):
|
||||
"""Initialize the thermostat."""
|
||||
self._pdp = pdp
|
||||
self._name = None
|
||||
|
||||
@property
|
||||
def supported_features(self):
|
||||
"""Return the list of supported features."""
|
||||
return SUPPORT_TARGET_TEMPERATURE
|
||||
|
||||
@property
|
||||
def should_poll(self):
|
||||
"""Set up polling needed for thermostat."""
|
||||
|
|
|
@ -5,10 +5,7 @@ from pyprosegur.auth import Auth
|
|||
from pyprosegur.installation import Installation, Status
|
||||
|
||||
import homeassistant.components.alarm_control_panel as alarm
|
||||
from homeassistant.components.alarm_control_panel import (
|
||||
SUPPORT_ALARM_ARM_AWAY,
|
||||
SUPPORT_ALARM_ARM_HOME,
|
||||
)
|
||||
from homeassistant.components.alarm_control_panel import AlarmControlPanelEntityFeature
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import (
|
||||
STATE_ALARM_ARMED_AWAY,
|
||||
|
@ -43,6 +40,11 @@ async def async_setup_entry(
|
|||
class ProsegurAlarm(alarm.AlarmControlPanelEntity):
|
||||
"""Representation of a Prosegur alarm status."""
|
||||
|
||||
_attr_supported_features = (
|
||||
AlarmControlPanelEntityFeature.ARM_AWAY
|
||||
| AlarmControlPanelEntityFeature.ARM_HOME
|
||||
)
|
||||
|
||||
def __init__(self, contract: str, auth: Auth) -> None:
|
||||
"""Initialize the Prosegur alarm panel."""
|
||||
self._changed_by = None
|
||||
|
@ -53,7 +55,6 @@ class ProsegurAlarm(alarm.AlarmControlPanelEntity):
|
|||
|
||||
self._attr_name = f"contract {self.contract}"
|
||||
self._attr_unique_id = self.contract
|
||||
self._attr_supported_features = SUPPORT_ALARM_ARM_AWAY | SUPPORT_ALARM_ARM_HOME
|
||||
|
||||
async def async_update(self):
|
||||
"""Update alarm status."""
|
||||
|
|
|
@ -7,17 +7,15 @@ from pyps4_2ndscreen.errors import NotReady, PSDataIncomplete
|
|||
from pyps4_2ndscreen.media_art import TYPE_APP as PS_TYPE_APP
|
||||
import pyps4_2ndscreen.ps4 as pyps4
|
||||
|
||||
from homeassistant.components.media_player import MediaPlayerEntity
|
||||
from homeassistant.components.media_player import (
|
||||
MediaPlayerEntity,
|
||||
MediaPlayerEntityFeature,
|
||||
)
|
||||
from homeassistant.components.media_player.const import (
|
||||
ATTR_MEDIA_CONTENT_TYPE,
|
||||
ATTR_MEDIA_TITLE,
|
||||
MEDIA_TYPE_APP,
|
||||
MEDIA_TYPE_GAME,
|
||||
SUPPORT_PAUSE,
|
||||
SUPPORT_SELECT_SOURCE,
|
||||
SUPPORT_STOP,
|
||||
SUPPORT_TURN_OFF,
|
||||
SUPPORT_TURN_ON,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import (
|
||||
|
@ -46,13 +44,6 @@ from .const import (
|
|||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
SUPPORT_PS4 = (
|
||||
SUPPORT_TURN_OFF
|
||||
| SUPPORT_TURN_ON
|
||||
| SUPPORT_PAUSE
|
||||
| SUPPORT_STOP
|
||||
| SUPPORT_SELECT_SOURCE
|
||||
)
|
||||
|
||||
ICON = "mdi:sony-playstation"
|
||||
MEDIA_IMAGE_DEFAULT = None
|
||||
|
@ -81,6 +72,14 @@ async def async_setup_entry(
|
|||
class PS4Device(MediaPlayerEntity):
|
||||
"""Representation of a PS4."""
|
||||
|
||||
_attr_supported_features = (
|
||||
MediaPlayerEntityFeature.TURN_OFF
|
||||
| MediaPlayerEntityFeature.TURN_ON
|
||||
| MediaPlayerEntityFeature.PAUSE
|
||||
| MediaPlayerEntityFeature.STOP
|
||||
| MediaPlayerEntityFeature.SELECT_SOURCE
|
||||
)
|
||||
|
||||
def __init__(self, config, name, host, region, ps4, creds):
|
||||
"""Initialize the ps4 device."""
|
||||
self._entry_id = config.entry_id
|
||||
|
@ -430,11 +429,6 @@ class PS4Device(MediaPlayerEntity):
|
|||
"""Title of current playing media."""
|
||||
return self._media_title
|
||||
|
||||
@property
|
||||
def supported_features(self):
|
||||
"""Media player features that are supported."""
|
||||
return SUPPORT_PS4
|
||||
|
||||
@property
|
||||
def source(self):
|
||||
"""Return the current input source."""
|
||||
|
|
Loading…
Add table
Reference in a new issue