[SOLVED] Events.log flooding

Thanks for this idea, I thought to try it this way first before potentially considering the regex filter approach.

After reading a tutorial on how-to-use-transformations and then some further research (due to slight changes between OH3 and OH4 as I understand, I could finally make it work. Thanks again so much for the code, it would have taken me quite some time to figure it out on my own.

As you instructed, I registered the code as a transformation in Settings → Transformations. Tranformation Type “JS”.
Saved that and then went to the according thing. Under Channels, I selected the channel and clicked on the linked item.
There I selected “SCRIPT ECMAScript (ECMAScript 262 Edition 11)” which seems to represent the former JS profile name (which was much easier to comprehend :wink: ).
Then select the script in the “thing to item transformation” and good-to-go :slight_smile:

P.S: I had to alter the code slightly. The if clause needs to trigger true for the last value being null. I therefore changed to check the cache.private.get(‘last’) directly. parseFloat apparently returns a NaN if the input value is null, therefore the if check didn’t trigger.

(function(data) {
   
    const THRESHOLD = 50;
    const lastValue = parseFloat(cache.private.get('last'));
    const currValue = parseFloat(data);
   
  if(cache.private.get('last') === null 
     || Math.abs(currValue - lastValue) >= THRESHOLD) {
    cache.private.put('last', currValue);
    return data;
  }
  return cache.private.get('last');
})(input)