As these are strings, I do not understand how I could calculate the hours between these 2 times.
Or should I follow another approach instead of creating the aforementioned 2 template sensors and create 1 template sensor that directly calculates the sunlight/ daylight hours? But how?
Use the as_timedelta filter/function to convert each string to a timedelta object, then just subtract one from the other. You could do it something like this:
This calculation will have one error though – it will only show the “correct” value in the evening/night, after sunset but before sunrise. At any other time during the day, those times will be fetched from different days (+/- 1 day) so may differ by some minutes.