Lovelace - sensor card, does it work?

Yes thanks @petro.

What is slightly frustrating about this is that the original sensor-graph custom component seemed to work perfectly (although I actually found it after the official version was released I so only used it for a couple of days before I realised and then swapped).

What is doubly frustrating is the way official versions of original custom components often seem to be less functional than the custom component they replace. This is one and the button-entity is another.

There may be very good reasons for this but it is frustrating :neutral_face:

Thanks for digging into that.
BTW, where are the Lovelace component ? Didn’t find them in site-package, so ?

Point 1 : that’s why we see those behavior with variable input devices, like the xiaomi sensors. We don’t know how many data in 24h we’ll have. I thought I’d be safe increasing the number, wrong !
Point 2 : that’s why I had those curve totally off, I posted the screenshot #2
Point 3 : this was the most obvious error.

Well, I’ll leave it for now, expecting improvements in next versions.

Not sure why that is. Must be a fluke. The original card has the exact same function.

I don’t have a dev environment but I’m going to try to make it work. I know code very well, but i’ve never coded in JS. So that will be a challenge.

I’m not sure. The loop looks optimized. Typically math operations like that are fast so the trade off is negligible.

That’s a nice idea, Unfortunately, I know math. I do not know JS well. I know math and a little JS enough to make the change to the sensor graph but not enough to add new properties. I don’t understand a lot of the ‘glue’ that makes CSS, JS, and HTML work that I don’t understand.

Not sure where they are stored. The lovelace frontend is home-assistant-polymer. So i’d start looking around for phrases like that.

I’ve thought about this quite a bit and I’ve decided to avoid incorporating a moving average filter. The UI really shouldn’t be chugging away at math. I will however fix the flat line and you should now have the ability to get to a resolution of 1 to 1 (which was impossible before).

EDIT: Made the changes. Did not include a moving average. If you guys want an exact representation of your data, setting the accuracy to a very large number will give you that now. The flat line should also be gone.

I’m not sure when the PR will make it into the software.

5 Likes

Very nice, thanks !

Thank’s a lot!
Can you please share the link to your PR?

I’m afraid I have the same problem as the others. If the accuracy value is too high, the first half of the graph is a flat line, if the accuracy value is too low, the graph of the sensor card usually does not match the history graph anymore.

This has something of a trial and error :smiley:

Thanks man! Hopefully your changes make it into the public version soon!

I found the PR and I was expecting to test it, but in fact the JS are not as component, stored in a file.
You’ll find all that in a “chunk1234567890…js” file (or something as less readable as that…), that is in the site-packages/hass_frontend folder.

So I’ll be patient :wink:

Hey guys, I’m the author of the original custom mini-graph-card which I upon request contributed to the HA core as the sensor card.

When I initially made this card I didn’t have a ton of sensor data play around with. The implementation I ended up with was simple and seemed to work fairly well with the data the sensors I had at home provided me with.

But as discussed in this thread, the current implementation is not very elegant and flawed many ways.

I’ve worked on a new algorithm to calculate the data points for the line graph, which should solve issues discussed in this thread.
The new implementation would take moving average as well as the actual timestamps of the history entries into account. This should make the graph way more accurate and better represent the actual history, regardless of if the sensor data is updated sporadically or regularly.

However with this new implementation we would have to replace the accuracy option (which as mentioned is poorly named) with something like detail : 1 or 2, 1 for one data point every hour and 2 for one data point every 10 minute.

Here is the PR: https://github.com/home-assistant/home-assistant-polymer/pull/2069

4 Likes

Hey all,

I was wondering, since the 81.0 upgrade i’ve had an issue with sensor cards. They just flatline.
I can see the date changing but the graph just stays the same what so ever. Ex the outside temp went from -2 to 10 in less than 24h but nothing…

Was working ace before.

Capture2
Any ideas ?

You can see in the photos that the graph isn’t even on the right value.

Here is my lovelace code:

