mirror of
https://github.com/esphome/esphome.git
synced 2025-10-29 22:24:26 +00:00
make time components polling components (#1443)
* make real time clock components polling components * add test
This commit is contained in:
@@ -22,7 +22,7 @@ CODEOWNERS = ['@OttoWinter']
|
||||
IS_PLATFORM_COMPONENT = True
|
||||
|
||||
time_ns = cg.esphome_ns.namespace('time')
|
||||
RealTimeClock = time_ns.class_('RealTimeClock', cg.Component)
|
||||
RealTimeClock = time_ns.class_('RealTimeClock', cg.PollingComponent)
|
||||
CronTrigger = time_ns.class_('CronTrigger', automation.Trigger.template(), cg.Component)
|
||||
ESPTime = time_ns.struct('ESPTime')
|
||||
TimeHasTimeCondition = time_ns.class_('TimeHasTimeCondition', Condition)
|
||||
@@ -294,7 +294,7 @@ TIME_SCHEMA = cv.Schema({
|
||||
cv.Optional(CONF_CRON): validate_cron_raw,
|
||||
cv.Optional(CONF_AT): validate_time_at,
|
||||
}, validate_cron_keys),
|
||||
})
|
||||
}).extend(cv.polling_component_schema('15min'))
|
||||
|
||||
|
||||
@coroutine
|
||||
|
||||
@@ -15,7 +15,7 @@ RealTimeClock::RealTimeClock() = default;
|
||||
void RealTimeClock::call_setup() {
|
||||
setenv("TZ", this->timezone_.c_str(), 1);
|
||||
tzset();
|
||||
this->setup();
|
||||
PollingComponent::call_setup();
|
||||
}
|
||||
void RealTimeClock::synchronize_epoch_(uint32_t epoch) {
|
||||
struct timeval timev {
|
||||
|
||||
@@ -106,7 +106,7 @@ struct ESPTime {
|
||||
/// The C library (newlib) available on ESPs only supports TZ strings that specify an offset and DST info;
|
||||
/// you cannot specify zone names or paths to zoneinfo files.
|
||||
/// \see https://www.gnu.org/software/libc/manual/html_node/TZ-Variable.html
|
||||
class RealTimeClock : public Component {
|
||||
class RealTimeClock : public PollingComponent {
|
||||
public:
|
||||
explicit RealTimeClock();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user