custom-components / climate.programmable_thermostat

Programmable thermostat that let you have a smart thermostat on budget.
The Unlicense
115 stars 35 forks source link

error writing to core.config_entries = integration does not survive HA restart #27

Closed hugalafutro closed 3 years ago

hugalafutro commented 3 years ago

Hi, using 7.1 on HA 0.118.2 when you create the integration via config flow it does not get written to core.config_entries and these error show in log:

Failed to serialize to JSON: /config/.storage/core.config_entries. Bad data at $.data.entries[14].data.min_cycle_duration=0:00:00(<class 'datetime.timedelta'>
Error writing config for core.config_entries: Failed to serialize to JSON: /config/.storage/core.config_entries. Bad data at $.data.entries[14].data.min_cycle_duration=0:00:00(<class 'datetime.timedelta'>

This causes the integration only persist until restart of HA. What I think is happening is it fails because I did not put anything in the new min cycle field. The integration works just fine otherwise.

hugalafutro commented 3 years ago

it's not leaving the field empty, even inputting values into it doesn't work:

inputting either 05:00 or 00:05:00 (which if i understand it right should both mean 5minutes) into the min cycle the errors in logs are still there but the value shows as 0:05:00 regardless of the format I used to input the 5min.

Error writing config for core.config_entries: Failed to serialize to JSON: /config/.storage/core.config_entries. Bad data at $.data.entries[14].data.min_cycle_duration=0:05:00(<class 'datetime.timedelta'>
13:09:01 – helpers/storage.py (ERROR)
Failed to serialize to JSON: /config/.storage/core.config_entries. Bad data at $.data.entries[14].data.min_cycle_duration=0:05:00(<class 'datetime.timedelta'>
13:09:01 – util/json.py (ERROR)
johanolde commented 3 years ago

I have cold floors so I started troubleshooting and found the same here. All settings reset when restarted this morning.

MapoDan commented 3 years ago

Ciao guys,

Yes I noticed it the day after the 7.1 release. I've just release 7.2 that should fix it. Issue was due to how config_flow store data, now I should managed it.

Let me know if you still have issue. (You will keep having migration issue, I'll have a look to it later)

hugalafutro commented 3 years ago

Hi, after updating to 7.2, restarting and recreating the integration it now remains after restart as it should. Thanks for the fix!