From 993a02b8c4f131003dbf7bd335ee3bb8b538cd80 Mon Sep 17 00:00:00 2001 From: Alexander Lyon Date: Mon, 15 Oct 2018 23:18:59 +0100 Subject: [PATCH] Fix the sabnzbd component api error (#17014) * Bump pysabnzbd version number * Pass hass aiohttp session to pysabnzbd --- homeassistant/components/sabnzbd.py | 9 ++++++--- requirements_all.txt | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/sabnzbd.py b/homeassistant/components/sabnzbd.py index 380867a3285..25fce22c641 100644 --- a/homeassistant/components/sabnzbd.py +++ b/homeassistant/components/sabnzbd.py @@ -15,11 +15,12 @@ from homeassistant.const import ( CONF_HOST, CONF_API_KEY, CONF_NAME, CONF_PORT, CONF_SENSORS, CONF_SSL) from homeassistant.core import callback from homeassistant.helpers import discovery +from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.dispatcher import async_dispatcher_send from homeassistant.helpers.event import async_track_time_interval from homeassistant.util.json import load_json, save_json -REQUIREMENTS = ['pysabnzbd==1.0.1'] +REQUIREMENTS = ['pysabnzbd==1.1.0'] _LOGGER = logging.getLogger(__name__) @@ -102,7 +103,8 @@ async def async_configure_sabnzbd(hass, config, use_ssl, name=DEFAULT_NAME, hass.config.path(CONFIG_FILE)) api_key = conf.get(base_url, {}).get(CONF_API_KEY, '') - sab_api = SabnzbdApi(base_url, api_key) + sab_api = SabnzbdApi(base_url, api_key, + session=async_get_clientsession(hass)) if await async_check_sabnzbd(sab_api): async_setup_sabnzbd(hass, sab_api, config, name) else: @@ -188,7 +190,8 @@ def async_request_configuration(hass, config, host): async def async_configuration_callback(data): """Handle configuration changes.""" api_key = data.get(CONF_API_KEY) - sab_api = SabnzbdApi(host, api_key) + sab_api = SabnzbdApi(host, api_key, + session=async_get_clientsession(hass)) if not await async_check_sabnzbd(sab_api): return diff --git a/requirements_all.txt b/requirements_all.txt index d693b50b040..70106787f61 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -1057,7 +1057,7 @@ pyrainbird==0.1.6 pyrecswitch==1.0.2 # homeassistant.components.sabnzbd -pysabnzbd==1.0.1 +pysabnzbd==1.1.0 # homeassistant.components.climate.sensibo pysensibo==1.0.3