- id: 1  # Automatically created id
    title: Climate
    cards:
      - id: e898ade66e594a79ac25b1b50e726b90  # Automatically created id
        type: sensor
        entity: sensor.outside_temp
        name: Outside temperature
        line_color: '#3498db'
      - id: 10920511b6c042cca071585c1aaa54f6  # Automatically created id
        type: sensor
        entity: sensor.living_room_temp
        name: Living room temperature
        line_color: '#3498db'
      - id: 6a546b2353d44c6eae1ae36eb825d60f  # Automatically created id
        type: sensor
        entity: sensor.matt_bedroom_temperature
        name: Matthew's bedroom temperature
        line_color: '#3498db'
      - id: de38715b41d94f68a584eac15fabb330  # Automatically created id
        type: sensor
        entity: sensor.living_room_hum
        name: Living room humidity
      - id: ef8614374ab043609c55dac301ce74f0  # Automatically created id
        type: sensor
        entity: sensor.matt_bedroom_humidity
        name: Matthew's bedroom humidity
      - id: 00126b04f3a2411d8325eac86c9b5767  # Automatically created id
        type: sensor
        entity: sensor.outside_hum
        name: Outside humidity
      - id: c0de6f9066d64cff859842557eb561a0  # Automatically created id
        type: weather-forecast
        entity: weather.dark_sky
      - id: b71c8ac2d6a6429bae46975de76fd038  # Automatically created id
        type: sensor
        entity: sensor.outside_pressure
        name: Pressure
        line_color: '#db346e'
      - id: b7cb9521fea54081bba78e5c1f4f607f  # Automatically created id
        type: sensor
        entity: sensor.matt_bedroom_airquality
        name: Matthew's bedroom air quality
        line_color: '#56aa2f'
      - type: iframe
        url: https://embed.windy.com/embed2.html
        aspect_ratio: 150%
      - type: iframe
        url: https://embed.windy.com/embed2.html?lat=45.105&lon=4.417&zoom=6&level=surface&overlay=rain&menu=&message=&marker=&calendar=&pressure=true&type=map&location=coordinates&detail=&detailLat=45.768&detailLon=4.851&metricWind=default&metricTemp=default&radarRange=-1
        aspect_ratio: 150%
      - type: iframe
        url: https://embed.windy.com/embed2.html?lat=45.859&lon=4.812&zoom=6&level=surface&overlay=radar&menu=&message=&marker=&calendar=&pressure=true&type=map&location=coordinates&detail=&detailLat=45.768&detailLon=4.851&metricWind=default&metricTemp=default&radarRange=-1
        aspect_ratio: 150%
      - type: iframe
        url: https://embed.windy.com/embed2.html?lat=45.537&lon=4.801&zoom=7&level=surface&overlay=clouds&menu=&message=&marker=&calendar=&pressure=true&type=map&location=coordinates&detail=&detailLat=45.576&detailLon=4.614&metricWind=default&metricTemp=default&radarRange=-1
        aspect_ratio: 150%

Cheers,

Matthew

you’ll want to add graph: line to each card

Fwiw, my sensor cards are working without a graph: entry. I did have a few sensors flatline recently, but it turned out to be dead batteries.

Edit: Since going to 0.84.0b0 I did have to enter the “graph: line” bit for it to show. Thanks!

1 Like

Hello,

Thank you both for the heads up. But it doesn’t seem to work. If i restart the server it works for a couple hours then flat-lines. Could it be a db issue ? Whats is weird is that when i click on the graph, the line doesn’t correspond to the actual shown data.

Cheers,

Matthew

It does not have 1 to 1 matching of the history chart. If you want one to one, use a history chart card

Hello,

Indeed, it seems that all the history graphs are flat too. I’ll pop over to that that part of the forum.

Cheers,

Matthew

Hello
I’ve got some issues with sensor card. Why my mean temperature graph is so short, although all temperatures graphs are normal?

Does that sensor have history? If not, it won’t be complete.