From 350a18bf814b2bb79af215feb8d73d625f6f124f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Lov=C3=A9n?= Date: Sat, 2 May 2020 21:03:23 +0200 Subject: [PATCH] Improved async. Fix #97. --- custom_components/browser_mod/__init__.py | 2 +- custom_components/browser_mod/light.py | 4 ++-- custom_components/browser_mod/media_player.py | 4 ++-- custom_components/browser_mod/service.py | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/custom_components/browser_mod/__init__.py b/custom_components/browser_mod/__init__.py index b15ed59..bf7a526 100644 --- a/custom_components/browser_mod/__init__.py +++ b/custom_components/browser_mod/__init__.py @@ -33,7 +33,7 @@ async def async_setup(hass, config): await setup_connection(hass, config) - setup_service(hass) + await setup_service(hass) return True diff --git a/custom_components/browser_mod/light.py b/custom_components/browser_mod/light.py index bae91dc..77fd342 100644 --- a/custom_components/browser_mod/light.py +++ b/custom_components/browser_mod/light.py @@ -2,7 +2,7 @@ import logging from datetime import datetime from homeassistant.const import STATE_UNAVAILABLE, STATE_ON, STATE_OFF -from homeassistant.components.light import Light, SUPPORT_BRIGHTNESS +from homeassistant.components.light import LightEntity, SUPPORT_BRIGHTNESS from .helpers import setup_platform, BrowserModEntity @@ -11,7 +11,7 @@ PLATFORM = 'light' async def async_setup_platform(hass, config, async_add_devices, discovery_info=None): return setup_platform(hass, config, async_add_devices, PLATFORM, BrowserModLight) -class BrowserModLight(Light, BrowserModEntity): +class BrowserModLight(LightEntity, BrowserModEntity): domain = PLATFORM def __init__(self, hass, connection, deviceID, alias=None): diff --git a/custom_components/browser_mod/media_player.py b/custom_components/browser_mod/media_player.py index 538d7f5..b9b8d6c 100644 --- a/custom_components/browser_mod/media_player.py +++ b/custom_components/browser_mod/media_player.py @@ -3,7 +3,7 @@ from homeassistant.components.media_player import ( SUPPORT_PLAY, SUPPORT_PLAY_MEDIA, SUPPORT_PAUSE, SUPPORT_STOP, SUPPORT_VOLUME_SET, SUPPORT_VOLUME_MUTE, - MediaPlayerDevice, + MediaPlayerEntity, ) from homeassistant.const import ( STATE_UNAVAILABLE, @@ -23,7 +23,7 @@ async def async_setup_platform(hass, config, async_add_devices, discovery_info=N return setup_platform(hass, config, async_add_devices, PLATFORM, BrowserModPlayer) -class BrowserModPlayer(MediaPlayerDevice, BrowserModEntity): +class BrowserModPlayer(MediaPlayerEntity, BrowserModEntity): domain = PLATFORM def __init__(self, hass, connection, deviceID, alias=None): diff --git a/custom_components/browser_mod/service.py b/custom_components/browser_mod/service.py index 438900e..9ed092e 100644 --- a/custom_components/browser_mod/service.py +++ b/custom_components/browser_mod/service.py @@ -3,7 +3,7 @@ from .const import DOMAIN, DATA_DEVICES, DATA_ALIASES, USER_COMMANDS _LOGGER = logging.getLogger(__name__) -def setup_service(hass): +async def setup_service(hass): def handle_command(call): command = call.data.get("command", None)