How to persist only certain value change

Hi folks,

I have a zigbee temperature sensor which updates quite often. Even if the value change is only 0,01 degree. If I persist every change it would came up with quite lot of data.
My idea: only persist if the value chage is at least 0,1 degree. How can I do it?

I’m using mysql and if its matters zigbee2mqtt for the sensor

To much data for logs or mysql?

There may be a way to adjust the the sensor via your ymal file check the zigbee2mqtt doc’s. If you just want less in your logs you can exclude the temp in logs. Other way would be to make a rule to round the number and send to a proxy item then log the proxy item in mysql.

Rule example:

rule “Round Temperature Sensor”
when
Item Temperature received update
then
if (Temperature.state != NULL){
val roundedNumber = (Math::round((Temperature.state as DecimalType).floatValue()* 10)).floatValue() /10
sendCommand(Temperature_rounded,roundedNumber)
}
end

Another proxy :rofl:

I’d like to reduce the data points in the mysql database. I’m a fan of slim storage. And i don’t belive in a 0,01 presision of a 10€ sensor.:wink:

But i have to admit, I’m a zigbee2mqtt beginner.
I’ll try to figure out the Settings in the ymal file.

1 Like

Only store the rounded proxy item in database but always best to resolve these issues at the device when possible.:wink:

May be I have some look and some one here uses this sensor and can give me a hint for ymal Settings:
Aqara WSDCGQ11LM

Have a look at the zigee2mqtt site https://www.zigbee2mqtt.io/#getting-started

Then instead of declaring persistence strategies in *.persist files, omit that and use item.persist() where applicable (i.e. after checking it’s substantially different from the previous value).

3 Likes

Now I’m zigbee2mqtt beginner + :upside_down_face:
I’ve changed the settings of the sensor in the configuration.ymal. Now data changes with the precision of 0.1degree.

1 Like