jmcollin78 / versatile_thermostat

A full featured Thermostat for Home Assistant: presets, window, motion, presence and overpowering management
MIT License
331 stars 36 forks source link

New Thermostat Installation / Configuration changes fail (and crash HA!) #506

Closed Jadefalcon100 closed 1 month ago

Jadefalcon100 commented 1 month ago

Hi there,

when I crate a new VTherm Home Assistant crashes. Vtherm shows the next step popup, but never finished. Instead HA as a whole becomes inresponsive/crashes after 10 seconds and never recovers. image

The Instance can only be brought back with a VM restart.

After the restart the VTherm is despite it fuctional, but when I change the configuration it returns to a failed state. Wohnzimmer - Hinten: functional after restart image

Wohnzimmer - Vorner: functional after restart - just did a pseudo change by altering cycle time => Error image

Version of the custom_component

Configuration

My VTherm attributes are the following (both VTherms above are identical except for switch and sensor)

hvac_modes: heat, off
min_temp: 10
max_temp: 30
target_temp_step: 0.1
current_temperature: 22.2
temperature: null
hvac_action: idle
is_on: null
hvac_mode: null
preset_mode: none
type: null
is_controlled_by_central_mode: false
last_central_mode: null
frost_temp: 0
eco_temp: 0
boost_temp: 0
comfort_temp: 0
frost_away_temp: 0
eco_away_temp: 0
boost_away_temp: 0
comfort_away_temp: 0
power_temp: null
target_temperature_step: 0.1
ext_current_temperature: null
ac_mode: false
current_power: null
current_power_max: null
saved_preset_mode: none
saved_target_temp: none
saved_hvac_mode: null
motion_sensor_entity_id: null
motion_state: null
power_sensor_entity_id: null
max_power_sensor_entity_id: null
overpowering_state: null
presence_sensor_entity_id: null
presence_state: null
window_state: off
window_auto_state: off
window_bypass_state: false
window_sensor_entity_id: null
window_delay_sec: null
window_auto_enabled: false
window_auto_open_threshold: null
window_auto_close_threshold: null
window_auto_max_duration: null
window_action: window_turn_off
security_delay_min: 60
security_min_on_percent: 0.5
security_default_on_percent: 0.1
last_temperature_datetime: 2024-09-27T06:30:31.933001+02:00
last_ext_temperature_datetime: 2024-09-27T06:30:29.479694+02:00
security_state: false
minimal_activation_delay_sec: 10
device_power: 1
mean_cycle_power: 0
total_energy: null
last_update_datetime: 2024-09-27T06:30:36.516055+02:00
timezone: Europe/Berlin
temperature_unit: °C
is_device_active: false
ema_temp: 22.2
is_used_by_central_boiler: false
is_over_switch: true
is_inversed: true
keep_alive_sec: 0
underlying_switch_0: switch.schalter_eg_heizung_l1
underlying_switch_1: null
underlying_switch_2: null
underlying_switch_3: null
on_percent: 0
power_percent: 0
on_time_sec: 0
off_time_sec: 300
cycle_min: 5
function: tpi
tpi_coef_int: null
tpi_coef_ext: null
friendly_name: Wohnzimmer - Hinten
supported_features: 385

Debug log

