Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

history-graph: contains entities which were NOT selected for the card #73155

Closed
3 tasks done
ildar170975 opened this issue Jun 3, 2022 · 30 comments · Fixed by #73191
Closed
3 tasks done

history-graph: contains entities which were NOT selected for the card #73155

ildar170975 opened this issue Jun 3, 2022 · 30 comments · Fixed by #73191

Comments

@ildar170975
Copy link

ildar170975 commented Jun 3, 2022

Checklist

  • I have updated to the latest available Home Assistant version.
  • I have cleared the cache of my browser.
  • I have tried a different browser to see if it is related to my browser.

Describe the issue you are experiencing

Create a history-graph with TWO entities:

  • sun.sun (which is supposed to be included in the Recorder)
  • any other entity (which was excluded from Recorder)

Let's create a sensor w/o a History:

template:
  - sensor:
      - name: service_zero_value
        icon: mdi:null
        state: '{{ "0" }}'
recorder:
  exclude:
    entity_globs:
      - sensor.service_zero_value

The card:

type: history-graph
entities:
  - entity: sun.sun
  - entity: sensor.service_zero_value
hours_to_show: 24

The output:
изображение

The card contains TWO same another entities - which were not selected.

Describe the behavior you expected

If some selected entity does not have a history - then it is NOT displayed on the graph.
No any other entities are displayed, except selected entities with a history.

Steps to reproduce the issue

  1. Create a sensor w/o history.
  2. Create a card.

What version of Home Assistant Core has the issue?

HA 2022.6.1

What was the last working version of Home Assistant Core?

No response

In which browser are you experiencing the issue with?

Chrome 102.0.5005.63

Which operating system are you using to run this browser?

Win10x64

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

@ildar170975
Copy link
Author

ildar170975 commented Jun 3, 2022

I may explain why I find this bug important.
I am using the history-graph with that "zero sensor w/o history" to create a decluttering template for a quick building graphs.
The history-graph in the template has several zero sensors which - if not replaced by non-zero sensors with history - are not displayed on the graph. By default the graph contains ONE non-zero sensor (i.e. "one graph"). You may specify more sensors for the card by input variables to show more sensors on the graph.
Now all my graphs have these 2 excessive sensors - because they are added due to the bug.

@bdraco
Copy link
Member

bdraco commented Jun 4, 2022

Here is what I get with your example card and configuration

Screen Shot 2022-06-03 at 14 22 16

@ildar170975
Copy link
Author

ildar170975 commented Jun 4, 2022

For me it seems very strange.
I am absolutely sure that right after update to HA 2022.6.1 there were no any excessive entities in the card.
But then - probably after several HA reboots - they appeared.

Here is one more horror picture:
изображение
This is my test page. Every card must contain TWO graphs for different binary_sensors (11 cards x 2 sensors).
And almost every card:

  • either contains ONLY these two same excessive sensors
  • or contains them additionally to correct sensors.

@bdraco
Copy link
Member

bdraco commented Jun 4, 2022

Can you open the network tab, watch the websocket, and paste the data you get back the from the history query?

@ildar170975
Copy link
Author

Can you open the network tab, watch the websocket

Sorry, cannot find this tab.
Here is what I only have:
изображение
Using HA in Docker.

@bdraco
Copy link
Member

bdraco commented Jun 4, 2022

Sorry, its the network tab in your browser's inspector. You may have to force reload once its open
Screen Shot 2022-06-03 at 14 34 05

@ildar170975
Copy link
Author

ildar170975 commented Jun 4, 2022

Cannot find it...
изображение
изображение

@bdraco
Copy link
Member

bdraco commented Jun 4, 2022

Click the arrows to the right of sources

@ildar170975
Copy link
Author

I found some Network view but it does not look like yours (see the post above)

@bdraco
Copy link
Member

bdraco commented Jun 4, 2022

You need to shift+reload to get it to appear

@ildar170975
Copy link
Author

ildar170975 commented Jun 4, 2022

While trying to find that Network page I probably made a mistake - I rebooted HA.
After reboot the glitch gone - so there is nothing to trace probably (or may be I am wrong).
I am afraid the glitch may come back.

If we can trace something now - please tell me what to do.
I found the page you described.

@bdraco
Copy link
Member

bdraco commented Jun 4, 2022

If it happens again please get a copy of the websocket response to the history api call

@ildar170975
Copy link
Author

Could you tell me how can I do it?
изображение
There are many messages.

