Skip to content

Set the Cover to a specific percentage #69

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"Name": "HA-Commander",
"Description": "Search, and interact with Home Assistant using Wox or Flow Launcher.",
"Author": "Garulf",
"Version": "5.2.1",
"Version": "5.3.0",
"Language": "python",
"Website": "https://github.com/Garulf/HA-Commander",
"IcoPath": "icons\\home-assistant.png",
Expand Down
14 changes: 14 additions & 0 deletions plugin/homeassistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,3 +503,17 @@ def _default_action(self):
def press(self) -> None:
"""Press button"""
self._client.call_services("button", "press", data=self.target)

class Cover(Entity):
"""Representation of a Cover entity."""
def __init__(self, client: Client, entity: dict) -> None:
super().__init__(client, entity)
self.current_position = self._entity["attributes"].get("current_position", 'None')
self.current = entity.get("attributes", "").get("current_position", "");

def _current_position(self, current_position: int) -> None:
"""Set Current Postion of the Cover."""
#self.turn_on(**{"current_position": current_position})
data = self.target
data["position"] = current_position
self._client.call_services("cover", "set_cover_position", data=data)
9 changes: 9 additions & 0 deletions plugin/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ def query(self, query):
entity.entity_id, "light"
):
subtitle = f"{subtitle} - Press ENTER to change brightness to: {q.split('_')[-1]}%"
if q.split("_")[-1].isdigit() and self.client.domain(
entity.entity_id, "cover"
):
subtitle = f"{subtitle} - Press ENTER to open Cover to: {q.split('_')[-1]}%"
self.add_item(
title=f"{entity.friendly_name or entity.entity_id}",
subtitle=subtitle.replace("_", " ").title(),
Expand Down Expand Up @@ -165,6 +169,11 @@ def action(self, entity_id, query="", service="_default_action"):
and query.split("_")[-1].isdigit()
):
entity._brightness_pct(int(query.split("_")[-1]))
elif (
self.client.domain(entity.entity_id, "cover")
and query.split("_")[-1].isdigit()
):
entity._current_position(int(query.split("_")[-1]))
else:
getattr(entity, service)()
except (HTTPError, ReadTimeout, ConnectionError):
Expand Down
Loading