Compare commits
5 Commits
9cf9bc11d3
...
master
Author | SHA1 | Date | |
---|---|---|---|
1114014bc9 | |||
31dfa017cf | |||
7a2f84dc25 | |||
e4439cb176 | |||
e8d6057264 |
@ -4,7 +4,7 @@ An [Albert](https://albertlauncher.github.io/) extention to view and control dev
|
||||
|
||||
This extension is heavily inspired by the home assistant extension for ulauncher from [qcasey](https://github.com/qcasey/ulauncher-homeassistant).
|
||||
|
||||

|
||||

|
||||
|
||||
## Requirements
|
||||
|
||||
|
17
__init__.py
17
__init__.py
@ -34,7 +34,7 @@ icon_files = {
|
||||
"switch": "icons/switch.png",
|
||||
}
|
||||
|
||||
toggle_types = ["light", "switch", "automation", "group", "input_boolean", "climate", "camera"]
|
||||
toggle_types = ["light", "switch", "automation", "group", "script", "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,7 +193,12 @@ def showEntities(query):
|
||||
entity["state"].capitalize()
|
||||
)
|
||||
|
||||
# build item for list
|
||||
if state == "unavailable" and "unavailable" not in entity:
|
||||
entity["unavailable"] = True
|
||||
entities.append(entity)
|
||||
continue
|
||||
|
||||
# Build item for list
|
||||
item = Item(id=__title__,
|
||||
icon=entity_icon,
|
||||
text=entity["attributes"]["friendly_name"],
|
||||
@ -201,7 +206,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")))
|
||||
|
||||
@ -220,7 +225,7 @@ def showEntities(query):
|
||||
|
||||
results.append(item)
|
||||
|
||||
# no entity found
|
||||
# No entity found
|
||||
if len(results) == 0:
|
||||
results.append(
|
||||
Item(id=__title__,
|
||||
|
BIN
ha_demo.mp4
Normal file
BIN
ha_demo.mp4
Normal file
Binary file not shown.
Reference in New Issue
Block a user