Pass Sensor value to Python Script, process it and return back as another Sensor value

You could also take a look at appdaemon, there you can import libraries and they are not lost after an update of HA.