[SOLVED] Calculating the elevation of the sun at a specific point in time using the astro binding?


Use case: Using previous data for the production of my solar panels as a function of the sun’s elevation at noon and the weather forecast for the day, I plan to let OH decide if the geothermal heat pump should be allowed to run or not.

It is probably stretching things a bit, I would like to use the astro binding to calculate the elevation of the sun at a specific point in time (i.e. noon) each night. Much like sending the desired DateTime as an input to astro:sun:home:noon.

I do, however, realize OH is event driven and not a general calculation instrument so the chances are slim but… A possible (?) solution would be to use something like “Now-astro:sun:home:noon#start” and use that number of minutes as an offset to astro:sun:home:position#elevation but it seems a bit far fetched if there already is a method to do it.

Having read e.g., OH2 Astro binding - Question or feature request: calculate next day's sunrise time it seems less probable. I could of course do a GOlang solution and/or a REST-API as an alternative. Any takers?

Best /Brus-Per

You could still calculate the elevation at noon for example at a few minutes after midnight based on the way the astro binding does that:

(see public void setPositionalInfo)

Thank you, Rolf, this seems to be a solution to my problem. Even if it’s not using the Astro binding per se, it is definitely the astro binding in action :slight_smile:

I’m looking to build the same i.e. get a prediction of expected solar yield for the day.

Did you come up with a DSL rules solution ?

Not really. I took the easy way out and made a table of the mean elevation for each week and that in combination with the weather forecast controls the heat pump. Not a pretty solution and not a solution within openHAB but it works :slight_smile:

Ok thanks for getting back with me.
My current best idea is to cheat a little: calc and persist every minute, then use yesterday’s persisted value.