mirror of
https://github.com/esphome/esphome.git
synced 2026-05-20 09:31:56 +08:00
[sprinkler][pn532] Fix bugprone-unchecked-optional-access (#16102)
This commit is contained in:
@@ -317,6 +317,7 @@ enum PN532ReadReady PN532::read_ready_(bool block) {
|
||||
if (!this->rd_start_time_.has_value()) {
|
||||
this->rd_start_time_ = millis();
|
||||
}
|
||||
const uint32_t rd_start_time = *this->rd_start_time_;
|
||||
|
||||
while (true) {
|
||||
if (this->is_read_ready()) {
|
||||
@@ -324,7 +325,7 @@ enum PN532ReadReady PN532::read_ready_(bool block) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (millis() - *this->rd_start_time_ > 100) {
|
||||
if (millis() - rd_start_time > 100) {
|
||||
ESP_LOGV(TAG, "Timed out waiting for readiness from PN532!");
|
||||
this->rd_ready_ = TIMEOUT;
|
||||
break;
|
||||
|
||||
@@ -897,11 +897,12 @@ void Sprinkler::resume() {
|
||||
}
|
||||
|
||||
if (this->paused_valve_.has_value() && (this->resume_duration_.has_value())) {
|
||||
const size_t paused_valve = *this->paused_valve_;
|
||||
const uint32_t resume_duration = *this->resume_duration_;
|
||||
// Resume only if valve has not been completed yet
|
||||
if (!this->valve_cycle_complete_(this->paused_valve_.value())) {
|
||||
ESP_LOGD(TAG, "Resuming valve %zu with %" PRIu32 " seconds remaining", this->paused_valve_.value_or(0),
|
||||
this->resume_duration_.value_or(0));
|
||||
this->fsm_request_(this->paused_valve_.value(), this->resume_duration_.value());
|
||||
if (!this->valve_cycle_complete_(paused_valve)) {
|
||||
ESP_LOGD(TAG, "Resuming valve %zu with %" PRIu32 " seconds remaining", paused_valve, resume_duration);
|
||||
this->fsm_request_(paused_valve, resume_duration);
|
||||
}
|
||||
this->reset_resume();
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user