mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 20:27:08 +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):
|
||||
"""Get the current DNS IP address for hostname."""
|
||||
response = await self.resolver.query(self.hostname,
|
||||
self.querytype)
|
||||
from aiodns.error import DNSError
|
||||
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:
|
||||
self._state = response[0].host
|
||||
else:
|
||||
|
Loading…
x
Reference in New Issue
Block a user