JamesSwift/localbytes-plug-pm

"Disable LED" resets to default after ESPHome firmware upgrade

andrewmooreio opened this issue · 2 comments

Hi,

I've noticed that whenever I update the firmware of my plugs, the LED turns back on. Not a huge deal, but can get annoying for plugs located in bedrooms.

I had a quick look through the YAML, and it seems the "Disable LED" switch has the restore_mode set to RESTORE_DEFAULT_OFF. My understanding is this should try to restore state to whatever it was previously. Why is the restore failing? The setting works for the relay.

Thanks in advance.

Hi,

Thanks for pointing this out. I hadn't noticed that before, but yes you're right! After going down some rabbit holes trying to figure out why, I eventually realised it was something of a race condition in the initialization of disabled_led and disable_button. The state of each switch was being restored properly, but the logic of whether or not the LED was left illuminated after the state was loaded wasn't working. (Actually in firmware compiled before January the state of disable_led wasn't even being restored due to a bug in esphome).

I've fixed that problem in the latest release, and also added a bit of extra logic. Now when the plug receives power the led will either just turn on, or be left off, depending on the state of the three switches. (Instead of flashing the led like it used to, which was actually unintentional behaviour).

Thanks for pointing the bug out. Please let me know if the latest release fixes your issue.

All good, just upgraded ESPHome on all my plugs and the light has stayed off. Thanks a lot @JamesSwift.