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
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
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).