From 5fd0a1b98cc386faa577561ab85285b519399352 Mon Sep 17 00:00:00 2001 From: e2002 Date: Thu, 17 Mar 2022 20:02:52 +0300 Subject: [PATCH] home assistant v0.5.010 --- HA/custom_components/yoradio/manifest.json | 2 +- HA/custom_components/yoradio/media_player.py | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/HA/custom_components/yoradio/manifest.json b/HA/custom_components/yoradio/manifest.json index 1e0729f..1f4197f 100644 --- a/HA/custom_components/yoradio/manifest.json +++ b/HA/custom_components/yoradio/manifest.json @@ -5,5 +5,5 @@ "dependencies": ["http", "mqtt"], "codeowners": ["@e2002"], "requirements": [], - "version": "0.4.323" + "version": "0.5.010" } diff --git a/HA/custom_components/yoradio/media_player.py b/HA/custom_components/yoradio/media_player.py index 1a6268a..4d7b78e 100644 --- a/HA/custom_components/yoradio/media_player.py +++ b/HA/custom_components/yoradio/media_player.py @@ -8,7 +8,7 @@ from homeassistant.helpers.aiohttp_client import async_get_clientsession _LOGGER = logging.getLogger(__name__) -VERSION = '0.4.323' +VERSION = '0.5.010' DOMAIN = "yoradio" @@ -67,16 +67,25 @@ class yoradioApi(): self.root_topic = root_topic async def set_command(self, command): - self.mqtt.async_publish(self.root_topic + '/command', command) + try: + self.mqtt.async_publish(self.root_topic + '/command', command) + except: + await self.mqtt.async_publish(self.hass, self.root_topic + '/command', command) async def set_volume(self, volume): command = "vol " + str(volume) - self.mqtt.async_publish(self.root_topic + '/command', command) + try: + self.mqtt.async_publish(self.root_topic + '/command', command) + except: + await self.mqtt.async_publish(self.hass, self.root_topic + '/command', command) async def set_source(self, source): number = source.split('.') command = "play " + number[0] - self.mqtt.async_publish(self.root_topic + '/command', command) + try: + self.mqtt.async_publish(self.root_topic + '/command', command) + except: + await self.mqtt.async_publish(self.hass, self.root_topic + '/command', command) async def load_playlist(self, msg): try: