home-assistant / frontend

:lollipop: Frontend for Home Assistant
https://demo.home-assistant.io
Other
3.8k stars 2.6k forks source link

History Graph card not rendering some entities #16571

Closed K-Money closed 1 year ago

K-Money commented 1 year ago

Checklist

Describe the issue you are experiencing

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'

Describe the behavior you expected

Expected to see the state history on the card.

Steps to reproduce the issue

  1. Load a page that has a history-graph card.
  2. ...

What version of Home Assistant Core has the issue?

2023.5.3

What was the last working version of Home Assistant Core?

No response

In which browser are you experiencing the issue with?

Mozilla Firefox 113.0.1, also Google Chrome 113.0.5672.93

Which operating system are you using to run this browser?

Microsoft Windows Home 10 Version 10.0.19044 Build 19044

State of relevant entities

No response

Problem-relevant frontend configuration

No response

Javascript errors shown in your browser console/inspector

No response

Additional information

No response

karwosts commented 1 year ago

I would suggest opening an issue in the core repo against the history integration. That call stack is coming from core and suggests it is not able to provide the history data to the frontend.