From b7eb237632d4c6b277518c0e4f6ab1c8d4a060b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Lov=C3=A9n?= Date: Thu, 27 Jun 2019 10:35:33 +0200 Subject: [PATCH] Various fixes --- custom_components/browser_mod/connection.py | 10 ++++++---- custom_components/browser_mod/media_player.py | 9 +++++++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/custom_components/browser_mod/connection.py b/custom_components/browser_mod/connection.py index 9623f67..6daa447 100644 --- a/custom_components/browser_mod/connection.py +++ b/custom_components/browser_mod/connection.py @@ -46,7 +46,6 @@ def handle_update(hass, connection, msg): class BrowserModEntity(Entity): def __init__(self, hass, deviceID, alias=None): - self._hass = hass self._deviceID = deviceID self._alias = alias self._ws_data = {} @@ -66,16 +65,19 @@ class BrowserModEntity(Entity): _LOGGER.error(f"Connecting {self.entity_id}") self.ws_send("update") connection.subscriptions[cid] = self.ws_disconnect - self.schedule_update_ha_state() + if self.hass: + self.schedule_update_ha_state() def ws_disconnect(self): self._ws_cid = None self._ws_connection = None - self.schedule_update_ha_state() + if self.hass: + self.schedule_update_ha_state() def ws_update(self, data): self._ws_data = data - self.schedule_update_ha_state() + if self.hass: + self.schedule_update_ha_state() @property def device_id(self): diff --git a/custom_components/browser_mod/media_player.py b/custom_components/browser_mod/media_player.py index 52a816f..9966061 100644 --- a/custom_components/browser_mod/media_player.py +++ b/custom_components/browser_mod/media_player.py @@ -1,6 +1,7 @@ import logging from homeassistant.components.media_player import ( - SUPPORT_PLAY, SUPPORT_PLAY_MEDIA, SUPPORT_PAUSE, SUPPORT_STOP, + SUPPORT_PLAY, SUPPORT_PLAY_MEDIA, + SUPPORT_PAUSE, SUPPORT_STOP, SUPPORT_VOLUME_SET, SUPPORT_VOLUME_MUTE, MediaPlayerDevice, ) @@ -53,7 +54,11 @@ class BrowserModPlayer(MediaPlayerDevice, BrowserModEntity): return None @property def supported_features(self): - return 0 + return ( + SUPPORT_PLAY | SUPPORT_PLAY_MEDIA | + SUPPORT_PAUSE | SUPPORT_STOP | + SUPPORT_VOLUME_SET | SUPPORT_VOLUME_MUTE + ) @property def volume_level(self): return 0