Tibber: retry if we fail to connect at startup (#12620)
* Tibber: retry if we fail to connect at startup * Tibber: retry if we fail to connect at startup * Tibber: retry if we fail to connect at startup * Tibber: retry if we fail to connect at startup * Update tibber.py * Update tibber.py
This commit is contained in:
parent
23c39ebefd
commit
b186b27600
2 changed files with 16 additions and 10 deletions
|
@ -9,16 +9,18 @@ import asyncio
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
import aiohttp
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
||||||
from homeassistant.const import CONF_ACCESS_TOKEN
|
from homeassistant.const import CONF_ACCESS_TOKEN
|
||||||
|
from homeassistant.exceptions import PlatformNotReady
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
from homeassistant.util import dt as dt_util
|
from homeassistant.util import dt as dt_util
|
||||||
|
|
||||||
REQUIREMENTS = ['pyTibber==0.2.1']
|
REQUIREMENTS = ['pyTibber==0.3.0']
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -33,14 +35,18 @@ SCAN_INTERVAL = timedelta(minutes=1)
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
|
def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
|
||||||
"""Set up the Tibber sensor."""
|
"""Set up the Tibber sensor."""
|
||||||
import Tibber
|
import tibber
|
||||||
tibber = Tibber.Tibber(config[CONF_ACCESS_TOKEN],
|
tibber_connection = tibber.Tibber(config[CONF_ACCESS_TOKEN],
|
||||||
websession=async_get_clientsession(hass))
|
websession=async_get_clientsession(hass))
|
||||||
yield from tibber.update_info()
|
|
||||||
|
try:
|
||||||
|
yield from tibber_connection.update_info()
|
||||||
dev = []
|
dev = []
|
||||||
for home in tibber.get_homes():
|
for home in tibber_connection.get_homes():
|
||||||
yield from home.update_info()
|
yield from home.update_info()
|
||||||
dev.append(TibberSensor(home))
|
dev.append(TibberSensor(home))
|
||||||
|
except (asyncio.TimeoutError, aiohttp.ClientError):
|
||||||
|
raise PlatformNotReady() from None
|
||||||
|
|
||||||
async_add_devices(dev, True)
|
async_add_devices(dev, True)
|
||||||
|
|
||||||
|
|
|
@ -644,7 +644,7 @@ pyHS100==0.3.0
|
||||||
pyRFXtrx==0.21.1
|
pyRFXtrx==0.21.1
|
||||||
|
|
||||||
# homeassistant.components.sensor.tibber
|
# homeassistant.components.sensor.tibber
|
||||||
pyTibber==0.2.1
|
pyTibber==0.3.0
|
||||||
|
|
||||||
# homeassistant.components.switch.dlink
|
# homeassistant.components.switch.dlink
|
||||||
pyW215==0.6.0
|
pyW215==0.6.0
|
||||||
|
|
Loading…
Add table
Reference in a new issue