home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
72.55k stars 30.35k forks source link

Enabling Recorder breaks other integrations #103838

Closed viiliainen closed 11 months ago

viiliainen commented 11 months ago

The problem

After restart following errors occur. Last ones for "ValueError: Sensor sensor.lenovo_tb_x606f_battery_state.." will naturally disappear if disabling that device, but Recorder initialization errors remain.

Recorder Database is also container and seems to be working fine.. system is storing data there.

I have tried with and without include list, same result. Previously I had HA version from August and it did the same. It somehow breaks the initialization of the system and some integrations stops working, like Sonoff.

What version of Home Assistant Core has the issue?

2023.11.2

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Container

Integration causing the issue

Recorder

Link to integration documentation on our website

No response

Diagnostics information

No response

Example YAML snippet

recorder:
  purge_keep_days: 30
  auto_purge: true
  db_url: mysql://xxxxxxxxx:********@mariadb_HA:3306/HomeAssistant?charset=utf8mb4_unicode_ci
  include:
    entities:
      - sensor.shf_electricity_price_now
      - sensor.netatmo_sisailma_co2
      - sensor.netatmo_sisailma_humidity
      - sensor.netatmo_sisailma_temperature

Anything in the logs that might be useful for us?

Logger: homeassistant.setup
Source: setup.py:185
First occurred: 11.40.59 (5 occurrences)
Last logged: 11.41.10

Setup failed for recorder: Integration failed to initialize.
Setup failed for history: (DependencyError(...), 'Could not setup dependencies: recorder')
Setup failed for logbook: (DependencyError(...), 'Could not setup dependencies: recorder')
Setup failed for energy: (DependencyError(...), 'Could not setup dependencies: history, recorder')
Setup failed for default_config: (DependencyError(...), 'Could not setup dependencies: energy, history, logbook')

Logger: homeassistant.setup
Source: setup.py:159
First occurred: 11.41.03 (4 occurrences)
Last logged: 11.41.10

Unable to set up dependencies of history. Setup failed for dependencies: recorder
Unable to set up dependencies of logbook. Setup failed for dependencies: recorder
Unable to set up dependencies of energy. Setup failed for dependencies: history, recorder
Unable to set up dependencies of default_config. Setup failed for dependencies: energy, history, logbook

Logger: homeassistant.components.sensor
Source: helpers/entity_platform.py:367
Integration: Sensori (documentation, issues)
First occurred: 11.41.10 (1 occurrences)
Last logged: 11.41.10

Error while setting up mobile_app platform for sensor
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 616, in state
    numerical_value = int(value)
                      ^^^^^^^^^^
ValueError: invalid literal for int() with base 10: 'discharging'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 619, in state
    numerical_value = float(value)
                      ^^^^^^^^^^^^
ValueError: could not convert string to float: 'discharging'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 367, in _async_setup_platform
    await asyncio.gather(*pending)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 507, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 752, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1023, in add_to_platform_finish
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 743, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 843, in _async_write_ha_state
    state, attr = self._async_generate_attributes()
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 784, in _async_generate_attributes
    state = self._stringify_state(available)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 749, in _stringify_state
    if (state := self.state) is None:
                 ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 623, in state
    raise ValueError(
ValueError: Sensor sensor.lenovo_tb_x606f_battery_state has device class 'battery', state class 'None' unit 'None' and suggested precision 'None' thus indicating it has a numeric value; however, it has the non-numeric value: 'discharging' (<class 'str'>)

Logger: homeassistant.components.sensor
Source: helpers/entity_platform.py:507
Integration: Sensori (documentation, issues)
First occurred: 11.41.10 (1 occurrences)
Last logged: 11.41.10

Error adding entities for domain sensor with platform mobile_app
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 616, in state
    numerical_value = int(value)
                      ^^^^^^^^^^
ValueError: invalid literal for int() with base 10: 'discharging'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 619, in state
    numerical_value = float(value)
                      ^^^^^^^^^^^^
ValueError: could not convert string to float: 'discharging'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 507, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 752, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1023, in add_to_platform_finish
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 743, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 843, in _async_write_ha_state
    state, attr = self._async_generate_attributes()
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 784, in _async_generate_attributes
    state = self._stringify_state(available)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 749, in _stringify_state
    if (state := self.state) is None:
                 ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 623, in state
    raise ValueError(
ValueError: Sensor sensor.lenovo_tb_x606f_battery_state has device class 'battery', state class 'None' unit 'None' and suggested precision 'None' thus indicating it has a numeric value; however, it has the non-numeric value: 'discharging' (<class 'str'>)

Additional information

No response

mib1185 commented 11 months ago

Which integration provides the sensor.lenovo_tb_x606f_battery_state ?

viiliainen commented 11 months ago

Mobile. Its just Lenovo tablet. If I disable that device that error disappears but others remain.

mib1185 commented 11 months ago

ok, than you might want to open a separate issue report about this sensor.

about the issue with the recorder, please provide the full home-assistant.log

viiliainen commented 11 months ago

Okay.. And today restarting system with recorder enabled could not reproduce same errors. Recorder updated database and seems to be working fine now. No other changes from yesterday. Tried~20 times with different combinations. No errors on log allthough not all integrations worked on all rounds.. I'll close this now and open new if/when have again some errors to show.