core: History Graph card not rendering some entities

The problem

The history-graph card says “loading state history” but doesn’t load the entities for some entities. The entities themselves have no problem showing their history when clicked on their own. I’ve tried it with multiple browsers, computers, and from the mobile app. It seems to only affect some of the entities, but I haven’t seen an obvious pattern of which ones. Sometimes, it works fine (and persists across refreshes of the page) and other times from the same device it doesn’t (and also persists not working across refreshes of the page).

Card as seen on front end: StateHistoryIssue

Card as seen when editing: StateHistoryCardState

Same entity showing history with no problems: StateHistoryEntityState

When loading a page that has an affected card, the below error appears in the log:

Logger: homeassistant.components.websocket_api.http.connection
  Source: components/history/websocket_api.py:242
  Integration: Home Assistant WebSocket API (documentation, issues)
  First occurred: 10:25:28 PM (6 occurrences)
  Last logged: 10:25:32 PM
  
  [140480700928000] Error handling message: Unknown error (unknown_error) RedactedUser from 192.168.10.230 (Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/113.0)
  [140480398423472] Error handling message: Unknown error (unknown_error) RedactedUser from 192.168.10.230 (Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/113.0)
  Traceback (most recent call last):
    File "/usr/src/homeassistant/homeassistant/components/websocket_api/decorators.py", line 26, in _handle_async_response
      await func(hass, connection, msg)
    File "/usr/src/homeassistant/homeassistant/components/history/websocket_api.py", line 524, in ws_stream
      last_event_time = await _async_send_historical_states(
    File "/usr/src/homeassistant/homeassistant/components/history/websocket_api.py", line 279, in _async_send_historical_states
      last_time_ts, last_time_dt, payload = await instance.async_add_executor_job(
    File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
      result = self.fn(*self.args, **self.kwargs)
    File "/usr/src/homeassistant/homeassistant/components/history/websocket_api.py", line 242, in _generate_historical_response
      and (state_last_time := state_list[-1][COMPRESSED_STATE_LAST_UPDATED])
  TypeError: '>' not supported between instances of 'NoneType' and 'float'


I created issue 16571 on the frontend repo since this was an issue with the UI not displaying, but they redirected me here after seeing the stack trace.

What version of Home Assistant Core has the issue?

core-2023.5.3

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

websocket_api

Link to integration documentation on our website

https://www.home-assistant.io/integrations/websocket_api/

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

Logger: homeassistant.components.websocket_api.http.connection
  Source: components/history/websocket_api.py:242
  Integration: Home Assistant WebSocket API (documentation, issues)
  First occurred: 10:25:28 PM (6 occurrences)
  Last logged: 10:25:32 PM
  
  [140480700928000] Error handling message: Unknown error (unknown_error) RedactedUser from 192.168.10.230 (Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/113.0)
  [140480398423472] Error handling message: Unknown error (unknown_error) RedactedUser from 192.168.10.230 (Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/113.0)
  Traceback (most recent call last):
    File "/usr/src/homeassistant/homeassistant/components/websocket_api/decorators.py", line 26, in _handle_async_response
      await func(hass, connection, msg)
    File "/usr/src/homeassistant/homeassistant/components/history/websocket_api.py", line 524, in ws_stream
      last_event_time = await _async_send_historical_states(
    File "/usr/src/homeassistant/homeassistant/components/history/websocket_api.py", line 279, in _async_send_historical_states
      last_time_ts, last_time_dt, payload = await instance.async_add_executor_job(
    File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
      result = self.fn(*self.args, **self.kwargs)
    File "/usr/src/homeassistant/homeassistant/components/history/websocket_api.py", line 242, in _generate_historical_response
      and (state_last_time := state_list[-1][COMPRESSED_STATE_LAST_UPDATED])
  TypeError: '>' not supported between instances of 'NoneType' and 'float'


Additional information

No response

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 29 (16 by maintainers)

Commits related to this issue

Most upvoted comments

Thanks a lot, I confirm it fixes the issue.