I am experimenting with it using two sensors but the graph that the card shows seems to bear no relation to the graph shown in the ‘more info’ pop-up. Please see below for examples (I keep 24 hours of history).

Furthermore irrespective of how I configure the card I always get a flat line for the first half of the graph. Is that by design (if so why?) because the image in the docs shows this too.

Just remember that by default it’ll show the last 24h (hours_to_show). Do you have data for the last 24h?
Also by default it displays only 10 data points (accuracy)

@lolouk44
Yes, I have 24 hours of data as can be seen by the ‘more info’ graph and I have experimented with all sorts of number of data points right up to 5000.

I don’t understand why the graphs bear no relation to each other.

EDIT: I just found out that the accuracy: isn’t really well named. It is better described by the description(!) in that it is simply the number of points displayed. If it doesn’t have enough points it does the flat line rather than graphing as many as it can up to the number defined in accuracy: Not that useful when you don’t know how many data points there will be in a given time.

[And as an aside, do you have a gauge and a sensor on the same card there? If so how do you do that?]

the gauge and sensor cards are 2 cards in a vertical stack, but I use the custom vertical stack to remove the frames to make it look like a single card:

So how do you get the most ‘accurate’ representation of the ‘more info’ graph on the sensor card? I already tested various accuray: values from 10 up to 500, but none of it seems to fit very well. At some point, half of the graph is always a straight line when increasing accuracy.

What exactly is the hours_to_show: setting for when it doesn’t show the configured timespan over the whole width of card, but just half of it? Also, 3 of my 4 sensor cards always show a ‘spike’ at the end of the line, even if there isn’t any increase at the end of the ‘more info’ history graph. Can’t really figure this out.

This function appears to use a method called moving average. Lower the number, the more accurate graph. I.E. 1 will be 1 point to 1. 10 will be 10 points to 1. I.E the graph will use 5 points before and after to make a single point in the simple graph.

The side affect of a moving average filter is rounded corners when they should be sharp.

EDIT: Actually, the input is not as smart. It is using moving average but you can’t specify it by lowering the number.

If you want to get 1 to 1, you need to find out the number of data points over 24 hours and place that number into the accuracy spot.

Yeah, accuracy: 1 gives you a straight line, accuracy: 2 a line between 2 points and so on.

Counting the data points over the time period seems to work best, the only problem is that some sensors like the Xiaomi Temperature & Humidity sensor only report a new value if there is a significant change, which means that the amount of data points isn’t always the same within the last 24 hours.

EDIT: I think it would be a lot more useful if the line just showed the exact graph over the set period of time, with the possibility to configure the level of ‘smoothness’ via the accuracy setting.

Well that’s how moving average should work. I’m not sure why the guy built it that way. Typically you specify how many points you want to be averaging. The way he wrote it was ‘this is the desired number of points I want’. Counter intuitive to be honest.

Yes, but still : accuracy 1 gives a flat line, accuracy 500 (or 5000 or 50000) still shows a flat line in the first part. See the example, red sensor with details opened, green sensor behaves the same.

Once per minute is: 1440
Twice per minute is: 2880

Have you tried either of those numbers?

It’s possible that if you specify 5000 data points that it will give you 5000 no matter what. It can’t make up data so it probably places the data in front.

This is why I said ‘accuracy’ is poorly implemented. It should be x number of points = x number of points. I.e if you place a 1 in accuracy it maintains a 1 to 1 ratio.

There are bugs in it I guess. But lovelace is beta no ? I’ve only tried it or a few days, trying to achieve the same interface I have with legacy + customUI. Or even better, which the sensor card was supposed to be.

I use it in the “technical information” screen, it’s nice because you can put several sensors in the same graph, but way less pretty ! And doesn’t display the current value. Here I’m using it for my main screen, that I’d like to see on a wall-mounted tablet.

OK, so I debugged into the algorithm for the sensor card. Here are a few things to note:

You cannot supply more resolution than the number of data points collected. For example, If I have 4300 data points, and you put an accuracy of 5000, you will only get 4300 data points.

This is NOT averaging at all. This is filtering points out. Example: You have 600 datapoints, you have an accuracy of 6, you will get every 100th point. If that point happens to be a flier, so be it. It’s in your data. (not good practice for data analysis). EDIT: This will make the graph look NOTHING like your actual history. This is what @klogg, @sebastian_p are seeing.

If you have a lot of data points and you hit the max resolution you will encounter a bug. This is that flat line you see. Basically they try to find an increment to use and they end up doing math similar to 1000/999, which returns 1.0000x. They then ceiling this number, getting a result of 2 exactly. So later on in the function, they iterate over the whole list. Normally, they should be choosing every item. But because ceiling returned 2, they are choosing every second item. This then results in them choosing a default value for HALF of the data points that are beyond the length of the array, which results in a flat line in the beginning. This is what @klogg, @abmantis, and @Mister_Slowhand is seeing.

Thanks man, appreciate all the effort you are putting into this!

Sounds like a lot of things within the sensor card still need to be fixed/improved. Just filtering data points out isn’t really the way to go if you want an accurate repesentation of the graph. Maybe they did this instead of actual averaging because it would probably take a lot longer for the line to show up in the UI on slower systems?

Another thing that would be great is an option to hide the card title/icon, for instance if you have the temperature and humidity of the same room vertically stacked together, you don’t need the room name on every card.

Anyways, it would be amazing if we could get a functioning sensor card in the next few releases, still like the concept a lot!