async HTTP component (#3914)

* Migrate WSGI to asyncio

* Rename wsgi -> http

* Python 3.4 compat

* Move linting to Python 3.4

* lint

* Lint

* Fix Python 3.4 mock_open + binary data

* Surpress logging aiohttp.access

* Spelling

* Sending files is a coroutine

* More callback annotations and naming fixes

* Fix ios
This commit is contained in:
Paulus Schoutsen authored and GitHub committed 2016-10-23 23:48:01 -07:00
1 parent 9aa88819a5
commit 519d9f2fd0
45 files changed
+1422 -1009

No files matched your search

+6 -4
View File
@@ -10,6 +10,7 @@ from datetime import timedelta
import voluptuous as vol
from homeassistant.core import callback
from homeassistant import util
from homeassistant.components.http import HomeAssistantView
from homeassistant.const import (
@@ -40,7 +41,7 @@ MIN_TIME_BETWEEN_SCANS = timedelta(seconds=10)
REQ_CONF = [CONF_HOST, CONF_OUTLETS]
URL_API_NETIO_EP = '/api/netio/<host>'
URL_API_NETIO_EP = '/api/netio/{host}'
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Required(CONF_HOST): cv.string,
@@ -61,7 +62,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
port = config.get(CONF_PORT)
if len(DEVICES) == 0:
hass.wsgi.register_view(NetioApiView)
hass.http.register_view(NetioApiView)
dev = Netio(host, port, username, password)
@@ -93,9 +94,10 @@ class NetioApiView(HomeAssistantView):
url = URL_API_NETIO_EP
name = 'api:netio'
@callback
def get(self, request, host):
"""Request handler."""
data = request.args
data = request.GET
states, consumptions, cumulated_consumptions, start_dates = \
[], [], [], []
@@ -117,7 +119,7 @@ class NetioApiView(HomeAssistantView):
ndev.start_dates = start_dates
for dev in DEVICES[host].entities:
dev.update_ha_state()
self.hass.loop.create_task(dev.async_update_ha_state())
return self.json(True)