mirror of
https://github.com/esphome/esphome.git
synced 2024-11-27 09:18:00 +01:00
Update interval is changed automatically for the duration of calibration
This commit is contained in:
parent
bb12f90864
commit
a4f6987950
2 changed files with 13 additions and 1 deletions
|
@ -568,8 +568,13 @@ void ShellyDimmer::reset_dfu_boot_() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShellyDimmer::start_calibration() {
|
void ShellyDimmer::start_calibration() {
|
||||||
ESP_LOGI(TAG, "Starting calibration");
|
ESP_LOGD(TAG, "Setting update interval to 1 second");
|
||||||
|
this->update_interval_original_ = this->get_update_interval();
|
||||||
|
this->stop_poller();
|
||||||
|
this->set_update_interval(1000);
|
||||||
|
this->start_poller();
|
||||||
|
|
||||||
|
ESP_LOGI(TAG, "Starting calibration");
|
||||||
// Turn on the light, disable transition, set max brightness
|
// Turn on the light, disable transition, set max brightness
|
||||||
this->set_brightness_no_transition_(1);
|
this->set_brightness_no_transition_(1);
|
||||||
|
|
||||||
|
@ -655,6 +660,12 @@ void ShellyDimmer::complete_calibration_() {
|
||||||
}
|
}
|
||||||
|
|
||||||
this->set_brightness_no_transition_(1);
|
this->set_brightness_no_transition_(1);
|
||||||
|
|
||||||
|
uint32_t update_interval = this->update_interval_original_ == 0 ? 10000 : this->update_interval_original_;
|
||||||
|
ESP_LOGD(TAG, "Reverting update interval to %d seconds", update_interval / 1000);
|
||||||
|
this->stop_poller();
|
||||||
|
this->set_update_interval(update_interval);
|
||||||
|
this->start_poller();
|
||||||
}
|
}
|
||||||
void ShellyDimmer::save_calibration_() {
|
void ShellyDimmer::save_calibration_() {
|
||||||
if (this->rtc_.save(&this->calibration_data_)) {
|
if (this->rtc_.save(&this->calibration_data_)) {
|
||||||
|
|
|
@ -89,6 +89,7 @@ class ShellyDimmer : public PollingComponent, public light::LightOutput, public
|
||||||
uint8_t calibration_measurement_cnt_{0};
|
uint8_t calibration_measurement_cnt_{0};
|
||||||
std::array<float, 3> calibration_measurements_;
|
std::array<float, 3> calibration_measurements_;
|
||||||
std::array<float, 20> calibration_data_;
|
std::array<float, 20> calibration_data_;
|
||||||
|
uint32_t update_interval_original_{0};
|
||||||
|
|
||||||
ESPPreferenceObject rtc_;
|
ESPPreferenceObject rtc_;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue