Sensor filter confuses me

I am struggle in creating a filtered temperature sensor. The file editor shows that everything is ok, but when i check my configuration i am getting an error:

Invalid config for [sensor.filter]: [sensors] is an invalid option for [sensor.filter]. Check: sensor.filter->sensors. (See ?, line ?).

I have linked my sensor file in the configruation.yaml file using this line of code:

sensor: !include sensors.yaml

And my filtered sensor in my sensors.yaml looks like this:

- platform: filter
  sensors:
    filtered_realistic_out_temperature:
        friendly_name: Außentemperatur (gefiltert)
        entity_id: sensor.heizung_aussentemperatur
        filters:
          - filter: outlier
            window_size: 4
            radius: 60.0
        unit_of_measurement: °C
        device_class: temperature

Can somebody tell me what i am doing wrong?

(This is my complete sensors.yaml file)

- platform: template
  sensors:
    pool_temperature:
      friendly_name: Pool Temperatur
      value_template: >-
        {{ states("input_number.pool_temperature_value") }}
#{{ state_attr("input_number.pool_temperature_value","unit_of_measurement") }}
      icon_template: mdi:pool-thermometer
      unit_of_measurement: °C
      device_class: temperature
      
- platform: template
  sensors: 
    regler_raumtemperatur:
        friendly_name: Regler Raumtemperatur (mit Faktor 10)
        value_template: '{{ ((states.sensor.temperatur_luftfeuchte_wohnzimmer_temperature.state | float(22) * 10.0)) | round(2) }}'
        icon_template: mdi:temperature-chevron-up
        unit_of_measurement: °C
        device_class: temperature

- platform: filter
  sensors:
    filtered_realistic_out_temperature:
        friendly_name: Außentemperatur (gefiltert)
        entity_id: sensor.heizung_aussentemperatur
        filters:
          - filter: outlier
            window_size: 4
            radius: 60.0
        unit_of_measurement: °C
        device_class: temperature

Look at the examples in the documentation compared to your incorrect configuration.

So i did… now my sensors.yaml looks like this:

- platform: template
  sensors:
    pool_temperature:
      friendly_name: Pool Temperatur
      value_template: >-
        {{ states("input_number.pool_temperature_value") }}
#{{ state_attr("input_number.pool_temperature_value","unit_of_measurement") }}
      icon_template: mdi:pool-thermometer
      unit_of_measurement: °C
      device_class: temperature
      
- platform: template
  sensors: 
    regler_raumtemperatur:
        friendly_name: Regler Raumtemperatur (mit Faktor 10)
        value_template: '{{ ((states.sensor.temperatur_luftfeuchte_wohnzimmer_temperature.state | float(22) * 10.0)) | round(2) }}'
        icon_template: mdi:temperature-chevron-up
        unit_of_measurement: °C
        device_class: temperature

- platform: filter
  name: "filtered_realistic_out_temperature"
  entity_id: sensor.heizung_aussentemperatur
  filters:
      - filter: outlier
        window_size: 4
        radius: 60.0
  friendly_name: Außentemperatur (gefiltert)
  unit_of_measurement: °C
  device_class: temperature

Nothing changed… getting the same error.

Ok, i seems not to be possible to set

  friendly_name: Außentemperatur (gefiltert)
  unit_of_measurement: °C
  device_class: temperature

Thought this filtered sensor derives from sensor?

This sensors.yaml works:

- platform: template
  sensors:
    pool_temperature:
      friendly_name: Pool Temperatur
      value_template: >-
        {{ states("input_number.pool_temperature_value") }}
#{{ state_attr("input_number.pool_temperature_value","unit_of_measurement") }}
      icon_template: mdi:pool-thermometer
      unit_of_measurement: °C
      device_class: temperature
      
- platform: template
  sensors: 
    regler_raumtemperatur:
        friendly_name: Regler Raumtemperatur (mit Faktor 10)
        value_template: '{{ ((states.sensor.temperatur_luftfeuchte_wohnzimmer_temperature.state | float(22) * 10.0)) | round(2) }}'
        icon_template: mdi:temperature-chevron-up
        unit_of_measurement: °C
        device_class: temperature

- platform: filter
  name: "filtered_realistic_out_temperature"
  entity_id: sensor.heizung_aussentemperatur
  filters:
      - filter: outlier
        window_size: 4
        radius: 60.0

So how can i set now

friendly_name: Außentemperatur (gefiltert)
unit_of_measurement: °C
device_class: temperature

on the filtered sensor?

Edit
It seems the filtered sensor inherits the properties from the original sensor. I will provide feedback on the documentation, missing that information. Thanks for help.

For the first one it only supports name, the unit and device class are derived from the source sensor.

1 Like

So no “friendly_name”?

Name and friendly name behave identically. There is no need for both.

1 Like

Allright, so i have to use “unique_id” as id and name as “friendly_name”.
That confused me a little bit, because for sensors i am using the name (unique_id) for creating the sensor and give it a friendly name using “friendly_name”.
But now it seems to work. Thank you @tom_l