From 5ac9b8d545367d2dec254abc3e04aea5907aa5e4 Mon Sep 17 00:00:00 2001 From: Otto Winter Date: Tue, 15 Jan 2019 20:13:20 +0100 Subject: [PATCH] Allow IPv4 addresses for SNTP servers (#340) Fixes https://github.com/OttoWinter/esphomelib/issues/395 --- esphomeyaml/config_validation.py | 7 +++++-- tests/test1.yaml | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/esphomeyaml/config_validation.py b/esphomeyaml/config_validation.py index 68e96c5b44..e847747911 100644 --- a/esphomeyaml/config_validation.py +++ b/esphomeyaml/config_validation.py @@ -458,9 +458,12 @@ def hostname(value): def domain(value): value = string(value) - if re.match(vol.DOMAIN_REGEX, value) is None: + if re.match(vol.DOMAIN_REGEX, value) is not None: + return value + try: + return str(ipv4(value)) + except vol.Invalid: raise vol.Invalid("Invalid domain: {}".format(value)) - return value def domain_name(value): diff --git a/tests/test1.yaml b/tests/test1.yaml index ba5bd1f791..0ad6e07621 100644 --- a/tests/test1.yaml +++ b/tests/test1.yaml @@ -1022,7 +1022,7 @@ time: servers: - 0.pool.ntp.org - 1.pool.ntp.org - - 2.pool.ntp.org + - 192.168.178.1 on_time: cron: '/30 0-30,30/5 * ? JAN-DEC MON,SAT-SUN,TUE-FRI' then: