mirror of
https://github.com/home-assistant/core.git
synced 2025-07-18 02:37:08 +00:00
fix aiohttp ServerDisconnectedError in Daikin (#22880)
This commit is contained in:
parent
49a2f5a40b
commit
55c8417ec0
@ -2,13 +2,13 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
from socket import timeout
|
|
||||||
|
|
||||||
import async_timeout
|
from aiohttp import ClientConnectionError
|
||||||
|
from async_timeout import timeout
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry
|
from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry
|
||||||
from homeassistant.const import CONF_HOSTS, CONF_HOST
|
from homeassistant.const import CONF_HOST, CONF_HOSTS
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.helpers.device_registry import CONNECTION_NETWORK_MAC
|
from homeassistant.helpers.device_registry import CONNECTION_NETWORK_MAC
|
||||||
from homeassistant.helpers.typing import HomeAssistantType
|
from homeassistant.helpers.typing import HomeAssistantType
|
||||||
@ -16,7 +16,7 @@ from homeassistant.util import Throttle
|
|||||||
|
|
||||||
from . import config_flow # noqa pylint_disable=unused-import
|
from . import config_flow # noqa pylint_disable=unused-import
|
||||||
|
|
||||||
REQUIREMENTS = ['pydaikin==1.3.1']
|
REQUIREMENTS = ['pydaikin==1.4.0']
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -88,11 +88,14 @@ async def daikin_api_setup(hass, host):
|
|||||||
from pydaikin.appliance import Appliance
|
from pydaikin.appliance import Appliance
|
||||||
session = hass.helpers.aiohttp_client.async_get_clientsession()
|
session = hass.helpers.aiohttp_client.async_get_clientsession()
|
||||||
try:
|
try:
|
||||||
with async_timeout.timeout(10):
|
with timeout(10, loop=hass.loop):
|
||||||
device = Appliance(host, session)
|
device = Appliance(host, session)
|
||||||
await device.init()
|
await device.init()
|
||||||
except asyncio.TimeoutError:
|
except asyncio.TimeoutError:
|
||||||
_LOGGER.error("Connection to Daikin could not be established")
|
_LOGGER.error("Connection to Daikin timeout")
|
||||||
|
return None
|
||||||
|
except ClientConnectionError:
|
||||||
|
_LOGGER.error("ServerDisconected")
|
||||||
return None
|
return None
|
||||||
except Exception: # pylint: disable=broad-except
|
except Exception: # pylint: disable=broad-except
|
||||||
_LOGGER.error("Unexpected error creating device")
|
_LOGGER.error("Unexpected error creating device")
|
||||||
@ -119,7 +122,7 @@ class DaikinApi:
|
|||||||
try:
|
try:
|
||||||
await self.device.update_status()
|
await self.device.update_status()
|
||||||
self._available = True
|
self._available = True
|
||||||
except timeout:
|
except ClientConnectionError:
|
||||||
_LOGGER.warning(
|
_LOGGER.warning(
|
||||||
"Connection failed for %s", self.ip_address
|
"Connection failed for %s", self.ip_address
|
||||||
)
|
)
|
||||||
|
@ -2,7 +2,8 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import async_timeout
|
from aiohttp import ClientError
|
||||||
|
from async_timeout import timeout
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import config_entries
|
from homeassistant import config_entries
|
||||||
@ -42,10 +43,13 @@ class FlowHandler(config_entries.ConfigFlow):
|
|||||||
host,
|
host,
|
||||||
self.hass.helpers.aiohttp_client.async_get_clientsession(),
|
self.hass.helpers.aiohttp_client.async_get_clientsession(),
|
||||||
)
|
)
|
||||||
with async_timeout.timeout(10):
|
with timeout(10):
|
||||||
await device.init()
|
await device.init()
|
||||||
except asyncio.TimeoutError:
|
except asyncio.TimeoutError:
|
||||||
return self.async_abort(reason='device_timeout')
|
return self.async_abort(reason='device_timeout')
|
||||||
|
except ClientError:
|
||||||
|
_LOGGER.exception("ClientError")
|
||||||
|
return self.async_abort(reason='device_fail')
|
||||||
except Exception: # pylint: disable=broad-except
|
except Exception: # pylint: disable=broad-except
|
||||||
_LOGGER.exception("Unexpected error creating device")
|
_LOGGER.exception("Unexpected error creating device")
|
||||||
return self.async_abort(reason='device_fail')
|
return self.async_abort(reason='device_fail')
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
"name": "Daikin",
|
"name": "Daikin",
|
||||||
"documentation": "https://www.home-assistant.io/components/daikin",
|
"documentation": "https://www.home-assistant.io/components/daikin",
|
||||||
"requirements": [
|
"requirements": [
|
||||||
"pydaikin==1.3.1"
|
"pydaikin==1.4.0"
|
||||||
],
|
],
|
||||||
"dependencies": [],
|
"dependencies": [],
|
||||||
"codeowners": [
|
"codeowners": [
|
||||||
|
@ -985,7 +985,7 @@ pycsspeechtts==1.0.2
|
|||||||
# pycups==1.9.73
|
# pycups==1.9.73
|
||||||
|
|
||||||
# homeassistant.components.daikin
|
# homeassistant.components.daikin
|
||||||
pydaikin==1.3.1
|
pydaikin==1.4.0
|
||||||
|
|
||||||
# homeassistant.components.danfoss_air
|
# homeassistant.components.danfoss_air
|
||||||
pydanfossair==0.0.7
|
pydanfossair==0.0.7
|
||||||
|
Loading…
x
Reference in New Issue
Block a user