Can't get generic thermostat to use filter sensor value

Hi all. I am trying to set up a generic thermostat using a filtered temperature sensor. The thermostat works fine if I configure it to use the sensor directly, but if I set target_sensor to a filter sensor, the value always shows as null. The filter sensor does show a good value on the History page. Can anyone see what I might be doing wrong in this config?

sensor:
        - platform: filter
          name: "Filtered Main Zone Temp"
          entity_id: sensor.living_room_temperature
          filters:
                  - filter: outlier
                    window_size: 10
                    radius: 3.0
                  - filter: lowpass
                    time_constant: 10
                    precision: 1

climate:
        - platform: generic_thermostat
          name: Main Zone
          heater: switch.main_heat_zone
          target_sensor: sensor.filtered_main_zone_temp
          target_temp: 63
          min_cycle_duration:
                  minutes: 1
          initial_hvac_mode: "heat"
          precision: 0.1
1 Like

add a unit of measurement to your filter sensor, i.e. ºF or ºC

Thanks. After your reply I tried adding a unit_of_measurement line to the filter sensor, but then configuration validation fails. I think it may already be picking that up from the source sensor anyway:

If it has a unit of measurement it should be wroking with your configuration. What does the sensor.living_room_temperature look like?

I don’t have a config snippet for that once since it was added by the ESPHome add-on, but here’s what it looks like in Developer Tools:

It should be working then based on your config and that screenshot. Are there errors in your logs?

Just the one from trying to add a unit of measurement (which no longer happens after I removed that line):
2019-12-20 09:30:35 ERROR (MainThread) [homeassistant.components.hassio] Invalid config for [sensor.filter]: [unit_of_measurement] is an invalid option for [sensor.filter]. Check: sensor.filter->unit_of_measurement. (See ?, line ?). Please check the docs at https://home-assistant.io/integrations/filter/

Here’s what the thermostat looks like when I set target_sensor to sensor.filtered_main_zone_temp:

If it’s null, you should be getting errors in your log

One would think. But if there are, they don’t show up under Developer Tools->Logs, or through ssh “hassio homeassistant logs”

What’s your logger setting? Info?

Yes, I tried debug but didn’t see anything relevant there either.

Odd, looking at the code then the only path without information is a path with a valid config and a number that’s returned. Which doesn’t make sense because you’re getting null. I plan on making my own ESP temperature sensor but It’ll be a bit before I get all the materials. Until then, I don’t think I can help you out. Sorry to waste your time.

Thanks for trying to help! I’ll keep after it, maybe I’m missing something.

If it’s not related to the unit_of_measurement, then it might be the scan interval. It’s also possible that the filter doesn’t have a state at startup when the climate is ‘built’.

Try moving the unit of measurement to the customize section instead of the sensor definition.

That worked! Thanks to you both.

1 Like

I am also hitting this (Home Assistant 0.114.4).

Moving unit_of_measurement to the customize section didn’t work:

homeassistant:
  customize:
    sensor.filtered_temperature:
      unit_of_measurement: °C

I tried all sorts of things in config. Nothing worked.

But eventually I noticed that simply “touching” a control on thermostat widget in Lovelace will trigger an update. (This is easily reproducible for me by setting current_temperature: null on the thermostat and refreshing the UI.)