Prohibit persistence of bogus values

Hi.
Is there any way of telling OH not to persist if a reported value is zero? I’ve got a meter (a Qubino ZMNHXD1) that from time to time tells me that my entire house is currently using 0 watts of energy, which is obviously complete bogus. This is no big problem, but it makes my graphs look kinda weird, so I’d rather not persist those values at all.

The only way I can think of is to add another Item and let a rule copy over the value from the “real” meter Item to the new one as long as it’s not zero. And then persist that new Item instead. But that feels kinda like an ugly workaround…

Another ugly workaround would be to not configure the Item in your .persist file. Then create a Rule that triggers when it changes, check the value and if the value is reasonable call MyItem.persist. In short, you remove the automated persisting of the Item and only have your Rule persist. At least with this approach you don’t need another Item. You still need the Rule though.

2 Likes

Yep, that seems like a less ugly workaround :sunglasses:

It would be nice though if there was functionality to fine tune the persistence a bit more, like defining limits which the value would need to be within to actually be persisted. Often bogus values are easy to detect, either zero or absurdly high values (I’ve got a temperature sensor that once in a while tells me it’s over 5000 degrees Celsius here. I don’t believe it.)

I ended up with a simple rule doing this:

rule "persistOnEveryChange"
when
	Member of persistOnEveryChange changed
then
	if(triggeringItem.state > 0) {
		triggeringItem.persist
	}
end

(I guess I’d need to rename the group though to minimize future confusion, I guess it should now be named something like persistPositiveValuesOnEveryChange)