From 9d2f4d4054d6f76fd22d2e1ff1ba713b06b50b74 Mon Sep 17 00:00:00 2001 From: Garulf <535299+Garulf@users.noreply.github.com> Date: Thu, 27 Oct 2022 18:37:50 -0400 Subject: [PATCH 1/4] Major version bump --- plugin.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugin.json b/plugin.json index d087839..f510e07 100644 --- a/plugin.json +++ b/plugin.json @@ -4,9 +4,9 @@ "Name": "HA-Commander", "Description": "Search, and interact with Home Assistant using Wox or Flow Launcher.", "Author": "Garulf", - "Version": "4.0.0", + "Version": "5.0.0", "Language": "python", "Website": "https://github.com/Garulf/HA-Commander", "IcoPath": "icons\\home-assistant.png", "ExecuteFileName": "main.py" -} \ No newline at end of file +} From 49fe4055b6290bf75abe020597ffe9259cfe456a Mon Sep 17 00:00:00 2001 From: Garulf <535299+Garulf@users.noreply.github.com> Date: Thu, 27 Oct 2022 18:41:42 -0400 Subject: [PATCH 2/4] Autopep8 formatting --- plugin/homeassistant.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/plugin/homeassistant.py b/plugin/homeassistant.py index 4bd1077..434d858 100644 --- a/plugin/homeassistant.py +++ b/plugin/homeassistant.py @@ -176,7 +176,8 @@ def __init__(self, client, entity): self.entity_id = entity.get("entity_id") self.domain = self.entity_id.split(".")[0] self.name = entity.get("name") - self.friendly_name = entity.get("attributes", "").get("friendly_name", "") + self.friendly_name = entity.get( + "attributes", "").get("friendly_name", "") self.state = entity.get("state") self.attributes = entity["attributes"] self.target = {"entity_id": self.entity_id} @@ -225,7 +226,8 @@ def turn_on(self, **service_data) -> any: for arg in service_data: service_data[arg] = service_data[arg] service_data["entity_id"] = self.entity_id - self._client.call_services("homeassistant", "turn_on", data=service_data) + self._client.call_services( + "homeassistant", "turn_on", data=service_data) @service(icon="switch_off", score=100) def turn_off(self, **service_data) -> None: @@ -233,7 +235,8 @@ def turn_off(self, **service_data) -> None: for arg in service_data: service_data[arg] = service_data[arg] service_data["entity_id"] = self.entity_id - self._client.call_services("homeassistant", "turn_off", data=service_data) + self._client.call_services( + "homeassistant", "turn_off", data=service_data) class Light(Entity): @@ -250,7 +253,8 @@ def __init__(self, client: Client, entity: dict) -> None: for effect in self.attributes.get("effect_list", []): setattr(self, f"{effect}", partial(self.turn_on, effect=effect)) getattr(self, f"{effect}").name = effect.title() - getattr(self, f"{effect}").__doc__ = f"Set light effect to {effect}." + getattr( + self, f"{effect}").__doc__ = f"Set light effect to {effect}." getattr(self, f"{effect}").icon = "star-circle-outline" getattr(self, f"{effect}").score = 0 # print(getattr(self, f"{color}").__icon__) @@ -336,12 +340,14 @@ def play(self) -> None: @service(icon="pause") def pause(self) -> None: """Pause currently playing media.""" - self._client.call_services("media_player", "media_pause", data=self.target) + self._client.call_services( + "media_player", "media_pause", data=self.target) @service(icon="play-pause") def play_pause(self) -> None: """Toggle Play/Pause.""" - self._client.call_services("media_player", "media_play_pause", data=self.target) + self._client.call_services( + "media_player", "media_play_pause", data=self.target) class Climate(Entity): @@ -362,7 +368,8 @@ def cycle_mode(self) -> None: mode_index = 0 service_data = self.target service_data["hvac_mode"] = self.hvac_modes[mode_index] - self._client.call_services("climate", "set_hvac_mode", data=service_data) + self._client.call_services( + "climate", "set_hvac_mode", data=service_data) class Script(Entity): @@ -413,7 +420,8 @@ def snapshot(self) -> None: @service(icon="television") def view(self) -> None: """View a still from this Camera entity.""" - webbrowser.open(f'{self._client._url}{self.attributes["entity_picture"]}') + webbrowser.open( + f'{self._client._url}{self.attributes["entity_picture"]}') class InputSelect(BaseEntity): From 9892651a1e62f374be3158f245676a87dac66288 Mon Sep 17 00:00:00 2001 From: Garulf <535299+Garulf@users.noreply.github.com> Date: Thu, 27 Oct 2022 18:41:58 -0400 Subject: [PATCH 3/4] Add Scene support --- plugin/homeassistant.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/plugin/homeassistant.py b/plugin/homeassistant.py index 434d858..7fbb361 100644 --- a/plugin/homeassistant.py +++ b/plugin/homeassistant.py @@ -475,3 +475,16 @@ def __init__(self, client: Client, entity: dict) -> None: getattr(self, entity).__doc__ = 'Toggle entity "{}"'.format(entity) getattr(self, entity).icon = "checkbox-multiple-blank" getattr(self, entity)._service = True + + +class Scene(Entity): + def __init__(self, client: Client, entity: dict) -> None: + super().__init__(client, entity) + + def _default_action(self): + self.activate() + + @service(icon="play") + def activate(self) -> None: + """Activate scene.""" + self._client.call_services("scene", "turn_on", data=self.target) From 49ad9a45ee157a86732413c18d3a7939e822ce2e Mon Sep 17 00:00:00 2001 From: Garulf <535299+Garulf@users.noreply.github.com> Date: Thu, 27 Oct 2022 18:42:23 -0400 Subject: [PATCH 4/4] Upgrade Flox --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index bb47aa4..9cd43bf 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ requests==2.25.1 -flox-lib==0.18.0 +flox-lib==0.18.1