Skip to content

Commit

Permalink
More iOS HTTP Async updates
Browse files Browse the repository at this point in the history
  • Loading branch information
robbiet480 committed Oct 25, 2016
1 parent 7158919 commit f25ddef
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion homeassistant/components/ios.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/ios/
"""
import asyncio
import os
import json
import logging
Expand All @@ -15,6 +16,8 @@

from homeassistant.helpers import discovery

from homeassistant.core import callback

from homeassistant.components.http import HomeAssistantView

from homeassistant.const import (HTTP_INTERNAL_SERVER_ERROR,
Expand Down Expand Up @@ -268,6 +271,7 @@ def __init__(self, hass, push_config):
super().__init__(hass)
self.push_config = push_config

@callback
def get(self, request):
"""Handle the GET request for the push configuration."""
return self.json(self.push_config)
Expand All @@ -283,10 +287,16 @@ def __init__(self, hass):
"""Init the view."""
super().__init__(hass)

@asyncio.coroutine
def post(self, request):
"""Handle the POST request for device identification."""
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:
return self.json_message(humanize_error(request.json, ex),
HTTP_BAD_REQUEST)
Expand Down

0 comments on commit f25ddef

Please sign in to comment.