2024-09-27 06:30:40.445 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved (None) Traceback (most recent call last): File "/config/custom_components/versatile_thermostat/init.py", line 110, in _async_startup_internal await api.init_vtherm_links() File "/config/custom_components/versatile_thermostat/vtherm_api.py", line 178, in init_vtherm_links await entity.async_startup(self.find_central_configuration()) File "/config/custom_components/versatile_thermostat/base_thermostat.py", line 665, in async_startup await self.init_presets(central_configuration) File "/config/custom_components/versatile_thermostat/base_thermostat.py", line 2808, in init_presets await self._async_set_preset_mode_internal(self._attr_preset_mode, True) File "/config/custom_components/versatile_thermostat/base_thermostat.py", line 1341, in _async_set_preset_mode_internal self.recalculate() File "/config/custom_components/versatile_thermostat/thermostat_switch.py", line 182, in recalculate self._prop_algorithm.calculate( File "/config/custom_components/versatile_thermostat/prop_algorithm.py", line 87, in calculate self._tpi_coef_int * delta_temp

2024-09-27 07:11:24.669 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved (None) Traceback (most recent call last): File "/config/custom_components/versatile_thermostat/base_thermostat.py", line 1495, in _async_temperature_changed self.recalculate() File "/config/custom_components/versatile_thermostat/thermostat_switch.py", line 182, in recalculate self._prop_algorithm.calculate( File "/config/custom_components/versatile_thermostat/prop_algorithm.py", line 87, in calculate self._tpi_coef_int * delta_temp


TypeError: unsupported operand type(s) for *: 'NoneType' and 'float'

2024-09-27 10:45:39.967 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry Wohnzimmer - Vorne for versatile_thermostat
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 604, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/versatile_thermostat/__init__.py", line 165, in async_setup_entry
    await api.init_vtherm_links()
  File "/config/custom_components/versatile_thermostat/vtherm_api.py", line 178, in init_vtherm_links
    await entity.async_startup(self.find_central_configuration())
  File "/config/custom_components/versatile_thermostat/base_thermostat.py", line 665, in async_startup
    await self.init_presets(central_configuration)
  File "/config/custom_components/versatile_thermostat/base_thermostat.py", line 2808, in init_presets
    await self._async_set_preset_mode_internal(self._attr_preset_mode, True)
  File "/config/custom_components/versatile_thermostat/base_thermostat.py", line 1341, in _async_set_preset_mode_internal
    self.recalculate()
  File "/config/custom_components/versatile_thermostat/thermostat_switch.py", line 182, in recalculate
    self._prop_algorithm.calculate(
  File "/config/custom_components/versatile_thermostat/prop_algorithm.py", line 87, in calculate
    self._tpi_coef_int * delta_temp
    ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
TypeError: unsupported operand type(s) for *: 'NoneType' and 'float'
jmcollin78 commented 1 month ago

Hello, It seems that you don't configure the TPI coefficients. You will find this coefficients in the configuration page. Please check the values and set it if not already set (default values are : 0.6 and 0.01). Please note that, there is a bug in the HA UI which prevent to type 0.01, you have to copy/paste the value.

tpi_coef_int: null
tpi_coef_ext: null

This should not be possible. Can you explain how you manage to get into this case ?

Moreover, I notice that you don't have any temperature set. Please check if it is normal:

frost_temp: 0
eco_temp: 0
boost_temp: 0
comfort_temp: 0
frost_away_temp: 0
eco_away_temp: 0
boost_away_temp: 0
comfort_away_temp: 0

and nor

Jadefalcon100 commented 1 month ago

Hi, I do not get the two fields during setup. Just a checkbox for using central configuration. Screenshot_20240927-232425 The same with Presets. Just the checkbox. When unchecked it does not display the input fields

Jadefalcon100 commented 1 month ago

Sorry, closed issue accidentally

jmcollin78 commented 1 month ago

I will try to reproduce this case. Do you have a central configuration ? Can you post me the attribute of your central configuration VTherm please ? (Dev Tools/State)

jmcollin78 commented 1 month ago

I try your case:

  1. First I create a over_switch VTHERM,

Capture d’écran 2024-09-29 à 08 49 05

  1. then I click on 'TPI parameters'. The checkbox is checked by default:

Capture d’écran 2024-09-29 à 08 50 02

  1. When I uncheck the checkbox and click validate, I have this:

Capture d’écran 2024-09-29 à 08 50 45

  1. then, coeffs are mandatory, I cannot remove them.

Can you please try to reproduce the case on your side and give me the steps. I will continue but it seems to work as expected.

jmcollin78 commented 1 month ago

I read carefully the first post and if I understand well, after restart all is fine and the issue occurs when you try to change a parameter. And then all your HA is blocked.

I think this is not possible for an integration like Versatile Thermostat do totally block HA. At worst, you have some error logs, but I never see, and I can't imagine this will totally block HA.

Si what I think now, is that you have another system error on your HA (maybe hard drive failure or something like that) that makes HA not able to read the configuration at random time.

Is it only VTherm that have trouble or many others integrations ? I guess you can search in the log for other errors before VTherm ones.

Are you on a PI with a SDCard ? If yes, it is known to have failure, specially after one or two years and you may have to switch on an SSD.

jmcollin78 commented 1 month ago

I add some test to prevent too much logs when this occurs: https://github.com/jmcollin78/versatile_thermostat/pull/512

I have published a beta release, if you want to give it a try: https://github.com/jmcollin78/versatile_thermostat/releases/tag/6.3.0.beta2

Jadefalcon100 commented 1 month ago

I think, I found the issue: Meanwhile I created a central configuration, new VTherms do NOT crash after "All done". So everything seems fine now.

But before (without the central configuration) the checkboxes for TPI and Preset are set by default "use central configuration" which I did not change. Then the VTherm/HA stalled with the very first screenshot.

I don't want to mess my current productive setup by deleting the central configuration, so I cannot reproduce it right now.

HA ist running as a VM on a Proxmox Server. Very stable setup until now ;-)

jmcollin78 commented 1 month ago

Thank you for your report. Just to be sure, with 6.3.0, is this bug fixed ? I close it, don't hesitate to re-open if needed.