ScratMan / HASmartThermostat

Smart Thermostat with PID controller for HomeAssistant
345 stars 50 forks source link

When autotune is set and HA is restarting - >error 'SmartThermostat' object has no attribute 'pidController' #3

Closed benlbrm closed 2 years ago

benlbrm commented 2 years ago

When restarting HA and autotune is set, we got an error, cause in that case, pidController did not exists.

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 382, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 607, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 714, in add_to_platform_finish
    await self.async_added_to_hass()
  File "/config/custom_components/smart_thermostat/climate.py", line 287, in async_added_to_hass
    self.pidController.integral = self.i
AttributeError: 'SmartThermostat' object has no attribute 'pidController'
2021-11-08 13:15:12 ERROR (MainThread) [homeassistant.components.climate] Error while setting up smart_thermostat platform for climate
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 257, in _async_setup_platform
    await asyncio.gather(*pending)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 382, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 607, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 714, in add_to_platform_finish
    await self.async_added_to_hass()
  File "/config/custom_components/smart_thermostat/climate.py", line 287, in async_added_to_hass
    self.pidController.integral = self.i
AttributeError: 'SmartThermostat' object has no attribute 'pidController'
ScratMan commented 2 years ago

Hi, please try with v2021.11.6.beta-1. I included a quick fix.

ScratMan commented 2 years ago

I made some trials, confirms the bug is fixed in release 2021.11.6.