Help with this lambda not working

I am trying to write this code to filter out any small values from a power meter that are mostly just noise and not actual power usage. Maybe there’s a better way to do it?

  - &small
    lambda:
      if (x > 10) {
        return (x * 1);
      } else {
        return (x * 0);
      }

but when I go to install I get this error. Any idea what I’m doing wrong?

Invalid key "{'lambda': 'if (x > 10) { return (x * 1); } else { return (x * 0); }'}" (not hashable)
  in "/config/energy-monitor-v2.yaml", line 114, column 5

Hi, have a look at the filter options:

^^ not sure what this one mean.

Can You provide more background - may be whole sensor config !?
IMHO not a lambda is a cause, but it usage.

Here’s how a commercial company does it.

1 Like

Thanks for the help everyone but turns out it was an error with where I was trying to use the filter instead of the lambda code itself.

For more info, I was trying to add an extra filter to this project and was adding the filter to portion where it copied the sensor data

 - { platform: copy, name:  "Dishwasher Power", source_id:  cir3, filters: *throttle_avg, *small }

instead of where it was reading the CT Clamp

 - { phase_id: phase_b, input:  "1", power: { id:  cir1, filters: [ *pos, multiply: 2, *small ] } }