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", "name": "Dnsip",
"documentation": "https://www.home-assistant.io/components/dnsip", "documentation": "https://www.home-assistant.io/components/dnsip",
"requirements": [ "requirements": [
"aiodns==1.1.1" "aiodns==2.0.0"
], ],
"dependencies": [], "dependencies": [],
"codeowners": [] "codeowners": []

View File

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

View File

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