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;
21 if (
flags & RX8025T_FLAG_VLF) {
22 ESP_LOGW(TAG,
"VLF flag is set - Loss of oscillator detected. Time may be invalid.");
29 ESP_LOGCONFIG(TAG,
"RX8025T:");
36 ESP_LOGE(TAG,
"Can't read flag register.");
51 ESP_LOGE(TAG,
"Can't read I2C data.");
55 if (
flags & RX8025T_FLAG_VLF) {
56 ESP_LOGW(TAG,
"VLF flag is set - time data may be invalid, not syncing to system clock.");
60 ESPTime rtc_time = time::decode_bcd_calendar<time::EPSON_BCD_CALENDAR>(date);
61 if (!rtc_time.
is_valid(
true,
false)) {
62 ESP_LOGE(TAG,
"Invalid RTC time, not syncing to system clock.");
65 ESP_LOGD(TAG,
"Read UTC time: %04d-%02d-%02d %02d:%02d:%02d VDET:%s", rtc_time.
year, rtc_time.
month,
73 ESP_LOGE(TAG,
"Invalid system time, not syncing to RTC.");
78 time::encode_bcd_calendar<time::EPSON_BCD_CALENDAR>(
now, buff);
79 if (!this->
write_bytes(RX8025T_REG_SEC, buff,
sizeof(buff))) {
80 ESP_LOGE(TAG,
"Can't write I2C data.");
92 flags &= ~(RX8025T_FLAG_VLF | RX8025T_FLAG_VDET);
void status_set_warning()
bool status_comm_result(bool ok)
Clears the warning when ok, else sets it with message (default "Communication failed"); returns ok.
bool ESPHOME_ALWAYS_INLINE setup_check(bool ok)
Marks the component failed with message (default "Communication failed") unless ok; returns ok.
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.
ESPHOME_LOG_TAG(TAG, "rx8025t")
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 >= internal::MIN_VALID_YEAR and the requested fields are in rang...
uint8_t day_of_month
day of the month [1-31]
uint8_t month
month; january=1 [1-12]