Get energy yield on a specific date to calculate yearly energy yield and kWh/kWp value

I have a Iungo EMS with a Modbus connection to log my solar panels. Via MQTT I get data that I can use in the energy dashboard. The only value that I cannot get is the total energy yield for this year. So I need to get the value on 31-12-2021 00:00 and calculate this with the total yield which I can get via MQTT from the Iungo.
I can access the historical data via a API curl request with a timestamp, property name and object id.
Is it also possible to make the timestamp dynamic? When it is a new year it automatically changes?
I am quite new in the world of Home Assistant.