Compare commits
1 Commits
master
...
f13d3d2d9b
Author | SHA1 | Date | |
---|---|---|---|
f13d3d2d9b |
@ -2,9 +2,9 @@
|
||||
|
||||
An [Albert](https://albertlauncher.github.io/) extention to view and control devices in your [HomeAssistant](https://www.home-assistant.io/) instance.
|
||||
|
||||
This extension is heavily inspired by the home assistant extension for ulauncher from [qcasey](https://github.com/qcasey/ulauncher-homeassistant).
|
||||
This extension is heavily inspired by the home assistant extesnsion for ulauncher from [qcasey](https://github.com/qcasey/ulauncher-homeassistant).
|
||||
|
||||

|
||||

|
||||
|
||||
## Requirements
|
||||
|
||||
@ -20,10 +20,10 @@ You need to specify the URL and [API Key](https://developers.home-assistant.io/d
|
||||
You can generate a new long lived API Key by clicking your name in the bottom left in the Home Assistant UI.
|
||||
|
||||
Example:
|
||||
```json
|
||||
```
|
||||
{
|
||||
"hass_url": "http://192.168.1.2:8123",
|
||||
"hass_key": "s1GeOobviEbZS3OjfkYVmOQDMbCRIH0kCtisGVi2EQoKbDeqq"
|
||||
"hass_key": "s1GeOobviEbg019H32dTs973GU2sJ3zBIMETxKSLCzoJulgljXB31m1aqq2GFWe2TsaLRxYo0J08FHxEdXxzSzNJMNZS3OjfkYVmOQDMbCRIH0kCtisGVi2EQoKbDeqq"
|
||||
}
|
||||
```
|
||||
|
||||
|
22
__init__.py
22
__init__.py
@ -34,7 +34,7 @@ icon_files = {
|
||||
"switch": "icons/switch.png",
|
||||
}
|
||||
|
||||
toggle_types = ["light", "switch", "automation", "group", "script", "input_boolean", "climate", "camera"]
|
||||
toggle_types = ["light", "switch", "automation", "group", "input_boolean", "climate", "camera"]
|
||||
on_off_types = ["scene", "media_player"] # use turn_{on,off} instead of toggle
|
||||
|
||||
|
||||
@ -124,12 +124,12 @@ def showEntities(query):
|
||||
|
||||
entity_query_list = query.string.split()
|
||||
|
||||
# Query entities from HASS
|
||||
|
||||
# query entities from HASS
|
||||
try:
|
||||
response = requests.get(config["state_query"], headers=config["headers"])
|
||||
response.raise_for_status()
|
||||
except requests.exceptions.RequestException as error:
|
||||
critical(str(error))
|
||||
return Item(id=__title__,
|
||||
icon=os.path.dirname(__file__) + "/" + icon_files["logo"],
|
||||
text="Error while getting entity states from Home Assistant",
|
||||
@ -193,12 +193,7 @@ def showEntities(query):
|
||||
entity["state"].capitalize()
|
||||
)
|
||||
|
||||
if state == "unavailable" and "unavailable" not in entity:
|
||||
entity["unavailable"] = True
|
||||
entities.append(entity)
|
||||
continue
|
||||
|
||||
# Build item for list
|
||||
# build item for list
|
||||
item = Item(id=__title__,
|
||||
icon=entity_icon,
|
||||
text=entity["attributes"]["friendly_name"],
|
||||
@ -206,7 +201,7 @@ def showEntities(query):
|
||||
subtext="%s | %s" % (state_colored, entity_class.capitalize())
|
||||
)
|
||||
|
||||
# Add actions depending on class
|
||||
# add actions depending on class
|
||||
if entity_class in toggle_types:
|
||||
item.addAction(FuncAction("Toggle", lambda d=data: sendCommand(d, "homeassistant/toggle")))
|
||||
|
||||
@ -216,16 +211,13 @@ def showEntities(query):
|
||||
|
||||
if entity_class == "cover":
|
||||
open_or_close = "open" if state != "open" else "close"
|
||||
item.addAction(FuncAction("%s Cover" % (open_or_close.capitalize()), lambda d=data: sendCommand(d, "cover/%s_cover") % (open_or_close)))
|
||||
|
||||
if entity_class == "automation":
|
||||
item.addAction(FuncAction("Trigger", lambda d=data: sendCommand(d, "automation/trigger")))
|
||||
item.addAction(FuncAction("%s Cover" % (open_or_close.capitalize()), lambda d=data: sendCommand(d, "homeassistant/cover/%s_cover") % (open_or_close)))
|
||||
|
||||
item.addAction(ClipAction("Copy ID", entity["entity_id"]))
|
||||
|
||||
results.append(item)
|
||||
|
||||
# No entity found
|
||||
# no entity found
|
||||
if len(results) == 0:
|
||||
results.append(
|
||||
Item(id=__title__,
|
||||
|
BIN
ha_demo.mp4
BIN
ha_demo.mp4
Binary file not shown.
Reference in New Issue
Block a user