Filter - need to remove some values from my IoT devise

Hi

Im rookie in HA, starting to learn, so pleas bear out with me :wink:

My case:
I send values to HA by MQTT, works like a charm!

Values are planned to be in area 15 to 80.
I have logged my IoT devise and it sends correct values.

For my test im sending a fixed value from my sensor, I keep same load on my sensor 24/7, 25.3 kg

In HA I receive value 25.3 constant except some crazy values like 4 million that ruins my graph.

I have read that I may use Filter function, so this I now try to understand.

When I apply Filter as described below, I don’t know how to get the filtered values in HA, no new “sensor” item in HA.

So, what am I missing? Should Filter be installed from github?

Any tip?

Thanks up front!

In yaml I have set this, and mqtt is working, and HA receives values as planned.

I have tried this approach:

MQTT-> unique_id: kube1Vekt
Filter----> entity_id: kube1Vekt

mqtt:
    sensor:
    - name: 'Kube 1 vekt'
      unique_id: kube1Vekt
      state_topic: 'bikuber/kube1/vekt'
      state_class: measurement  
      unit_of_measurement: 'Kg' 

Filter I have added this:

sensor:
  - platform: filter
    name: "Filtrert vekt kube 1"
    entity_id: kube1Vekt
    filters:
      - filter: outlier
        window_size: 4
        radius: 4.0
      - filter: lowpass
        time_constant: 10
        precision: 2

kube1Vekt is not an entity_id. It will be something like sensor.kube1vekt

Hi.

Thanks, I will look into it

M

Hi

I changed entity_id to: sensor.kube1Vekt

Still I dont see the sensor on dashboard. Any other tip to get?

sensor:
  - platform: filter
    name: "Filtrert vekt kube 1"
    entity_id: sensor.kube1Vekt
    filters:
      - filter: outlier
        window_size: 4
        radius: 4.0
      - filter: lowpass
        time_constant: 10
        precision: 2

try

entity_id: sensor.kube1vekt

entity_ids never contain uppercase chars

Thanks for reply

Is the sensor name a complete free word, or is it connected to a value sent from IoT device?

I tried this, did not help…

entity_id: sensor.kube1vekt

Im on vacation with famiy, now its time to move to another city. I’ll be back!

You can see the entity_id once you start to type in the UI. Also you can see it in various places in the UI, like, for example, developer tools/states.

It is always lower case.

Hi

still in aparment

Now I found the states

Unknown.

Maybe connection between MQTT sensor and filter is wrong…
How do Filter know what sensor to read?
is unique_id == entity_id?

mqtt:
    sensor:
    - name: 'Kube 1 vekt'
      unique_id: kube1Vekt
      state_topic: 'bikuber/kube1/vekt'
      state_class: measurement  
      unit_of_measurement: 'Kg'
Filter:
entity_id: sensor.kube1vekt

In mqtt i have one big letter:
image

This name comes from IoT device, that I can try to update when home next week if this is the error.

Using the states page, what is the enitity_id of the entity you want to filter?

This iot entity:

unique_id:kube1Vekt

Filter:

Sensor entity_id: sensor.kube1vekt

Update, I did not read your question correct, I think you asked me for this:

I guess I only need to click SET STATE?

I did click.

Now I get this:
image

I think the case is that weigth is received as string, Filter is float.

Is it possible in config.yaml to convert string to float?

I didn’t ask for the unique id. I asked for the entity_id

This is like pulling teeth.

I updated the post

entity_id is sensor.kube1vekt

Then try this.

sensor:
  - platform: filter
    name: "Filtrert vekt kube 1"
    entity_id: sensor.kube1vekt
    filters:
      - filter: outlier
        window_size: 4
        radius: 4.0
      - filter: lowpass
        time_constant: 10
        precision: 2

Thanks for reply.

This code I have tried without success

entity_id: sensor.kube1vekt

Today I was thinking that my sensor data is sent by lora to my receiver that again send it to HA. The LoRa message is a string, and sender system is not convertin it to float.

I tried this:

sensor:
  - platform: template
    sensors:
      kube1vekt_as_float:
        friendly_name: "Kube 1 Vekt as Float"
        value_template: "{{ state_attr('sensor.kube1vekt', 'value') | float }}"
  
  - platform: filter
    name: "Filtrert vekt kube 1"
    entity_id: sensor.kube1vekt_as_float
    filters:
      - filter: outlier
        window_size: 4
        radius: 4.0
      - filter: lowpass
        time_constant: 10
        precision: 2

But again not working, not showing up in dashboard

All states are text. So the fact that it is text is not relevant. But maybe a unit_of_measurement would make HA recognise it as a numeric entity?

Well nothing shows up in dashboard unless you put it there.