ScratMan / HASmartThermostat

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

float division by zero #66

Closed Adorem closed 2 years ago

Adorem commented 2 years ago

Bonjour,

J'essaye de calibrer deux thermostats et j'obtiens les erreurs suivantes:

Describe the bug

Logger: homeassistant.components.websocket_api.http.connection
Source: custom_components/smart_thermostat/pid_controller/__init__.py:305
Integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 06:48:48 (2 occurrences)
Last logged: 06:48:53

[140041979602688] float division by zero
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 185, in handle_call_service
    await hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 1495, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1530, in _execute_service
    await handler.job.target(service_call)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 209, in handle_service
    await self.hass.helpers.service.entity_service_call(
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 663, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 896, in async_request_call
    await coro
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 700, in _handle_entity_call
    await result
  File "/config/custom_components/smart_thermostat/climate.py", line 646, in async_set_hvac_mode
    await self._async_control_heating(calc_pid=True)
  File "/config/custom_components/smart_thermostat/climate.py", line 823, in _async_control_heating
    await self.async_update_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 492, in async_update_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 541, in _async_write_ha_state
    extra_state_attributes = self.extra_state_attributes
  File "/config/custom_components/smart_thermostat/climate.py", line 621, in extra_state_attributes
    "autotune_buffer_full": round(self._pidAutotune.buffer_full, 2),
  File "/config/custom_components/smart_thermostat/pid_controller/__init__.py", line 305, in buffer_full
    return len(self._inputs) / float(self._inputs.maxlen)
ZeroDivisionError: float division by zero
Cette erreur provient d'une intégration personnalisée

Logger: homeassistant.helpers.event
Source: custom_components/smart_thermostat/pid_controller/__init__.py:305
Integration: smart_thermostat (documentation, issues)
First occurred: 06:19:07 (14 occurrences)
Last logged: 08:23:07

Error while processing state change for switch.sonoff_4ch_relay_4
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/event.py", line 269, in _async_state_change_dispatcher
    hass.async_run_hass_job(job, event)
  File "/usr/src/homeassistant/homeassistant/core.py", line 433, in async_run_hass_job
    hassjob.target(*args)
  File "/usr/src/homeassistant/homeassistant/helpers/event.py", line 209, in state_change_listener
    state_change_dispatcher(event)
  File "/usr/src/homeassistant/homeassistant/helpers/event.py", line 196, in state_change_dispatcher
    hass.async_run_hass_job(
  File "/usr/src/homeassistant/homeassistant/core.py", line 433, in async_run_hass_job
    hassjob.target(*args)
  File "/config/custom_components/smart_thermostat/climate.py", line 783, in _async_switch_changed
    self.async_schedule_update_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 660, in async_schedule_update_ha_state
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 505, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 541, in _async_write_ha_state
    extra_state_attributes = self.extra_state_attributes
  File "/config/custom_components/smart_thermostat/climate.py", line 621, in extra_state_attributes
    "autotune_buffer_full": round(self._pidAutotune.buffer_full, 2),
  File "/config/custom_components/smart_thermostat/pid_controller/__init__.py", line 305, in buffer_full
    return len(self._inputs) / float(self._inputs.maxlen)
ZeroDivisionError: float division by zero
Cette erreur provient d'une intégration personnalisée

Logger: homeassistant
Source: custom_components/smart_thermostat/pid_controller/__init__.py:305
Integration: smart_thermostat (documentation, issues)
First occurred: 06:19:07 (355 occurrences)
Last logged: 08:36:47

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/config/custom_components/smart_thermostat/climate.py", line 765, in _async_sensor_changed
    await self._async_control_heating(calc_pid=True)
  File "/config/custom_components/smart_thermostat/climate.py", line 823, in _async_control_heating
    await self.async_update_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 492, in async_update_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 541, in _async_write_ha_state
    extra_state_attributes = self.extra_state_attributes
  File "/config/custom_components/smart_thermostat/climate.py", line 621, in extra_state_attributes
    "autotune_buffer_full": round(self._pidAutotune.buffer_full, 2),
  File "/config/custom_components/smart_thermostat/pid_controller/__init__.py", line 305, in buffer_full
    return len(self._inputs) / float(self._inputs.maxlen)
ZeroDivisionError: float division by zero

To Reproduce

climate:
  - platform: smart_thermostat
    name: Thermostat salon
    unique_id: smart_thermostat_salon
    heater: switch.sonoff_4ch_relay_3
    target_sensor: sensor.temperature_salon
    outdoor_sensor: sensor.wemos_teleinfo_temperature
    min_temp: 18
    max_temp: 25
    ac_mode: False
    target_temp: 21
    target_temp_step: 0.1
    keep_alive:
      seconds: 60
    away_temp: 18
    kp: 3.6834316626861
    ki: 0.030695589940704194
    kd: 110.50177598710151
    ke: 0.01
    pwm: 00:15:00
    autotune: "ziegler-nichols"
    lookback: 02:00:00
    noiseband: 0.2
  - platform: smart_thermostat
    name: Thermostat bureau
    unique_id: smart_thermostat_bureau
    heater: switch.sonoff_4ch_relay_4
    target_sensor: sensor.temperature_bureau
    outdoor_sensor: sensor.wemos_teleinfo_temperature
    min_temp: 18
    max_temp: 25
    ac_mode: False
    target_temp: 21
    target_temp_step: 0.1
    keep_alive:
      seconds: 60
    away_temp: 18
    kp: 5
    ki: 0.01
    kd: 500
    ke: 0.01
    pwm: 00:15:00
    autotune: "ziegler-nichols"
    lookback: 0024:00:00
    noiseband: 0.2

Merci !

Adorem commented 2 years ago

Oops ça semble venir de cette erreur de configuration:

    lookback: 0024:00:00