11 ESP_LOGCONFIG(TAG,
"DS3231 Time:");
12 RealTimeClock::dump_config();
19 const ESPTime rtc_time = time::decode_bcd_calendar<time::DS_BCD_CALENDAR>(
raw);
20 ESP_LOGD(TAG,
"Read UTC time: %04u-%02u-%02u %02u:%02u:%02u (day of week %u)", rtc_time.
year, rtc_time.
month,
25 LOG_STR(
"Invalid RTC time")))
33 ESP_LOGE(TAG,
"Invalid system time, not syncing to RTC.");
37 ESP_LOGE(TAG,
"Year %u is out of the DS3231 range (2000-2199).",
now.
year);
41 time::encode_bcd_calendar<time::DS_BCD_CALENDAR>(
now,
raw);
bool status_comm_result(bool ok)
Clears the warning when ok, else sets it with message (default "Communication failed"); returns ok.
DS3231Component * parent_
static constexpr size_t CALENDAR_LEN
Seconds through year, the 7-byte BCD calendar the time platform decodes with time::DS_BCD_CALENDAR.
void write_time()
Store the system clock in the RTC.
void dump_config() override
void read_time()
Set the system clock from the RTC.
ESPTime now()
Get the time in the currently defined timezone.
ESPTime utcnow()
Get the time without any time zone or DST corrections.
void synchronize_epoch_(uint32_t epoch)
Report a unix epoch as current time.
ESPHOME_LOG_TAG(TAG, "ds3231")
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]
time_t timestamp
unix epoch time (seconds since UTC Midnight January 1, 1970)
bool is_valid(bool check_day_of_week=true, bool check_day_of_year=true) const
Check if this ESPTime is valid (year >= 2019 and the requested fields are in range).
uint8_t day_of_month
day of the month [1-31]
uint8_t month
month; january=1 [1-12]
uint8_t day_of_week
day of the week; sunday=1 [1-7]