hass-4button/http_api.py
Dessa Simpson 96a25cf79b Restructure and add HTTP API
- Move check_action and run_action into actions.py
- Add HTTP API
- Minor formatting changes
2022-05-28 06:17:41 +00:00

15 lines
478 B
Python

#!/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