1
0
mirror of https://github.com/esphome/esphome.git synced 2025-04-16 07:40:29 +01:00

fix: add validation check for timers in read_timers_to_log method of DynamicLampComponent

This commit is contained in:
Oliver Kleinecke 2025-02-19 20:05:26 +01:00
parent 5abdff81c1
commit 944d9661bf

View File

@ -326,27 +326,29 @@ void DynamicLampComponent::read_timers_to_log() {
DynamicLampTimer timer;
for (uint8_t i = 0; i < 12; i++) {
this->fram_->read((0x4000 + (i * 64)), reinterpret_cast<unsigned char *>(&timer), 64);
std::string lamp_names_str = "";
for (uint8_t j = 0; j < 16; j++) {
uint8_t k = 0;
uint8_t l = j;
if (j > 7) {
k = 1;
l = j - 8;
}
//bool lamp_included = static_cast<bool>(timer.lamp_list[j / 8] & (1 << (j % 8)));
bool lamp_included = static_cast<bool>(timer.lamp_list[k] & (1 << l));
if (lamp_included == true && this->active_lamps_[j].active == true) {
if (lamp_names_str.length() > 0) {
lamp_names_str += ", ";
if (timer.validation_bytes[0] == 'V' && timer.validation_bytes[1] == 'D' && timer.validation_bytes[2] == 'L' && timer.validation_bytes[3] == 'T' && timer.in_use == true) {
std::string lamp_names_str = "";
for (uint8_t j = 0; j < 16; j++) {
uint8_t k = 0;
uint8_t l = j;
if (j > 7) {
k = 1;
l = j - 8;
}
//bool lamp_included = static_cast<bool>(timer.lamp_list[j / 8] & (1 << (j % 8)));
bool lamp_included = static_cast<bool>(timer.lamp_list[k] & (1 << l));
if (lamp_included == true && this->active_lamps_[j].active == true) {
if (lamp_names_str.length() > 0) {
lamp_names_str += ", ";
}
lamp_names_str += this->active_lamps_[j].name;
}
lamp_names_str += this->active_lamps_[j].name;
}
ESP_LOGV(TAG, "Timer %s found: [ active: %d, action: %d, hour: %d, minute: %d, monday: %d, tuesday: %d, wednesday: %d, thursday: %d, friday: %d, saturday: %d, sunday: %d ]",
timer.timer_desc, timer.active, timer.action, timer.hour, timer.minute, timer.monday, timer.tuesday,
timer.wednesday, timer.thursday, timer.friday, timer.saturday, timer.sunday);
ESP_LOGV(TAG, "Timer active for lamps %s", lamp_names_str.c_str());
}
ESP_LOGV(TAG, "Timer %s found: [ active: %d, action: %d, hour: %d, minute: %d, monday: %d, tuesday: %d, wednesday: %d, thursday: %d, friday: %d, saturday: %d, sunday: %d ]",
timer.timer_desc, timer.active, timer.action, timer.hour, timer.minute, timer.monday, timer.tuesday,
timer.wednesday, timer.thursday, timer.friday, timer.saturday, timer.sunday);
ESP_LOGV(TAG, "Timer active for lamps %s", lamp_names_str.c_str());
}
}