mirror of
https://github.com/home-assistant/core.git
synced 2025-07-26 06:37:52 +00:00
Add exception handling to dnsip sensor (#17332)
* Add exception handling to dnsip sensor * Refactor import * Fix exception
This commit is contained in:
parent
b2789d9883
commit
241d87e9d3
@ -87,8 +87,13 @@ class WanIpSensor(Entity):
|
|||||||
|
|
||||||
async def async_update(self):
|
async def async_update(self):
|
||||||
"""Get the current DNS IP address for hostname."""
|
"""Get the current DNS IP address for hostname."""
|
||||||
response = await self.resolver.query(self.hostname,
|
from aiodns.error import DNSError
|
||||||
self.querytype)
|
try:
|
||||||
|
response = await self.resolver.query(self.hostname,
|
||||||
|
self.querytype)
|
||||||
|
except DNSError as err:
|
||||||
|
_LOGGER.warning("Exception while resolving host: %s", err)
|
||||||
|
response = None
|
||||||
if response:
|
if response:
|
||||||
self._state = response[0].host
|
self._state = response[0].host
|
||||||
else:
|
else:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user