1 #include "automation.h" 8 static const char *
const TAG =
"automation";
9 static const int MAX_TIMESTAMP_DRIFT = 900;
30 ESP_LOGW(TAG,
"Time has jumped back!");
34 }
else if (time > *this->
last_check_ && time.
timestamp - this->last_check_->timestamp > MAX_TIMESTAMP_DRIFT) {
36 ESP_LOGW(TAG,
"Time has jumped ahead!");
53 ESP_LOGW(TAG,
"Time is out of range!");
54 ESP_LOGD(TAG,
"Second=%02u Minute=%02u Hour=%02u DayOfWeek=%u DayOfMonth=%u DayOfYear=%u Month=%u time=%" PRId64,
64 for (uint8_t it : seconds)
68 for (uint8_t it : minutes)
72 for (uint8_t it : hours)
76 for (uint8_t it : days_of_month)
80 for (uint8_t it : months)
84 for (uint8_t it : days_of_week)
void add_days_of_week(const std::vector< uint8_t > &days_of_week)
void add_hour(uint8_t hour)
uint8_t month
month; january=1 [1-12]
ESPTime now()
Get the time in the currently defined timezone.
bool is_valid() const
Check if this ESPTime is valid (all fields in range and year is greater than 2018) ...
bool matches(const ESPTime &time)
SyncTrigger(RealTimeClock *rtc)
The RealTimeClock class exposes common timekeeping functions via the device's local real-time clock...
time_t timestamp
unix epoch time (seconds since UTC Midnight January 1, 1970)
void add_minutes(const std::vector< uint8_t > &minutes)
std::bitset< 61 > seconds_
float get_setup_priority() const override
void add_on_time_sync_callback(std::function< void()> callback)
void add_seconds(const std::vector< uint8_t > &seconds)
void trigger(Ts... x)
Inform the parent automation that the event has triggered.
CronTrigger(RealTimeClock *rtc)
uint8_t minute
minutes after the hour [0-59]
std::bitset< 13 > months_
uint16_t day_of_year
day of the year [1-366]
A more user-friendly version of struct tm from time.h.
void add_month(uint8_t month)
std::bitset< 60 > minutes_
void add_day_of_month(uint8_t day_of_month)
void add_months(const std::vector< uint8_t > &months)
uint8_t second
seconds after the minute [0-60]
void add_days_of_month(const std::vector< uint8_t > &days_of_month)
bool fields_in_range() const
Check if all time fields of this ESPTime are in range.
std::bitset< 8 > days_of_week_
std::bitset< 32 > days_of_month_
uint8_t day_of_week
day of the week; sunday=1 [1-7]
optional< ESPTime > last_check_
const float HARDWARE
For components that deal with hardware and are very important like GPIO switch.
void add_second(uint8_t second)
void add_day_of_week(uint8_t day_of_week)
uint8_t day_of_month
day of the month [1-31]
void add_hours(const std::vector< uint8_t > &hours)
void add_minute(uint8_t minute)
uint8_t hour
hours since midnight [0-23]