Homeassistant.components.recorder.util: unsupported operand type(s) for +: 'NoneType' and 'float'

since october 26 I´ve issues at recorder and statistics - now idea why. I already tried several backups - no success until now. I use Home Assistant 2023.10.3, Supervisor 2023.10.1, Operating System 11.1, Frontend 20231005.0 - latest, recorder at MariaDB and influxDB for longterm.
the energy view is empty since that day, or let´s say in the meantime it worked after some reboots for some hours but it´s not working now. many (but not all) sensors stopped the trend view also at that time, but opening “more” works perfect.



at the protocol I found these two entries:
Logger: homeassistant.components.recorder.util
Source: components/recorder/util.py:130
Integration: Recorder (documentation, issues)
First occurred: 15:20:13 (8 occurrences)
Last logged: 15:50:10

Error executing query: unsupported operand type(s) for +: 'NoneType' and 'float'
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/recorder/util.py", line 130, in session_scope
    yield session
  File "/usr/src/homeassistant/homeassistant/components/recorder/statistics.py", line 454, in compile_missing_statistics
    modified_statistic_ids = _compile_statistics(
                             ^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/recorder/statistics.py", line 528, in _compile_statistics
    compiled: PlatformCompiledStatistics = platform_compile_statistics(
                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/sensor/recorder.py", line 462, in compile_statistics
    last_stats = statistics.get_latest_short_term_statistics_with_session(
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/recorder/statistics.py", line 1941, in get_latest_short_term_statistics_with_session
    return _sorted_statistics_to_dict(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/recorder/statistics.py", line 2110, in _sorted_statistics_to_dict
    "end": start_ts + table_duration_seconds,
           ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
TypeError: unsupported operand type(s) for +: 'NoneType' and 'float'

=============== and ==========

Logger: homeassistant.components.recorder.core
Source: components/recorder/core.py:893
Integration: Recorder (documentation, issues)
First occurred: 15:20:13 (8 occurrences)
Last logged: 15:50:10

Error while processing event StatisticsTask(start=datetime.datetime(2023, 10, 28, 13, 25, tzinfo=datetime.timezone.utc), fire_events=True): unsupported operand type(s) for +: 'NoneType' and 'float'
Error while processing event StatisticsTask(start=datetime.datetime(2023, 10, 28, 13, 30, tzinfo=datetime.timezone.utc), fire_events=True): unsupported operand type(s) for +: 'NoneType' and 'float'
Error while processing event StatisticsTask(start=datetime.datetime(2023, 10, 28, 13, 35, tzinfo=datetime.timezone.utc), fire_events=True): unsupported operand type(s) for +: 'NoneType' and 'float'
Error while processing event StatisticsTask(start=datetime.datetime(2023, 10, 28, 13, 40, tzinfo=datetime.timezone.utc), fire_events=True): unsupported operand type(s) for +: 'NoneType' and 'float'
Error while processing event StatisticsTask(start=datetime.datetime(2023, 10, 28, 13, 45, tzinfo=datetime.timezone.utc), fire_events=True): unsupported operand type(s) for +: 'NoneType' and 'float'
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/recorder/core.py", line 893, in _guarded_process_one_task_or_recover
    self._process_one_task_or_recover(task)
  File "/usr/src/homeassistant/homeassistant/components/recorder/core.py", line 904, in _process_one_task_or_recover
    return task.run(self)
           ^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/recorder/tasks.py", line 177, in run
    if statistics.compile_missing_statistics(instance):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/recorder/util.py", line 609, in wrapper
    return job(instance, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/recorder/statistics.py", line 454, in compile_missing_statistics
    modified_statistic_ids = _compile_statistics(
                             ^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/recorder/statistics.py", line 528, in _compile_statistics
    compiled: PlatformCompiledStatistics = platform_compile_statistics(
                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/sensor/recorder.py", line 462, in compile_statistics
    last_stats = statistics.get_latest_short_term_statistics_with_session(
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/recorder/statistics.py", line 1941, in get_latest_short_term_statistics_with_session
    return _sorted_statistics_to_dict(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/recorder/statistics.py", line 2110, in _sorted_statistics_to_dict
    "end": start_ts + table_duration_seconds,
           ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
TypeError: unsupported operand type(s) for +: 'NoneType' and 'float'

I see there are issues with operand types but why did they happen and how can I solve this?
hopefully someone can support me - thanks a lot :slight_smile:

Go to Developer Tools → Statistics. Are there any FIX ISSUE buttons?

sorry I forgot. yes, I already had a look there. when I try the entity of the screenshot it shows “no issues”. I already used this section in the past to modify energy values.

last updates at this date were phpmyadmin and studio code server => I already went back to the former versions, but didn´t fix the issues.

yesterday I tried several backups, also with new ssd + backup from some days back with older HA version => no succes. but today I tried it once again to upgrade from 10.3. to 10.5 and after the upgrade all issues were gone! recorder is ok now, all views work! crazy…

Hi,

i have the exact same issue as yours.
No problem in stats tab.
I am also on 2023.10.5 version but I still have this error :frowning:
Hopefully 2023.11.0 will fix it !

I have the same issue.

Lot’s of errors in the log as mentioned above.
Energy dashboard stopped updating.
Additionally after a reboot my old database gets replaced with a fresh one. The old database is renamed to home-assistant_v2.db.corrupt..

The log entries are rather nonspecific. No mention of an integration, device, entity.

I have also this same recorder issue

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/recorder/core.py", line 900, in _guarded_process_one_task_or_event_or_recover
    self._process_one_task_or_event_or_recover(task)
  File "/usr/src/homeassistant/homeassistant/components/recorder/core.py", line 920, in _process_one_task_or_event_or_recover
    return task.run(self)
           ^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/recorder/tasks.py", line 177, in run
    if statistics.compile_missing_statistics(instance):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/recorder/util.py", line 645, in wrapper
    return job(instance, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/recorder/statistics.py", line 471, in compile_missing_statistics
    modified_statistic_ids = _compile_statistics(
                             ^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/recorder/statistics.py", line 547, in _compile_statistics
    compiled: PlatformCompiledStatistics = platform_compile_statistics(
                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/sensor/recorder.py", line 467, in compile_statistics
    last_stats = statistics.get_latest_short_term_statistics_with_session(
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/recorder/statistics.py", line 1959, in get_latest_short_term_statistics_with_session
    return _sorted_statistics_to_dict(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/recorder/statistics.py", line 2128, in _sorted_statistics_to_dict
    "end": start_ts + table_duration_seconds,
           ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
TypeError: unsupported operand type(s) for +: 'NoneType' and 'float'

My HA was errorless for a month, but then, in some update, energy stopped receiving data and now my log is full of these. I have no clue of what to do.

I’m in the same position and have found

and

These both point to this code:

But I’ve had no joy on correcting the issue