cleanup a bit

This commit is contained in:
Aaron Bieber 2025-01-15 07:07:25 -07:00
parent d5bb98e5c0
commit 46146d547e
No known key found for this signature in database

20
krha.py
View File

@ -27,18 +27,18 @@ class Runner(dbus.service.Object):
command = query[3:] command = query[3:]
if not command: if not command:
return [("ha", "Home Assistant Commands", "home", 100, 1.0, return [("ha", "Home Assistant Commands", "home", 100, 1.0,
{'subtext': 'Type a command after "ha" to control Home Assistant'})] {'subtext': 'Type a command after "ha" to control Home Assistant'})]
return [( return [(
command, # data command,
f"Send to Home Assistant: {command}", # text f"Send to Home Assistant: {command}",
"home", # icon "home",
100, # type 100,
1.0, # relevance 1.0,
{'subtext': 'Press Enter to send command'} # properties {'subtext': 'Press Enter to send command'}
)] )]
@dbus.service.method(iface, out_signature='a(sss)') @dbus.service.method(iface, out_signature='a(sss)')
def Actions(self): def Actions(self):
return [("send", "Send to Home Assistant", "home")] return [("send", "Send to Home Assistant", "home")]
@ -49,12 +49,12 @@ class Runner(dbus.service.Object):
if not self.api_key or not self.ha_url: if not self.api_key or not self.ha_url:
print("Error: HA_API_KEY or HA_URL not configured") print("Error: HA_API_KEY or HA_URL not configured")
return return
headers = { headers = {
"Authorization": f"Bearer {self.api_key}", "Authorization": f"Bearer {self.api_key}",
"Content-Type": "application/json" "Content-Type": "application/json"
} }
try: try:
response = requests.post( response = requests.post(
f"{self.ha_url}/api/conversation/process", f"{self.ha_url}/api/conversation/process",