The number doesn't match the graph - what am I missing?

I’ve been fiddling with this all morning but I can’t see what I’m missing. Being at home all this time means I’m adding things to HAss that I’ve meant to for ages. So one of those things is a sensor to count how many people are at home. I’ve got this based on things I’ve found on here and with Google which seems to work fine…

- platform: template
  sensors:
    people_away:
      entity_id:
        - person.steve
        - person.[wife]
        - person.[child1]
        - person.[child2]
        - person.[child3]
      friendly_name: "People Away"
      unit_of_measurement: 'away'
      value_template: >
        {{ states.person | selectattr('state','ne','home') | list | count }}

Obviously the names are edited for this post but it would be so much easier if they were their actual names. Anyway - the front end currently shows this as the wife has gone to work (she’s a key worker before anyone complains).

Screenshot 2020-04-03 at 13.21.31

Exactly what you’d expect. But if I click on either of them I get this

This line never budges. Another weird thing I’ve noticed is that it says “14 hours” which I assumed was the last time HA detected a state change. However, 14 hours ago (11:30pm local time) everyone was at home and it correctly said 5. [wife] left at 8am when the UI updated the number.

It’s not important, it’s just annoying. Do I need to specifically tell something (Recorder, History etc) to record this data? That isn’t a logical conclusion because it’s obviously recording 5 and 0 somewhere but I’m running out of things to prod.

Thanks

Steve

nope. if recorder does not record data, you won’t see any graphs at all, just “No history found”.

have you tried to set unit_of_measurement and device_class properly?

Everything looks good (in regards to configuration). Does your time on the bottom bar look correct or is it off?

No - the time is correct. I took the screenshots before I posted this at 1:34 pm BST so at the time the x axis stops. Still correct now 2:12pm BST - which is an observation I’m making for my own peace of mind :slight_smile:

if you go to the history tab, is it correct there?

Yes, but you gave me an idea. I converted my sensor to a package and explicitly added

history:
  include:
    entities:
      - sensor.people_away
      - sensor.people_home

recorder:
  include:
    entities:
      - sensor.people_away
      - sensor.people_home      

And that seems to have fixed it. Weird.

Yes, I’d say you ran into a bug.

EDIT:
unless you weren’t recording these values.

A bug? In Home Assistant? I only use it because it’s bug free. :slight_smile:

unless you weren’t recording these values.

That was what I didn’t get (mentioned in my first post) - if I wasn’t recording the values at all what was it drawing the graph with?

It shouldn’t have! So, you ran into a bug in some way.