parent
ea7b1e4573
commit
9aaf11de8c
54 changed files with 223 additions and 382 deletions
|
@ -1,5 +1,4 @@
|
|||
"""Provides a Hue API to control Home Assistant."""
|
||||
import asyncio
|
||||
import logging
|
||||
|
||||
from aiohttp import web
|
||||
|
@ -36,11 +35,10 @@ class HueUsernameView(HomeAssistantView):
|
|||
extra_urls = ['/api/']
|
||||
requires_auth = False
|
||||
|
||||
@asyncio.coroutine
|
||||
def post(self, request):
|
||||
async def post(self, request):
|
||||
"""Handle a POST request."""
|
||||
try:
|
||||
data = yield from request.json()
|
||||
data = await request.json()
|
||||
except ValueError:
|
||||
return self.json_message('Invalid JSON', HTTP_BAD_REQUEST)
|
||||
|
||||
|
@ -146,8 +144,7 @@ class HueOneLightChangeView(HomeAssistantView):
|
|||
"""Initialize the instance of the view."""
|
||||
self.config = config
|
||||
|
||||
@asyncio.coroutine
|
||||
def put(self, request, username, entity_number):
|
||||
async def put(self, request, username, entity_number):
|
||||
"""Process a request to set the state of an individual light."""
|
||||
config = self.config
|
||||
hass = request.app['hass']
|
||||
|
@ -168,7 +165,7 @@ class HueOneLightChangeView(HomeAssistantView):
|
|||
return web.Response(text="Entity not exposed", status=404)
|
||||
|
||||
try:
|
||||
request_json = yield from request.json()
|
||||
request_json = await request.json()
|
||||
except ValueError:
|
||||
_LOGGER.error('Received invalid json')
|
||||
return self.json_message('Invalid JSON', HTTP_BAD_REQUEST)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue