This avoids copying all the states before applying the filter
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>