Code linting
This commit is contained in:
@@ -1,23 +1,27 @@
|
||||
import logging
|
||||
from homeassistant.components.media_player import (
|
||||
SUPPORT_PLAY, SUPPORT_PLAY_MEDIA,
|
||||
SUPPORT_PAUSE, SUPPORT_STOP,
|
||||
SUPPORT_VOLUME_SET, SUPPORT_VOLUME_MUTE,
|
||||
MediaPlayerEntity,
|
||||
)
|
||||
SUPPORT_PLAY,
|
||||
SUPPORT_PLAY_MEDIA,
|
||||
SUPPORT_PAUSE,
|
||||
SUPPORT_STOP,
|
||||
SUPPORT_VOLUME_SET,
|
||||
SUPPORT_VOLUME_MUTE,
|
||||
MediaPlayerEntity,
|
||||
)
|
||||
from homeassistant.const import (
|
||||
STATE_UNAVAILABLE,
|
||||
STATE_PAUSED,
|
||||
STATE_PLAYING,
|
||||
STATE_IDLE,
|
||||
STATE_UNKNOWN,
|
||||
)
|
||||
STATE_UNAVAILABLE,
|
||||
STATE_PAUSED,
|
||||
STATE_PLAYING,
|
||||
STATE_IDLE,
|
||||
STATE_UNKNOWN,
|
||||
)
|
||||
|
||||
from .helpers import setup_platform, BrowserModEntity
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
PLATFORM = 'media_player'
|
||||
PLATFORM = "media_player"
|
||||
|
||||
|
||||
async def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
|
||||
return setup_platform(hass, config, async_add_devices, PLATFORM, BrowserModPlayer)
|
||||
@@ -40,9 +44,9 @@ class BrowserModPlayer(MediaPlayerEntity, BrowserModEntity):
|
||||
@property
|
||||
def device_state_attributes(self):
|
||||
return {
|
||||
"type": "browser_mod",
|
||||
"deviceID": self.deviceID,
|
||||
}
|
||||
"type": "browser_mod",
|
||||
"deviceID": self.deviceID,
|
||||
}
|
||||
|
||||
@property
|
||||
def state(self):
|
||||
@@ -50,37 +54,48 @@ class BrowserModPlayer(MediaPlayerEntity, BrowserModEntity):
|
||||
return STATE_UNAVAILABLE
|
||||
state = self.data.get("state", "unknown")
|
||||
return {
|
||||
"playing": STATE_PLAYING,
|
||||
"paused": STATE_PAUSED,
|
||||
"stopped": STATE_IDLE,
|
||||
}.get(state, STATE_UNKNOWN)
|
||||
"playing": STATE_PLAYING,
|
||||
"paused": STATE_PAUSED,
|
||||
"stopped": STATE_IDLE,
|
||||
}.get(state, STATE_UNKNOWN)
|
||||
|
||||
@property
|
||||
def supported_features(self):
|
||||
return (
|
||||
SUPPORT_PLAY | SUPPORT_PLAY_MEDIA |
|
||||
SUPPORT_PAUSE | SUPPORT_STOP |
|
||||
SUPPORT_VOLUME_SET | SUPPORT_VOLUME_MUTE
|
||||
)
|
||||
SUPPORT_PLAY
|
||||
| SUPPORT_PLAY_MEDIA
|
||||
| SUPPORT_PAUSE
|
||||
| SUPPORT_STOP
|
||||
| SUPPORT_VOLUME_SET
|
||||
| SUPPORT_VOLUME_MUTE
|
||||
)
|
||||
|
||||
@property
|
||||
def volume_level(self):
|
||||
return self.data.get("volume", 0)
|
||||
|
||||
@property
|
||||
def is_volume_muted(self):
|
||||
return self.data.get("muted", False)
|
||||
|
||||
@property
|
||||
def media_content_id(self):
|
||||
return self.data.get("src", "")
|
||||
|
||||
def set_volume_level(self, volume):
|
||||
self.connection.send("set_volume", volume_level=volume)
|
||||
|
||||
def mute_volume(self, mute):
|
||||
self.connection.send("mute", mute=mute)
|
||||
|
||||
def play_media(self, media_type, media_id, **kwargs):
|
||||
self.connection.send("play", media_content_id=media_id)
|
||||
|
||||
def media_play(self):
|
||||
self.connection.send("play")
|
||||
|
||||
def media_pause(self):
|
||||
self.connection.send("pause")
|
||||
|
||||
def media_stop(self):
|
||||
self.connection.send("stop")
|
||||
|
||||
Reference in New Issue
Block a user