Sensor raw value for thermostat, filtered for HA

Hi all,
please help, I need to use raw (not filtered) temperature value in climate to have quick response and precise regulation and simultaneously push filtered valuse to Home Assistant - I don’t need fill HA database up by useless amount of values.
I’ve got:

sensor:
 - platform: dallas
   address: 0x1E011913B65AE128
   name: Chicken coop
   id: chicken_coop_temp
   filters:
    - sliding_window_moving_average:
         window_size: 128
         send_every: 8
         send_first_at: 8

climate:
 - platform: thermostat
   name: Chicken coop
   sensor: chicken_coop_temp
   visual:
      min_temperature: 10 °C
      max_temperature: 35 °C
      temperature_step: 0.1 °C
   default_target_temperature_low: 30 °C
   hysteresis: 0.01
   heat_action:
    - output.turn_on: rel_heater
   idle_action:
    - output.turn_off: rel_heater

Thanks.
Jiri

If you did not want the signal delayed (averaged) then why did you include the sliding window filter in your ESPhome sensor config?

Maybe try deleting this bit …

   filters:
    - sliding_window_moving_average:
         window_size: 128
         send_every: 8
         send_first_at: 8

Cause I don’t want send new value every 1s to HA.

Hi
you can exclude the sensors from being stored into the HA database in your configuration.yaml in HA?
Entity is for explicitly named sensors, entity_globs for patterns ( in my example sensors ending with *_db)

recorder:
  exclude:
    entity:
    - sensor.name
    entity_globs:
    - sensor.*_db

not 100% sure about the formatting for yaml

No, I don’t want exclude it from storing at all, I just want to lower amount of stored values - every second is not good for HA - it slows down showing history.

Perhaps a solution with two sensors based on the same input? One high frequency excluded from the database for quick response and another with less values within the timeframe for storage?

Armin

Hm, does not work.

sensor:
 - platform: dallas
   address: 0x1E011913B65AE128
   name: Chicken coop
   filters:
    - sliding_window_moving_average:
         window_size: 128
         send_every: 16
         send_first_at: 16

 - platform: dallas
   address: 0x1E011913B65AE128
   id: chicken_coop_temp

First in HA “unknown”, second is in Climate changing value every second.

I setup a sample with my Ultrasonic sensor. From ESPHome it is sending a value every 5 seconds to a sensor named “sensor.ultrasonic_sensor”

added this “filter” sensor to my configuration.yaml:

  - platform: filter
    name: Filtered Ultrasonic
    entity_id: sensor.ultrasonic_sensor
    filters:
    - filter: time_throttle
      window_size: "00:01"

After restart it created a new entity “sensor.filtered_ultrasonic”

There are more types of filters, this one sends only one value within the window ( here 1 minute) and it is the first value captured within the timeframe. For Ultrasonic distance it does not really make sense, but should work for temperature?
The filtered sensor would go to the database, the original sensor with higher frequency is excluded.

Armin

Well, quite complicated. It took me a while that this should be in HA file, not esphome…
(I don’t like to have spread configuration of one “think” in more files…)
BTW, traditional on/off thermostat is oscillating around desired value (0.7°C), so I’m trying PID, autotune is running now. I hope that then the temperature will stay in 0.1°C, so no database recording would be done.
Will report final solution…

After trying hard, it could be done via template:

- platform: dallas
  address: 0x1E011913B65AE128
  name: "chicken coop raw"
  id: chicken_coop_raw

- platform: template
  name: "chicken coop"
  id: chicken_coop
  update_interval: 1s
  unit_of_measurement: "°C"
  icon: "mdi:thermometer"
  accuracy_decimals: 1
  lambda: |-
    return id(chicken_coop_raw).state;
  filters:
  - sliding_window_moving_average:
      window_size: 32
      send_every: 8

And PID climate is satisfied even with filtered sensor, at least with window size 16 or 32.

climate:
- platform: pid
  id: pid_climate
  name: "chicken coop"
  sensor: chicken_coop
  default_target_temperature: 26°C
  heat_output: pwm_heater
  visual:
    min_temperature: 10 °C
    max_temperature: 35 °C
    temperature_step: 0.1 °C
  control_parameters:
    kp: 1
    ki: 0.003
    kd: 33
#autotune values
#      kp: 0.81487
#      ki: 0.00169
#      kd: 98.5182