More iOS HTTP Async updates
This commit is contained in:
parent
7158919346
commit
f25ddef4d7
1 changed files with 11 additions and 1 deletions
|
@ -4,6 +4,7 @@ Native Home Assistant iOS app component.
|
||||||
For more details about this platform, please refer to the documentation at
|
For more details about this platform, please refer to the documentation at
|
||||||
https://home-assistant.io/components/ios/
|
https://home-assistant.io/components/ios/
|
||||||
"""
|
"""
|
||||||
|
import asyncio
|
||||||
import os
|
import os
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
|
@ -15,6 +16,8 @@ from homeassistant.helpers import config_validation as cv
|
||||||
|
|
||||||
from homeassistant.helpers import discovery
|
from homeassistant.helpers import discovery
|
||||||
|
|
||||||
|
from homeassistant.core import callback
|
||||||
|
|
||||||
from homeassistant.components.http import HomeAssistantView
|
from homeassistant.components.http import HomeAssistantView
|
||||||
|
|
||||||
from homeassistant.const import (HTTP_INTERNAL_SERVER_ERROR,
|
from homeassistant.const import (HTTP_INTERNAL_SERVER_ERROR,
|
||||||
|
@ -268,6 +271,7 @@ class iOSPushConfigView(HomeAssistantView):
|
||||||
super().__init__(hass)
|
super().__init__(hass)
|
||||||
self.push_config = push_config
|
self.push_config = push_config
|
||||||
|
|
||||||
|
@callback
|
||||||
def get(self, request):
|
def get(self, request):
|
||||||
"""Handle the GET request for the push configuration."""
|
"""Handle the GET request for the push configuration."""
|
||||||
return self.json(self.push_config)
|
return self.json(self.push_config)
|
||||||
|
@ -283,10 +287,16 @@ class iOSIdentifyDeviceView(HomeAssistantView):
|
||||||
"""Init the view."""
|
"""Init the view."""
|
||||||
super().__init__(hass)
|
super().__init__(hass)
|
||||||
|
|
||||||
|
@asyncio.coroutine
|
||||||
def post(self, request):
|
def post(self, request):
|
||||||
"""Handle the POST request for device identification."""
|
"""Handle the POST request for device identification."""
|
||||||
try:
|
try:
|
||||||
data = IDENTIFY_SCHEMA(request.json)
|
req_data = yield from request.json()
|
||||||
|
except ValueError:
|
||||||
|
return self.json_message('Invalid JSON', HTTP_BAD_REQUEST)
|
||||||
|
|
||||||
|
try:
|
||||||
|
data = IDENTIFY_SCHEMA(req_data)
|
||||||
except vol.Invalid as ex:
|
except vol.Invalid as ex:
|
||||||
return self.json_message(humanize_error(request.json, ex),
|
return self.json_message(humanize_error(request.json, ex),
|
||||||
HTTP_BAD_REQUEST)
|
HTTP_BAD_REQUEST)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue