Restructure and add HTTP API
- Move check_action and run_action into actions.py - Add HTTP API - Minor formatting changes
This commit is contained in:
parent
e58b1b21ed
commit
96a25cf79b
3 changed files with 75 additions and 58 deletions
15
http_api.py
Normal file
15
http_api.py
Normal file
|
@ -0,0 +1,15 @@
|
|||
#!/usr/bin/python3
|
||||
import hassapi as hass
|
||||
from actions import run_action
|
||||
|
||||
class HttpApi(hass.Hass):
|
||||
def initialize(self):
|
||||
self.register_endpoint(self.api_request, '4button')
|
||||
|
||||
def api_request(self, data, kwargs):
|
||||
if 'sequence' not in data: return 'Missing sequence', 400
|
||||
# Let AppDaemon handle API response on error
|
||||
if (run_action(self,data['sequence'])):
|
||||
return 'Success', 200
|
||||
else:
|
||||
return 'No match', 400
|
Loading…
Add table
Add a link
Reference in a new issue