Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improvements to the EventGhost configuration
Use a bearer token for communications between EventGhost and Home Assistant. Listen for more consistent events when deciding computer activity. Closes #54 and #55
- Loading branch information
1 parent
bcd71e9
commit efd4382
Showing
7 changed files
with
17 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,3 +14,4 @@ | |
/downloads/ | ||
/.google.token | ||
/.storage/ | ||
/bearer-token |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 9 additions & 9 deletions
18
home-assistant/other_configuration/event_ghost_gaming_pc/home-assistant.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,35 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<EventGhost Version="1722" Guid="{13730AC3-1E50-4877-BE08-567B3E8B9E2F}" Time="1541185107.43"> | ||
<EventGhost Version="1722" Guid="{3FE0B20B-05B2-43B0-A7A1-DEF50B73B252}" Time="1544467184.08"> | ||
<Autostart Name="Autostart"> | ||
<Plugin Identifier="Task" Guid="{D1748551-C605-4423-B392-FB77E6842437}" File="Task"> | ||
gAIpLg== | ||
</Plugin> | ||
<Action> | ||
EventGhost.PythonScript(u'homeAssistantURL = "{homeAssistantURL}"\nhomeAssistantPassword = "{homeAssistantPassword}"\n\nsetattr(eg.globals, "homeAssistantURL", homeAssistantURL)\nsetattr(eg.globals, "homeAssistantPassword", homeAssistantPassword)') | ||
<Action Name="Set globals"> | ||
EventGhost.PythonScript(u'homeAssistantURL = "{homeAssistantURL}"\nhomeAssistantBearerToken = "{homeAssistantBearerToken}"\n\nsetattr(eg.globals, "homeAssistantURL", homeAssistantURL)\nsetattr(eg.globals, "homeAssistantBearerToken", homeAssistantBearerToken)') | ||
</Action> | ||
</Autostart> | ||
<Macro Name="Start Overwatch"> | ||
<Event Name="Task.Activated.Overwatch" /> | ||
<Action Name="Update HA"> | ||
EventGhost.PythonScript(u'import requests\n\nhomeAssistantURL = getattr(eg.globals, "homeAssistantURL")\nhomeAssistantPassword = getattr(eg.globals, "homeAssistantPassword")\n\nurl = homeAssistantURL + "/api/states/computer_activity.gaming_pc?api_password=" + homeAssistantPassword\nheaders = {\'content-type\': \'application/json\'}\ndata = \'{"state": true, "attributes": {"hidden": true, "focus": "overwatch"}}\'\nresponse = requests.post(url, data, headers=headers, verify=False)\nprint(response.text)') | ||
EventGhost.PythonScript(u'import requests\n\nhomeAssistantURL = getattr(eg.globals, "homeAssistantURL")\nhomeAssistantBearerToken = getattr(eg.globals, "homeAssistantBearerToken")\n\nurl = homeAssistantURL + "/api/states/computer_activity.gaming_pc"\nheaders = {}\nheaders["Content-Type"] = "application/json"\nheaders["Authorization"] = "Bearer " + homeAssistantBearerToken\ndata = \'{"state": true, "attributes": {"hidden": true, "focus": "overwatch"}}\'\nresponse = requests.post(url, data, headers=headers, verify=False)\nprint(response.text)') | ||
</Action> | ||
</Macro> | ||
<Macro Name="Stop Overwatch"> | ||
<Event Name="Task.Deactivated.Overwatch" /> | ||
<Action Name="Update HA"> | ||
EventGhost.PythonScript(u'import requests\n\nhomeAssistantURL = getattr(eg.globals, "homeAssistantURL")\nhomeAssistantPassword = getattr(eg.globals, "homeAssistantPassword")\n\nurl = homeAssistantURL + "/api/states/computer_activity.gaming_pc?api_password=" + homeAssistantPassword\nheaders = {\'content-type\': \'application/json\'}\ndata = \'{"state": true, "attributes": {"hidden": true, "focus": ""}}\'\nresponse = requests.post(url, data, headers=headers, verify=False)\nprint(response.text)') | ||
EventGhost.PythonScript(u'import requests\n\nhomeAssistantURL = getattr(eg.globals, "homeAssistantURL")\nhomeAssistantBearerToken = getattr(eg.globals, "homeAssistantBearerToken")\n\nurl = homeAssistantURL + "/api/states/computer_activity.gaming_pc"\nheaders = {}\nheaders["Content-Type"] = "application/json"\nheaders["Authorization"] = "Bearer " + homeAssistantBearerToken\ndata = \'{"state": true, "attributes": {"hidden": true, "focus": ""}}\'\nresponse = requests.post(url, data, headers=headers, verify=False)\nprint(response.text)') | ||
</Action> | ||
</Macro> | ||
<Macro Name="Lock/Idle Windows"> | ||
<Event Name="Task.Activated.LockApp" /> | ||
<Event Name="System.SessionLock" /> | ||
<Action Name="Update HA"> | ||
EventGhost.PythonScript(u'import requests\n\nhomeAssistantURL = getattr(eg.globals, "homeAssistantURL")\nhomeAssistantPassword = getattr(eg.globals, "homeAssistantPassword")\n\nurl = homeAssistantURL + "/api/states/computer_activity.gaming_pc?api_password=" + homeAssistantPassword\nheaders = {\'content-type\': \'application/json\'}\ndata = \'{"state": false, "attributes": {"hidden": true, "focus": ""}}\'\nresponse = requests.post(url, data, headers=headers, verify=False)\nprint(response.text)') | ||
EventGhost.PythonScript(u'import requests\n\nhomeAssistantURL = getattr(eg.globals, "homeAssistantURL")\nhomeAssistantBearerToken = getattr(eg.globals, "homeAssistantBearerToken")\n\nurl = homeAssistantURL + "/api/states/computer_activity.gaming_pc"\nheaders = {}\nheaders["Content-Type"] = "application/json"\nheaders["Authorization"] = "Bearer " + homeAssistantBearerToken\n\ndata = \'{"state": false, "attributes": {"hidden": true, "focus": ""}}\'\nresponse = requests.post(url, data, headers=headers, verify=False)\nprint(response.text)') | ||
</Action> | ||
</Macro> | ||
<Macro Name="Unlock/Unldle Windows"> | ||
<Event Name="Task.Deactivated.LockApp" /> | ||
<Event Name="System.SessionUnlock" /> | ||
<Action Name="Update HA"> | ||
EventGhost.PythonScript(u'import requests\n\nhomeAssistantURL = getattr(eg.globals, "homeAssistantURL")\nhomeAssistantPassword = getattr(eg.globals, "homeAssistantPassword")\n\nurl = homeAssistantURL + "/api/states/computer_activity.gaming_pc?api_password=" + homeAssistantPassword\nheaders = {\'content-type\': \'application/json\'}\ndata = \'{"state": true, "attributes": {"hidden": true, "focus": ""}}\'\nresponse = requests.post(url, data, headers=headers, verify=False)\nprint(response.text)') | ||
EventGhost.PythonScript(u'import requests\n\nhomeAssistantURL = getattr(eg.globals, "homeAssistantURL")\nhomeAssistantBearerToken = getattr(eg.globals, "homeAssistantBearerToken")\n\nurl = homeAssistantURL + "/api/states/computer_activity.gaming_pc"\nheaders = {}\nheaders["Content-Type"] = "application/json"\nheaders["Authorization"] = "Bearer " + homeAssistantBearerToken\ndata = \'{"state": true, "attributes": {"hidden": true, "focus": ""}}\'\nresponse = requests.post(url, data, headers=headers, verify=False)\nprint(response.text)') | ||
</Action> | ||
</Macro> | ||
</EventGhost> |