Pulse counter GPIO energy logging -> inserting values from script into HAS

I’m in the process of figuring out a smooth transition from Pimatic (Rip) to HAS.
One function I am struggling with is the way I can read the (current) production of my solar panels into de HA interface and perform some magic so that I can see the current energy consumption of my house. First step is interfacing with the smart meter. That seems to be easy, albeit, I have to read it through a home made interface over GPIO.
Second step is the difficult one: Reading the output of a dedicated kWh meter (only measures power from the inverter), that produces a pulse at every Wh production. I made a nice script 6 yeas ago in python that counts the pulses (production in kWh), measures how fast they come in (Power in Watts) and send these values into a file in the tmp folder. The pulses are read in the Rpi through a GPIO port. The produced file is monitored by Pimatic an I get live immediate updates when things change. Works perfectly!

Now HA: What is the best way to do it?
1: directly process detected pulses from the concering GPIO in HA?
2: use a “file” reader like in Pimatic?
3: Inject values into HA through an API, which can be handled in an adapted version of the script.

Option 3 is the preferred method, as I have all the correct values available. I was unable to find how to do this correctly.

Can anyone point me in the right direction? The goal is not to buy additional hardware,

Nobody ever use data from a “pulse” provider in HAS?

I am still not moved from Pimatic to HA as I have been unable to resolve this. Can any one point me to examples on how to use RESTful Sensor - Home Assistant properly?

I have followed the steps but have not been able to post values to a variable.

What I have set up now as a test:
sensor:

Now I want to write some values into that entity with Curl. I am not sure how authentications is handled