From 991cc5551ac1dd0166a7840c5ffbeba24e79b95c Mon Sep 17 00:00:00 2001 From: Garulf <535299+Garulf@users.noreply.github.com> Date: Sat, 5 Feb 2022 11:40:52 -0500 Subject: [PATCH 1/5] Add logger --- plugin/homeassistant.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugin/homeassistant.py b/plugin/homeassistant.py index 0044358..9127c16 100644 --- a/plugin/homeassistant.py +++ b/plugin/homeassistant.py @@ -2,12 +2,15 @@ import json from functools import partial, wraps import webbrowser +import logging import requests from requests.exceptions import ConnectionError, HTTPError from icons import DEFAULT_ICONS +log = logging.getLogger(__name__) + COLORS_FILE = "./plugin/colors.json" META_FILE = "./meta.json" From 872824dad7dfbf4bfe385c24d4d99781f3a5cf61 Mon Sep 17 00:00:00 2001 From: Garulf <535299+Garulf@users.noreply.github.com> Date: Sat, 5 Feb 2022 11:41:17 -0500 Subject: [PATCH 2/5] Source selection method --- plugin/homeassistant.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/plugin/homeassistant.py b/plugin/homeassistant.py index 9127c16..8ee79a5 100644 --- a/plugin/homeassistant.py +++ b/plugin/homeassistant.py @@ -311,6 +311,12 @@ class MediaPlayer(Entity): def __init__(self, client: Client, entity: dict) -> None: super().__init__(client, entity) + @service(icon="arrow-right") + def _select_source(self, source) -> None: + """Select source.""" + data = self.target + data["source"] = source + self._client.call_services("media_player", "select_source", data=data) @service(icon="play") def play(self) -> None: From 72dba2c43f4a94b89b2eac5d2a02eecb386098f3 Mon Sep 17 00:00:00 2001 From: Garulf <535299+Garulf@users.noreply.github.com> Date: Sat, 5 Feb 2022 11:41:29 -0500 Subject: [PATCH 3/5] Add source list to context --- plugin/homeassistant.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/plugin/homeassistant.py b/plugin/homeassistant.py index 8ee79a5..3b8284f 100644 --- a/plugin/homeassistant.py +++ b/plugin/homeassistant.py @@ -311,6 +311,15 @@ class MediaPlayer(Entity): def __init__(self, client: Client, entity: dict) -> None: super().__init__(client, entity) + for source in self.attributes.get("source_list", []): + setattr(self, source, partial(self._select_source, source)) + getattr(self, source).name = source + getattr(self, source).__doc__ = 'Set Source to "{}"'.format(source) + getattr(self, source).icon = "radiobox-blank" + if source == self.attributes.get("source"): + getattr(self, source).icon = "radiobox-marked" + getattr(self, source).__doc__ = "Currently selected Source." + @service(icon="arrow-right") def _select_source(self, source) -> None: """Select source.""" From 8fb0560ac0f59e66b3d2ab0d8bff06d978b5a042 Mon Sep 17 00:00:00 2001 From: Garulf <535299+Garulf@users.noreply.github.com> Date: Sat, 5 Feb 2022 13:52:32 -0500 Subject: [PATCH 4/5] Bump version --- plugin.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.json b/plugin.json index 1edc253..312214c 100644 --- a/plugin.json +++ b/plugin.json @@ -4,7 +4,7 @@ "Name": "HA-Commander", "Description": "Search, and interact with Home Assistant using Wox or Flow Launcher.", "Author": "Garulf", - "Version": "3.0.4", + "Version": "3.1.0", "Language": "python", "Website": "https://github.com/Garulf/HA-Commander", "IcoPath": "icons\\home-assistant.png", From d02723b7cb8761d160698dc26b20846dd67c9c89 Mon Sep 17 00:00:00 2001 From: Garulf <535299+Garulf@users.noreply.github.com> Date: Sat, 5 Feb 2022 13:53:44 -0500 Subject: [PATCH 5/5] Upgrade Flox --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 4c766a3..c0eef52 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ requests==2.25.1 -git+https://github.com/garulf/flox@v0.9.5#egg=flox +git+https://github.com/garulf/flox@v0.10.4#egg=flox-lib