Strange behaviour of ESPHOME Hum/Temp sensor and Grafana

Hi,
I am a newbie in this automation world.
I have the Grafana Addon (or integration) installed in homeassistant.
I’ve made a sensor with an ESP8266 and a HTU21d (also I am measuring the internal VCC as this is powered by a LiPo). The device is going for nap of 3 minutes… then wakes up for 20 seconds and take as much measurements every 5 seconds.
I made also a dashboard to plot those parameters over time
The system works, but I see a lot of inconsistencies in the data shown by Grafana, and reading by the ESPHome in the logs section.
Just to put an example, after a reset, in the ESPHOME logs, I see:
In the first cycle, it is sent 1 Vcc reading (at 21:24) and then the triplet of Temp/Hum/Vcc.
In the second cycle, six triplets has been send to HAS.

Then, if I go to grafana… I cannot find such measurements in the query…

For the first cycle, I find: 2 temp measurements, 6 humidity measurements, and 3 Vcc measurements.
I may understand that the logs are not reporting 100% of the communications between HAS and ESPHOME… so maybe in the background there are measurements not displayed in the logs.
But what confuses me, is the second cycle, as I can count: 1 Temp measurement, 4 humidity measurements, and none Vcc measurements… where the logs reported 6 measurements of all parameters.

I am also not familiar with Grafana, and I was trying to “see” the complete database, or to dump it to a CSV file to try to find the missing values… but I presume that the only way to interact with Grafana is through queries (the same way the panels does) so I expect that the result will be the same as the panel one.

What I am missing in this behaviour?
I attach a picture of my query on grafana (the one that miss more values)
Screenshot 2023-01-17 220033

I just check in the HAS History Tab… and the results are coherent with Grafana… seem that there is nothing in HAS:


So the problem seem to be a communication one between the integration of ESP home at HAS, and my device…
Any suggestions to increase the probability to end-up with values in the DB?

Are the values different for each reading or could the missing ones be the same value?
Grafana is a time-series database and it only records entities when they change. So if you have 5 readings of 20.0 degrees from 23:10 to 23:15 and then the temperature changes to 21.0 degrees at 23:16, Grafana only saves two entries: 23:10 - 20.0C, 23:16 - 21.0 degrees.
You then know that the temperature only changed at the point where it is recorded as being different.

Indeed, the temps are 8.0.xxxx to one decimal place. If the xxxx changes, they are still 8.0

Ah yes, I see that in the data now. Then it’s explained by what I described. :+1:

2 Likes

Yep, they are… thanks that’s the point.
So if I want to have always data displayed, I need to change my query to group by previous instead of the current null…
I will give a try.
Thanks for reply!

This was driving me crazy today. This fixed it for me too. TY.