paste the data you get back the from the history query?

What I did is:

  • wrote a "history" word into a filter field,
  • rows are filtered,
  • some rows are highlighted by green color

Shall I select each found row and save a data below?
изображение

@bdraco
Copy link
Member

bdraco commented Jun 4, 2022

You'll see an id in this case 31. If you look through the messages you'll find a response to id 31 which will have the history data.

When you find one that isn't working correctly find the request and then find the response by id

@ildar170975
Copy link
Author

Thank you very much for helping!
If the glitch repeats - I will try to post reports.

@bdraco
Copy link
Member

bdraco commented Jun 5, 2022

Can you post the YAML source to the panel you have displayed here #73155

I'm going to try to create similar entities to see if I can make it happen

@ildar170975
Copy link
Author

ildar170975 commented Jun 5, 2022

The view is masonry, a bit simplified view is:

- type: vertical-stack
  cards:
    - type: entities
      entities:
        - entity: binary_sensor.test_alert_life360_iphone_5s
          secondary_info: last-changed
        - entity: binary_sensor.test_alert_life360_test_iphone_5s
          secondary_info: last-changed
    - type: history-graph
      hours_to_show: 4
      entities:
        - entity: binary_sensor.test_alert_life360_iphone_5s
        - entity: binary_sensor.test_alert_life360_test_iphone_5s

- type: vertical-stack
  cards:
    - type: entities
      entities:
        - entity: binary_sensor.test_alert_life360_iphone_6
          secondary_info: last-changed
        - entity: binary_sensor.test_alert_life360_test_iphone_6
          secondary_info: last-changed
    - type: history-graph
      hours_to_show: 4
      entities:
        - entity: binary_sensor.test_alert_life360_iphone_6
        - entity: binary_sensor.test_alert_life360_test_iphone_6

- type: vertical-stack
  cards:
    - type: entities
      entities:
        - entity: binary_sensor.test_alert_life360_redmi_7a
          secondary_info: last-changed
        - entity: binary_sensor.test_alert_life360_test_redmi_7a
          secondary_info: last-changed
    - type: history-graph
      hours_to_show: 4
      entities:
        - entity: binary_sensor.test_alert_life360_redmi_7a
        - entity: binary_sensor.test_alert_life360_test_redmi_7a

- type: vertical-stack
  cards:
    - type: entities
      entities:
        - entity: binary_sensor.test_alert_life360_redmi_9a
          secondary_info: last-changed
        - entity: binary_sensor.test_alert_life360_test_redmi_9a
          secondary_info: last-changed
    - type: history-graph
      hours_to_show: 4
      entities:
        - entity: binary_sensor.test_alert_life360_redmi_9a
        - entity: binary_sensor.test_alert_life360_test_redmi_9a

- type: vertical-stack
  cards:
    - type: entities
      entities:
        - entity: binary_sensor.test_alert_life360_phone_galina
          secondary_info: last-changed
        - entity: binary_sensor.test_alert_life360_test_phone_galina
          secondary_info: last-changed
    - type: history-graph
      hours_to_show: 4
      entities:
        - entity: binary_sensor.test_alert_life360_phone_galina
        - entity: binary_sensor.test_alert_life360_test_phone_galina

- type: vertical-stack
  cards:
    - type: entities
      entities:
        - entity: binary_sensor.test_alert_life360_phone_boris
          secondary_info: last-changed
        - entity: binary_sensor.test_alert_life360_test_phone_boris
          secondary_info: last-changed
    - type: history-graph
      hours_to_show: 4
      entities:
        - entity: binary_sensor.test_alert_life360_phone_boris
        - entity: binary_sensor.test_alert_life360_test_phone_boris

- type: vertical-stack
  cards:
    - type: entities
      entities:
        - entity: binary_sensor.test_alert_life360_ipad_air_2
          secondary_info: last-changed
        - entity: binary_sensor.test_alert_life360_test_ipad_air_2
          secondary_info: last-changed
    - type: history-graph
      hours_to_show: 4
      entities:
        - entity: binary_sensor.test_alert_life360_ipad_air_2
        - entity: binary_sensor.test_alert_life360_test_ipad_air_2

- type: vertical-stack
  cards:
    - type: entities
      entities:
        - entity: binary_sensor.test_alert_life360_ipad_mini_2
          secondary_info: last-changed
        - entity: binary_sensor.test_alert_life360_test_ipad_mini_2
          secondary_info: last-changed
    - type: history-graph
      hours_to_show: 4
      entities:
        - entity: binary_sensor.test_alert_life360_ipad_mini_2
        - entity: binary_sensor.test_alert_life360_test_ipad_mini_2

