Re-use connection-pool (#19249)

Re-use connection-pool of VOC
This commit is contained in:
Erik Eriksson 2018-12-13 12:25:40 +01:00 committed by Fabian Affolter
parent 9d9e11372b
commit 6766d25e62
2 changed files with 10 additions and 6 deletions

View file

@ -15,6 +15,7 @@ from homeassistant.helpers import discovery
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import Entity from homeassistant.helpers.entity import Entity
from homeassistant.helpers.event import async_track_point_in_utc_time from homeassistant.helpers.event import async_track_point_in_utc_time
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from homeassistant.helpers.dispatcher import ( from homeassistant.helpers.dispatcher import (
async_dispatcher_send, async_dispatcher_send,
async_dispatcher_connect) async_dispatcher_connect)
@ -24,7 +25,7 @@ DOMAIN = 'volvooncall'
DATA_KEY = DOMAIN DATA_KEY = DOMAIN
REQUIREMENTS = ['volvooncall==0.7.11'] REQUIREMENTS = ['volvooncall==0.8.2']
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -106,12 +107,15 @@ CONFIG_SCHEMA = vol.Schema({
async def async_setup(hass, config): async def async_setup(hass, config):
"""Set up the Volvo On Call component.""" """Set up the Volvo On Call component."""
session = async_get_clientsession(hass)
from volvooncall import Connection from volvooncall import Connection
connection = Connection( connection = Connection(
config[DOMAIN].get(CONF_USERNAME), session=session,
config[DOMAIN].get(CONF_PASSWORD), username=config[DOMAIN].get(CONF_USERNAME),
config[DOMAIN].get(CONF_SERVICE_URL), password=config[DOMAIN].get(CONF_PASSWORD),
config[DOMAIN].get(CONF_REGION)) service_url=config[DOMAIN].get(CONF_SERVICE_URL),
region=config[DOMAIN].get(CONF_REGION))
interval = config[DOMAIN].get(CONF_UPDATE_INTERVAL) interval = config[DOMAIN].get(CONF_UPDATE_INTERVAL)

View file

@ -1591,7 +1591,7 @@ venstarcolortouch==0.6
volkszaehler==0.1.2 volkszaehler==0.1.2
# homeassistant.components.volvooncall # homeassistant.components.volvooncall
volvooncall==0.7.11 volvooncall==0.8.2
# homeassistant.components.verisure # homeassistant.components.verisure
vsure==1.5.2 vsure==1.5.2