So finally managed to put in it:
rule "TemperatureFilter_gf_cupboard1 filter rule" when Item gf_cupboard1_temperature_sensor changed then var Number difference if (gf_cupboard1_temperature.state != Uninitialized) { difference = Math::abs((gf_cupboard1_temperature.state as DecimalType).floatValue) - ((gf_cupboard1_temperature_sensor.state as DecimalType).floatValue) logWarn("gf_cupboard1_temperature", "sensor value difference = "+ difference) if (difference < 5) { logWarn("gf_cupboard1_temperature", "Posting update as difference < 5") gf_cupboard1_temperature.postUpdate(gf_cupboard1_temperature_sensor.state) } else logWarn("gf_cupboard1_temperature", "Discarding Difference as > 5") } else { logWarn("gf_cupboard1_temperature", "gf_cupboard1_temperature.state is null, posting " + gf_cupboard1_temperature_sensor.state) gf_cupboard1_temperature.postUpdate(gf_cupboard1_temperature_sensor.state) } end
Interestingly though I log the diffrence variable, and it still seems to post negatives. I thought that was the point of the Math::abs?
2016-08-03 22:33:58.850 [WARN ] [o.m.s.gf_cupboard1_temperature] - sensor value difference = -0.10000038
2016-08-03 22:33:58.860 [WARN ] [o.m.s.gf_cupboard1_temperature] - Posting update as difference < 5
2016-08-03 22:35:36.064 [WARN ] [o.m.s.gf_cupboard1_temperature] - sensor value difference = -0.10000038
2016-08-03 22:35:36.067 [WARN ] [o.m.s.gf_cupboard1_temperature] - Posting update as difference < 5