ScratMan / HASmartThermostat

Smart Thermostat with PID controller for HomeAssistant
336 stars 48 forks source link

Error at startup with valve. PID P stays 0 from debug #170

Closed niekvanprooijen closed 4 months ago

niekvanprooijen commented 8 months ago

I get the following error at startup of HASS:


Logger: homeassistant.components.climate Source: custom_components/smart_thermostat/climate.py:974 Integration: Klimaat (documentation, issues) First occurred: 08:57:06 (2 occurrences) Last logged: 08:57:06

Error adding entities for domain climate with platform smart_thermostat Error while setting up smart_thermostat platform for climate Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 471, in async_add_entities await asyncio.gather(*tasks) File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 749, in _async_add_entity await entity.add_to_platform_finish() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 849, in add_to_platform_finish await self.async_added_to_hass() File "/config/custom_components/smart_thermostat/climate.py", line 478, in async_added_to_hass await self._async_control_heating(calc_pid=True) File "/config/custom_components/smart_thermostat/climate.py", line 953, in _async_control_heating self.async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 590, in async_write_ha_state self._async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 656, in _async_write_ha_state attr.update(self.state_attributes or {}) ^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/climate/init.py", line 334, in state_attributes if self.hvac_action: ^^^^^^^^^^^^^^^^ File "/config/custom_components/smart_thermostat/climate.py", line 532, in hvac_action if not self._is_device_active: ^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/smart_thermostat/climate.py", line 974, in _is_device_active return float(self.hass.states.get(self.heater_or_cooler_entity).state) > 0 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'state'


Configuration.yaml: climate:

And some weird observations (I don't know if it is related to the error): When setpoint temperature is 21 and current temperature 19, PID P output stays 0.0%. PID I output is 100%. It looks like the PID is not calculated correctly.

Smart thermostat is version 2023.10.0, HASS is version 2023.6.0

Help is much apprecieated!

Chupaka commented 8 months ago

Also, when an entity is still not available on startup, I see this in log:

2023-10-15 13:22:11.507 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/home/homeassistant/.homeassistant/custom_components/smart_thermostat/climate.py", line 885, in _async_sensor_changed
    await self._async_control_heating(calc_pid=True)
  File "/home/homeassistant/.homeassistant/custom_components/smart_thermostat/climate.py", line 966, in _async_control_heating
    self.async_write_ha_state()
  File "/srv/homeassistant/lib/python3.11/site-packages/homeassistant/helpers/entity.py", line 779, in async_write_ha_state
    self._async_write_ha_state()
  File "/srv/homeassistant/lib/python3.11/site-packages/homeassistant/helpers/entity.py", line 879, in _async_write_ha_state
    state, attr = self._async_generate_attributes()
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/srv/homeassistant/lib/python3.11/site-packages/homeassistant/helpers/entity.py", line 822, in _async_generate_attributes
    attr.update(self.state_attributes or {})
                ^^^^^^^^^^^^^^^^^^^^^
  File "/srv/homeassistant/lib/python3.11/site-packages/homeassistant/components/climate/__init__.py", line 345, in state_attributes
    if hvac_action := self.hvac_action:
                      ^^^^^^^^^^^^^^^^
  File "/home/homeassistant/.homeassistant/custom_components/smart_thermostat/climate.py", line 534, in hvac_action
    if not self._is_device_active:
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/homeassistant/.homeassistant/custom_components/smart_thermostat/climate.py", line 977, in _is_device_active
    return float(self.hass.states.get(self.heater_or_cooler_entity).state) > 0
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: could not convert string to float: 'unavailable'
LeChuck2909 commented 6 months ago

I´m having the same issue.