mirror of
https://github.com/esphome/esphome.git
synced 2025-09-21 20:52:20 +01:00
Correcting ESP32 flash save/load key calculation algorithm (#3416)
Co-authored-by: Otto Winter <otto@otto-winter.com> Co-authored-by: Dr. Zimmermann Zsolt <cina@storage1.cina.hu>
This commit is contained in:
@@ -6,8 +6,17 @@ namespace number {
|
||||
|
||||
static const char *const TAG = "number.automation";
|
||||
|
||||
union convert {
|
||||
float from;
|
||||
uint32_t to;
|
||||
};
|
||||
|
||||
void ValueRangeTrigger::setup() {
|
||||
this->rtc_ = global_preferences->make_preference<bool>(this->parent_->get_object_id_hash());
|
||||
float local_min = this->min_.value(0.0);
|
||||
float local_max = this->max_.value(0.0);
|
||||
convert hash = {.from = (local_max - local_min)};
|
||||
uint32_t myhash = hash.to ^ this->parent_->get_object_id_hash();
|
||||
this->rtc_ = global_preferences->make_preference<bool>(myhash);
|
||||
bool initial_state;
|
||||
if (this->rtc_.load(&initial_state)) {
|
||||
this->previous_in_range_ = initial_state;
|
||||
|
Reference in New Issue
Block a user