mirror of
https://github.com/Threnklyn/esphome-dev.git
synced 2026-05-21 13:33:27 +02:00
652f6058d1
* make real time clock components polling components * add test
24 lines
751 B
Python
24 lines
751 B
Python
from esphome.components import time as time_
|
|
import esphome.config_validation as cv
|
|
import esphome.codegen as cg
|
|
from esphome.const import CONF_ID
|
|
from .. import gps_ns, GPSListener, CONF_GPS_ID, GPS
|
|
|
|
DEPENDENCIES = ['gps']
|
|
|
|
GPSTime = gps_ns.class_('GPSTime', cg.PollingComponent, time_.RealTimeClock, GPSListener)
|
|
|
|
CONFIG_SCHEMA = time_.TIME_SCHEMA.extend({
|
|
cv.GenerateID(): cv.declare_id(GPSTime),
|
|
cv.GenerateID(CONF_GPS_ID): cv.use_id(GPS),
|
|
}).extend(cv.polling_component_schema('5min'))
|
|
|
|
|
|
def to_code(config):
|
|
var = cg.new_Pvariable(config[CONF_ID])
|
|
yield time_.register_time(var, config)
|
|
yield cg.register_component(var, config)
|
|
|
|
paren = yield cg.get_variable(config[CONF_GPS_ID])
|
|
cg.add(paren.register_listener(var))
|