Scheduling switch on/off from REST API or other external python script

I have a fresh air intake on my house that I would like to turn on and off using HA. I have created a separate script that downloads the forecast and finds the best times to open / close the intake based on outdoor temperature (for now). Since this script runs daily I would like it to send the open/close times to HA and have HA take care of opening and closing the intake. Is there a way to send such scheduling commands to HA core either through the REST API or other APIs?

Alternatively - if there is a way to send a turn on/off command that could work also - then I would just need to make another script that would run in the background and send these on/off commands at my specified timepoints. (not as elegant of a solution).

Here is the output of the script - green is time to turn on redline is time to turn off:

Perhaps can AppDaemon help.

https://home-assistant.io/docs/ecosystem/appdaemon/

You can make an API call like this to set the value of a sensor.

curl -X POST -H "Content-Type: application/json" -H "x-ha-access: <your password>" -d "{\"state\": \"2017-05-20T10:06:14+00:00\"}" https://<your url>/api/states/sensor.faIntakeOn

Then, you can use a template trigger to compare that date/time value to the current date/time.