Persistence threshold values


Is it possible to place a threshold on values that can be persisted? I have an energy meter on the washing machine, but the washer is forever fluctuating between 0W and 1W over time. Is it possible to configure persistence so that it wont record changes below 1W for example? Alternatively, would it be possible to convert all below 1W values to 0W before they are persisted?

Thanks for the help


Not directly but you can do it indirectly.

Keep your Item that receives the values but create another Item.

Number ActualReadings
Number FilteredReadings

Put FilteredReadings in your persistence.

Create a rule that triggers when ActualReadings is updated and post an update to FilteredReadings after filtering the data.

rule "Filter power readings"
    Item ActualReadings received update
    // Ignore updates that are below 1w
    if(ActualReadings.state as DecimalType > 1) FilteredReadings.postUpdate(ActualReadings.state)

    // Convert updates that are below 1w to 0
    FilteredReadings.postUpdate(if(ActualReadings.state as DecimalType > 1) ActualReadings.state else 0)

I’m sure there are alternative approaches but this is probably the most straight forward.