1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-22 13:12:22 +01:00

Clean up time API (#221)

This commit is contained in:
Otto Winter
2018-11-09 20:08:16 +01:00
committed by GitHub
parent 3ec931ffa4
commit a9e799cb06
2 changed files with 56 additions and 30 deletions

View File

@@ -3,7 +3,7 @@ import voluptuous as vol
import esphomeyaml.config_validation as cv
from esphomeyaml.components import time as time_
from esphomeyaml.const import CONF_ID, CONF_LAMBDA, CONF_SERVERS
from esphomeyaml.helpers import App, Pvariable
from esphomeyaml.helpers import App, Pvariable, add
SNTPComponent = time_.time_ns.SNTPComponent
@@ -15,8 +15,10 @@ PLATFORM_SCHEMA = time_.TIME_PLATFORM_SCHEMA.extend({
def to_code(config):
rhs = App.make_sntp_component(*config.get(CONF_SERVERS, []))
rhs = App.make_sntp_component()
sntp = Pvariable(config[CONF_ID], rhs)
if CONF_SERVERS in config:
add(sntp.set_servers(*config[CONF_SERVERS]))
time_.setup_time(sntp, config)