3#ifdef USE_DATETIME_DATETIME
9static const char *
const TAG =
"template.datetime";
12 if (this->
f_.has_value())
41 if (!this->
f_.has_value())
44 auto val = this->
f_();
45 if (
val.has_value()) {
57 auto opt_year =
call.get_year();
58 auto opt_month =
call.get_month();
59 auto opt_day =
call.get_day();
60 auto opt_hour =
call.get_hour();
61 auto opt_minute =
call.get_minute();
62 auto opt_second =
call.get_second();
63 bool has_year = opt_year.has_value();
64 bool has_month = opt_month.has_value();
65 bool has_day = opt_day.has_value();
66 bool has_hour = opt_hour.has_value();
67 bool has_minute = opt_minute.has_value();
68 bool has_second = opt_second.has_value();
72 value.
year = *opt_year;
75 value.
month = *opt_month;
81 value.
hour = *opt_hour;
84 value.
minute = *opt_minute;
87 value.
second = *opt_second;
93 this->
year_ = *opt_year;
97 this->
day_ = *opt_day;
99 this->
hour_ = *opt_hour;
110 temp.
year = *opt_year;
115 temp.
month = *opt_month;
125 temp.
hour = *opt_hour;
130 temp.
minute = *opt_minute;
135 temp.
second = *opt_second;
145 LOG_DATETIME_DATETIME(
"",
"Template DateTime",
this);
146 ESP_LOGCONFIG(TAG,
" Optimistic: %s", YESNO(this->
optimistic_));
147 LOG_UPDATE_INTERVAL(
this);
ESPPreferenceObject make_entity_preference(uint32_t version=0)
Create a preference object for storing this entity's state/settings.
void trigger(const Ts &...x) ESPHOME_ALWAYS_INLINE
Inform the parent automation that the event has triggered.
void control(const datetime::DateTimeCall &call) override
Trigger< ESPTime > set_trigger_
void dump_config() override
TemplateLambda< ESPTime > f_
ESPPreferenceObject pref_
A more user-friendly version of struct tm from time.h.
uint8_t minute
minutes after the hour [0-59]
uint8_t second
seconds after the minute [0-60]
uint8_t hour
hours since midnight [0-23]
uint8_t day_of_month
day of the month [1-31]
uint8_t month
month; january=1 [1-12]
void apply(DateTimeEntity *datetime)