Ability to filter (i.e., adjust) sensor values before recording state to HA db

I have a number of cheap temperature & humidity sensors that are biased but lack internal calibration.

I would like to “filter” (i.e. adjust) the sensor values before the state gets recorded to the HA db – similar to the optional filter: line in ESPHome.

I can do this manually for mqtt integrations by changing the config line in MQTT and I can do this manually for ESPHome devices by adding a filter: line as noted above.

But I would like to be able to do this in a generic manner for all integrations.
In particular, I would like to calibrate my Nest Thermostat temperature sensors.

I know I can do this by creating a second “Template” or “Filtered” entity but that seems klugey and just duplicates the number of recorded entities while creating a new unnecessary abstraction layer that needs to be maintained as sensors come and go or are modified.

Has anyone created a generic integration (or is it even possible to do so) that stands between the primary integration and recording to HA db that allows one to filter individual states for specified entities. Ideally, the filter would be a line of jinja-like code that could be optionally added for any recording entity.

Any thoughts?

What you’re asking for is not possible, even from a custom integration standpoint.

Is it worthy of an HA core feature request then?
It seems like a pretty common use case and duplicating sensors is at best a hack it seems.

IMO no because it’ll never get approved and it’s the opposite workflow than what currently exists. Typically you remove the source entity from recorder. That’s the intended path with filters if you don’t want that history.