Upgrade aiodns to 2.0.0 (#23743)

This commit is contained in:
Fabian Affolter 2019-05-07 21:32:05 +02:00 committed by Charles Garwood
parent 264e70922b
commit b253c7499d
3 changed files with 14 additions and 12 deletions

View file

@ -3,7 +3,7 @@
"name": "Dnsip",
"documentation": "https://www.home-assistant.io/components/dnsip",
"requirements": [
"aiodns==1.1.1"
"aiodns==2.0.0"
],
"dependencies": [],
"codeowners": []

View file

@ -1,26 +1,26 @@
"""Get your own public IP address or that of any host."""
import logging
from datetime import timedelta
import logging
import voluptuous as vol
from homeassistant.components.sensor import PLATFORM_SCHEMA
from homeassistant.const import CONF_NAME
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import Entity
_LOGGER = logging.getLogger(__name__)
CONF_NAME = 'name'
CONF_HOSTNAME = 'hostname'
CONF_IPV6 = 'ipv6'
CONF_RESOLVER = 'resolver'
CONF_RESOLVER_IPV6 = 'resolver_ipv6'
CONF_IPV6 = 'ipv6'
DEFAULT_NAME = 'myip'
DEFAULT_HOSTNAME = 'myip.opendns.com'
DEFAULT_IPV6 = False
DEFAULT_NAME = 'myip'
DEFAULT_RESOLVER = '208.67.222.222'
DEFAULT_RESOLVER_IPV6 = '2620:0:ccc::2'
DEFAULT_IPV6 = False
SCAN_INTERVAL = timedelta(seconds=120)
@ -33,8 +33,8 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
})
async def async_setup_platform(hass, config, async_add_devices,
discovery_info=None):
async def async_setup_platform(
hass, config, async_add_devices, discovery_info=None):
"""Set up the DNS IP sensor."""
hostname = config.get(CONF_HOSTNAME)
name = config.get(CONF_NAME)
@ -57,8 +57,9 @@ class WanIpSensor(Entity):
"""Implementation of a DNS IP sensor."""
def __init__(self, hass, name, hostname, resolver, ipv6):
"""Initialize the sensor."""
"""Initialize the DNS IP sensor."""
import aiodns
self.hass = hass
self._name = name
self.hostname = hostname
@ -80,9 +81,10 @@ class WanIpSensor(Entity):
async def async_update(self):
"""Get the current DNS IP address for hostname."""
from aiodns.error import DNSError
try:
response = await self.resolver.query(self.hostname,
self.querytype)
response = await self.resolver.query(
self.hostname, self.querytype)
except DNSError as err:
_LOGGER.warning("Exception while resolving host: %s", err)
response = None

View file

@ -115,7 +115,7 @@ aioautomatic==0.6.5
aiobotocore==0.10.2
# homeassistant.components.dnsip
aiodns==1.1.1
aiodns==2.0.0
# homeassistant.components.esphome
aioesphomeapi==2.0.1