mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 05:07:41 +00:00
Add link to docs and update ordering (#10062)
This commit is contained in:
parent
e201bcad14
commit
f4f36a3662
@ -1,4 +1,9 @@
|
|||||||
"""Integrate with DuckDNS."""
|
"""
|
||||||
|
Integrate with DuckDNS.
|
||||||
|
|
||||||
|
For more details about this component, please refer to the documentation at
|
||||||
|
https://home-assistant.io/components/duckdns/
|
||||||
|
"""
|
||||||
import asyncio
|
import asyncio
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
@ -11,13 +16,18 @@ import homeassistant.helpers.config_validation as cv
|
|||||||
from homeassistant.helpers.event import async_track_time_interval
|
from homeassistant.helpers.event import async_track_time_interval
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
|
|
||||||
DOMAIN = 'duckdns'
|
|
||||||
UPDATE_URL = 'https://www.duckdns.org/update'
|
|
||||||
INTERVAL = timedelta(minutes=5)
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
SERVICE_SET_TXT = 'set_txt'
|
|
||||||
ATTR_TXT = 'txt'
|
ATTR_TXT = 'txt'
|
||||||
|
|
||||||
|
DOMAIN = 'duckdns'
|
||||||
|
|
||||||
|
INTERVAL = timedelta(minutes=5)
|
||||||
|
|
||||||
|
SERVICE_SET_TXT = 'set_txt'
|
||||||
|
|
||||||
|
UPDATE_URL = 'https://www.duckdns.org/update'
|
||||||
|
|
||||||
CONFIG_SCHEMA = vol.Schema({
|
CONFIG_SCHEMA = vol.Schema({
|
||||||
DOMAIN: vol.Schema({
|
DOMAIN: vol.Schema({
|
||||||
vol.Required(CONF_DOMAIN): cv.string,
|
vol.Required(CONF_DOMAIN): cv.string,
|
||||||
@ -59,8 +69,8 @@ def async_setup(hass, config):
|
|||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def update_domain_service(call):
|
def update_domain_service(call):
|
||||||
"""Update the DuckDNS entry."""
|
"""Update the DuckDNS entry."""
|
||||||
yield from _update_duckdns(session, domain, token,
|
yield from _update_duckdns(
|
||||||
txt=call.data[ATTR_TXT])
|
session, domain, token, txt=call.data[ATTR_TXT])
|
||||||
|
|
||||||
async_track_time_interval(hass, update_domain_interval, INTERVAL)
|
async_track_time_interval(hass, update_domain_interval, INTERVAL)
|
||||||
hass.services.async_register(
|
hass.services.async_register(
|
||||||
@ -96,7 +106,7 @@ def _update_duckdns(session, domain, token, *, txt=_SENTINEL, clear=False):
|
|||||||
body = yield from resp.text()
|
body = yield from resp.text()
|
||||||
|
|
||||||
if body != 'OK':
|
if body != 'OK':
|
||||||
_LOGGER.warning('Updating DuckDNS domain %s failed', domain)
|
_LOGGER.warning("Updating DuckDNS domain failed: %s", domain)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
Loading…
x
Reference in New Issue
Block a user