So here’s the solution(s) for anyone who stumbles across this:
Filters cannot be added directly to the modbus entries, the filters have to be templated seperately. An easier solution is there appears to be modbus filtering included when the device_class field is added to the modbus sensor definition.
Here is an excerpt from templates.yaml that demonstrates template filtering. This code doesn’t work as written because the “last” state is unknown when HA starts; I need to manually set the last state within the range of the current temperaute before it works (you could add logic to create a base case, but it is easier to add device_class as above and not use the template filtering:
- sensor:
- name: "Battery Temperature (Filtered)"
unique_id: gate_power_battery_temperature_filtered
unit_of_measurement: "℃"
state_class: measurement
device_class: temperature
state: >
{% set current = states('sensor.battery_temperature_raw') | float(0) %}
{% set last = states('sensor.battery_temperature_filtered') | float(0) %}
{% if (current - last) | abs < 2 %}
{{ current }}
{% else %}
{{ last }}
{% endif %}
availability: "{{ states('sensor.battery_temperature_raw') not in ['unknown', 'unavailable'] }}"