- type: vertical-stack
  cards:
    - type: entities
      entities:
        - entity: binary_sensor.test_alert_life360_samsung_p6800
          secondary_info: last-changed
        - entity: binary_sensor.test_alert_life360_test_samsung_p6800
          secondary_info: last-changed
    - type: history-graph
      hours_to_show: 4
      entities:
        - entity: binary_sensor.test_alert_life360_samsung_p6800
        - entity: binary_sensor.test_alert_life360_test_samsung_p6800

To create dummy sensors, use this code generator (insert it into a "template" HA page, it will generate a code - copy/paste it into some yaml file):

{% set SETTINGS = [
  ("iphone_5s"),
  ("iphone_6"),
  ("redmi_7a"),
  ("redmi_9a"),
  ("phone_galina"),
  ("phone_boris"),
  ("ipad_air_2"),
  ("ipad_mini_2"),
  ("samsung_p6800")
] %}

{% set code_alerts = '
      - name: test_alert_life360_{0}
        state: "on"

      - name: test_alert_life360_test_{0}
        state: "off"
' %}

template:
  - binary_sensor:
{% for object in SETTINGS -%}
  {{ code_alerts.format(object) }}
{%- endfor %}

NO custom cards are needed.

@bdraco
Copy link
Member

bdraco commented Jun 5, 2022

Do you have a minimal replication case that doesn't require custom cards? I can't be sure I'm looking at the right issue unless we can reduce it down to the most minimal reproducible case.

@ildar170975
Copy link
Author

ildar170975 commented Jun 5, 2022

Yes, I changed a code.
There are 9 similar cards, paste them into an empty view.

The code generator is edited too since there is no need in sensor entities now.

@bdraco
Copy link
Member

bdraco commented Jun 5, 2022

Screen Shot 2022-06-04 at 19 15 58

I've got your test data up and running and I'm going to try it with every supported database

@bdraco
Copy link
Member

bdraco commented Jun 5, 2022

  • MariaDB
  • MySQL
  • PostgreSQL
  • SQLite

@bdraco
Copy link
Member

bdraco commented Jun 5, 2022

Its working as expected on all 4 DBMs, but I'll leave it turn in a tab in case something goes wrong and I can catch it

@bdraco
Copy link
Member

bdraco commented Jun 5, 2022

It's also possible I may have fixed this in one of the PRs that hasn't made it into a public release yet

@ildar170975
Copy link
Author

ildar170975 commented Jun 5, 2022

Thank you for testing! As I said before, the glitch once appeared, then it was occurring stable, then it disappeared after HA restart (w/o HA updates).
I am afraid it could be some erratic thing.

More facts:

  1. The glitch was ALWAYS occurring with these conditions - i.e. when one sensor w/o history is added:
type: history-graph
entities:
  - entity: sun.sun
  - entity: sensor.service_zero_value
hours_to_show: 24
  1. With this code the glitch did NOT occur:
type: history-graph
entities:
  - entity: sun.sun
hours_to_show: 24
  1. That "horror page" did NOT contain sensors w/o history - so it was strange for me how it became "contaminated".

@bdraco
Copy link
Member

bdraco commented Jun 5, 2022

This might be caused by home-assistant/frontend#12878 so let's wait to see if it happens again after that one gets released

@lmagyar
Copy link
Contributor

lmagyar commented Jun 7, 2022

Isn't it related to #72991 ?

One of the "failure modes" when history graph receives wrong data from the database? After restart bug disappears?

@bdraco
Copy link
Member

bdraco commented Jun 7, 2022

This sure looks like it has the same root cause as #72991

@bdraco bdraco transferred this issue from home-assistant/frontend Jun 7, 2022
@probot-home-assistant
Copy link

recorder documentation
recorder source
(message by IssueLinks)

@probot-home-assistant
Copy link

Hey there @home-assistant/core, mind taking a look at this issue as it has been labeled with an integration (recorder) you are listed as a code owner for? Thanks!
(message by CodeOwnersMention)

@ildar170975
Copy link
Author

After restart bug disappears?

Yes, I have not observed it so far.
P.S. Made 2-3 restarts since that incident.
HA in Docker, native mysql.

@github-actions github-actions bot locked and limited conversation to collaborators Jul 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants