9static constexpr uint8_t RX8025T_REG_SEC = 0x00;
10static constexpr uint8_t RX8025T_REG_FLAG = 0x0E;
11static constexpr uint8_t RX8025T_FLAG_VDET = 0x01;
12static constexpr uint8_t RX8025T_FLAG_VLF = 0x02;
26 if (
flags & RX8025T_FLAG_VLF) {
27 ESP_LOGW(TAG,
"VLF flag is set - Loss of oscillator detected. Time may be invalid.");
34 ESP_LOGCONFIG(TAG,
"RX8025T:");
41 ESP_LOGE(TAG,
"Can't read flag register.");
55 if (!this->
read_bytes(RX8025T_REG_SEC, date,
sizeof(date))) {
56 ESP_LOGE(TAG,
"Can't read I2C data.");
62 if (flags & RX8025T_FLAG_VLF) {
63 ESP_LOGW(TAG,
"VLF flag is set - time data may be invalid, not syncing to system clock.");
68 .second =
bcd2dec(date[0] & 0x7f),
69 .minute =
bcd2dec(date[1] & 0x7f),
70 .hour =
bcd2dec(date[2] & 0x3f),
71 .day_of_week =
static_cast<uint8_t
>((date[3] & 0x7f) ? __builtin_ctz(date[3] & 0x7f) + 1 : 1),
72 .day_of_month =
bcd2dec(date[4] & 0x3f),
74 .month =
bcd2dec(date[5] & 0x1f),
75 .year =
static_cast<uint16_t
>(
bcd2dec(date[6]) + 2000),
80 if (!rtc_time.is_valid(
true,
false)) {
81 ESP_LOGE(TAG,
"Invalid RTC time, not syncing to system clock.");
84 ESP_LOGD(TAG,
"Read UTC time: %04d-%02d-%02d %02d:%02d:%02d VDET:%s", rtc_time.year, rtc_time.month,
85 rtc_time.day_of_month, rtc_time.hour, rtc_time.minute, rtc_time.second, ONOFF(
flags & RX8025T_FLAG_VDET));
92 ESP_LOGE(TAG,
"Invalid system time, not syncing to RTC.");
104 if (!this->
write_bytes(RX8025T_REG_SEC, buff,
sizeof(buff))) {
105 ESP_LOGE(TAG,
"Can't write I2C data.");
117 flags &= ~(RX8025T_FLAG_VLF | RX8025T_FLAG_VDET);
void mark_failed()
Mark this component as failed.
void status_set_warning()
void status_clear_warning()
bool write_byte(uint8_t a_register, uint8_t data) const
bool read_byte(uint8_t a_register, uint8_t *data)
bool write_bytes(uint8_t a_register, const uint8_t *data, uint8_t len) const
bool read_bytes(uint8_t a_register, uint8_t *data, uint8_t len)
Compat APIs All methods below have been added for compatibility reasons.
bool read_flags_(uint8_t *flags)
void dump_config() override
ESPTime now()
Get the time in the currently defined timezone.
ESPTime utcnow()
Get the time without any time zone or DST corrections.
void dump_config() override
void synchronize_epoch_(uint32_t epoch)
Report a unix epoch as current time.
constexpr uint8_t bcd2dec(uint8_t val)
ESPHOME_LOG_TAG(TAG, "rx8025t")
constexpr uint8_t dec2bcd(uint8_t val)
A more user-friendly version of struct tm from time.h.
uint8_t minute
minutes after the hour [0-59]
void recalc_timestamp_utc(bool use_day_of_year=true)
Recalculate the timestamp field from the other fields of this ESPTime instance (must be UTC).
uint8_t second
seconds after the minute [0-60]
uint8_t hour
hours since midnight [0-23]
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]