I use the outlier and median filters for some of my sensors.
Sometimes these sensors have 'unknown' state.
After the source sensor received unknown state the filter sensor receives also 'unknown' and in the log there is an error(see below).
The filter sensor continues to receive errors after the source sensor returns to normal functioning and the filter sensor state is 'unknown'.
ERROR (MainThread) [homeassistant.core] Error doing job: Exception in callback async_track_state_change.<locals>.state_change_listener(<Event st
ate_...128022+02:00>>) at /srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/event.py:81
Traceback (most recent call last):
File "/usr/local/lib/python3.7/asyncio/events.py", line 88, in _run
self._context.run(self._callback, *self._args)
File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/event.py", line 103, in state_change_listener
event.data.get("new_state"),
File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/core.py", line 364, in async_run_job
target(*args)
File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/components/filter/sensor.py", line 189, in filter_sensor_state_listener
filtered_state = filt.filter_state(copy(temp_state))
File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/components/filter/sensor.py", line 389, in filter_state
filtered = self._filter_state(FilterState(new_state))
File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/components/filter/sensor.py", line 472, in _filter_state
median = statistics.median([s.state for s in self.states]) if self.states else 0
File "/usr/local/lib/python3.7/statistics.py", line 376, in median
data = sorted(data)
TypeError: '<' not supported between instances of 'float' and 'str'
The problem
I use the outlier and median filters for some of my sensors. Sometimes these sensors have 'unknown' state. After the source sensor received unknown state the filter sensor receives also 'unknown' and in the log there is an error(see below). The filter sensor continues to receive errors after the source sensor returns to normal functioning and the filter sensor state is 'unknown'.
Only restart of Home Assistant solves a problem.
Environment
Problem-relevant
configuration.yaml
Traceback/Error logs
Additional information