My aim is to have MotionEyEOS run this script when it detects motion. So, rather than HA consuming a REST API I need it to expose an API that allows me to change the state of an entity.
Ah ok. Just a forewarning, if you attempt to use this with the python_script integration, you won’t be able to import anything. The environment is very restricted. You might have to move to appdaemon. Or create your own integration using your library.
EDIT: I need to read more, you said motionEye is running this script.