jmcollin78 / versatile_thermostat

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

Entities not jet ready when restarting home assistant #323

Closed LennardPlay closed 10 months ago

LennardPlay commented 10 months ago

My VTherm attributes are the following:

min_temp: 7
max_temp: 35
preset_modes: none, frost, eco, comfort, boost
current_temperature: 20.9
temperature: 21
preset_mode: comfort
friendly_name: Wohnzimmer Heizung
supported_features: 17
is_on: true
hvac_mode: heat
is_controlled_by_central_mode: true
frost_temp: 10
eco_temp: 18
boost_temp: 23
comfort_temp: 21
frost_away_temp: 10
eco_away_temp: 17
boost_away_temp: 20
comfort_away_temp: 19
power_temp: 13
target_temperature_step: null
ac_mode: false
saved_preset_mode: comfort
saved_target_temp: 21
window_state: off
window_auto_state: off
window_bypass_state: false
security_delay_min: 60
security_min_on_percent: 0.5
security_default_on_percent: 0.1
last_temperature_datetime: 2024-01-07T10:14:37.488936+01:00
last_ext_temperature_datetime: 2024-01-07T10:01:58.985302+01:00
security_state: false
minimal_activation_delay_sec: 10
device_power: 1
total_energy: 0.05
last_update_datetime: 2024-01-07T10:15:31.650875+01:00
timezone: Europe/Berlin
window_sensor_entity_id: binary_sensor.wohnzimmer_fenster_offnet
window_delay_sec: 0
window_auto_enabled: true
window_auto_open_threshold: 1
window_auto_close_threshold: 0
window_auto_max_duration: 60
temperature_unit: °C
is_device_active: true
ema_temp: 20.85
is_over_climate: true
underlying_climate_0: climate.wohnzimmer_thermostat
is_regulated: true
regulated_target_temperature: 22
auto_regulation_mode: auto_regulation_light
regulation_accumulated_error: 0.3000000000000007
auto_fan_mode: auto_fan_none
start_hvac_action_date: 2024-01-07T10:15:01.040485+01:00
hvac_action: heating
last_central_mode: Auto
ext_current_temperature: 0
current_auto_fan_mode: auto_fan_none

Describe the bug

When restarting home Assistant I get multiple errors, because some entities (like my bluetooth thermometer) aren't ready yet.

Dieser Fehler wurde von einer benutzerdefinierten Integration verursacht

Logger: custom_components.versatile_thermostat.underlyings
Source: custom_components/versatile_thermostat/underlyings.py:467
Integration: Versatile Thermostat (documentation, issues)
First occurred: 10:01:35 (2 occurrences)
Last logged: 10:01:35

VersatileThermostat-Wohnzimmer-climate.wohnzimmer_thermostat - Cannot find the underlying climate entity: climate.wohnzimmer_thermostat. Thermostat will not be operational
Dieser Fehler wurde von einer benutzerdefinierten Integration verursacht

Logger: custom_components.versatile_thermostat.commons
Source: custom_components/versatile_thermostat/commons.py:125
Integration: Versatile Thermostat (documentation, issues)
First occurred: 10:01:30 (36 occurrences)
Last logged: 10:01:31

<entity sensor.schlafzimmer_heizung_last_external_temperature_date=unknown> - no entity to listen. Try later
<entity sensor.schlafzimmer_heizung_temperature_slope=unknown> - no entity to listen. Try later
<entity sensor.schlafzimmer_heizung_ema_temperature=unknown> - no entity to listen. Try later
<entity sensor.schlafzimmer_heizung_energy=unknown> - no entity to listen. Try later
<entity sensor.schlafzimmer_heizung_regulated_temperature=unknown> - no entity to listen. Try later

I think setting up a startup delay might avoid cluttering the home assistant logs.

maia commented 10 months ago

The difficult question is how long that delay should be. My thread network with all the Homekit Eve Thermo TRVs takes about 5 minutes to recreate (as some TRVs need to connect to a router that needs to connect to another router and only that second router connects to the border router). Other people might be up and running within 30 seconds.

jmcollin78 commented 10 months ago

Hello, this is normal at startup and you can forget it if those messages don't persists. Once HA is totaly started up, those messages should not be present. Else, you have a problem.

LennardPlay commented 10 months ago

They only occur on startup and don't repeat after that (all errors are occuring within one second). Waiting a few seconds for integrations like zha to setup would be more elegant.

jmcollin78 commented 10 months ago

I try to wait a few second, but sometimes it is a few seconds, sometimes 30 sec, sometimes a few minutes, ... It depends of the startup order of the integration and cannot be determinist. So to avoid to penalize everobidy with the worst case, I just add a warning and retry periodically. You can remove the warning if it is a problem for you (see the Logger integration).

LennardPlay commented 10 months ago

Allright, thanks for clearing up, now I know to not stress about these warnings at startup. Thank you for your response and all the hard work you put into this project :)