fetzerch / grafana-sunandmoon-datasource

SunAndMoon is a datasource plugin for Grafana that calculates the position of Sun and Moon as well as the Moon illumination. ☀️🌙🧛‍♂️
MIT License
42 stars 8 forks source link

How to show Sunrise (as a curve) ? #10

Closed ozett closed 6 years ago

ozett commented 6 years ago

hi, as the plugin is now working for me, i thought to show the sunrise and the sunset as an overlay to my light/lux-data. I managed to get the mixed datasource, but as far as i see/understand: there is no sunset available. am i right?

i checked the suncalc repo at github, and there is a table that has this values.

❓ are they available at your plugin? Or is the "altitude" the rise of sun and moon? can anybody give me a hint to show them up on grafana?

zwischenablage02

fetzerch commented 6 years ago

grafik

You want the sun altitude, which shows how high the sun is in the sky. Sunrise / Sunset are the moments when the altitude is 0. They are available in the plugin as annotations. See also https://en.wikipedia.org/wiki/Sunset#/media/File:Twilight_subcategories.svg.

ozett commented 6 years ago

👍 i test this.. thx a lot

ozett commented 6 years ago

my lux-values range from 0 to 1000 on the ADC, the moon/sun altitude is too little, to be well recognizable. see this: lin

if i change scale completely for the whole Y-metrics to log2 it gets better see this: log

it is not possiblity to calculate on the moon/sunrise altitude values? that would help in my case to find a multiplier of the altiuted to get them into the max-scale of my lux of 1000 l do you think that this could be done somehow? see this: meetrics

fetzerch commented 6 years ago

You're trying to mix up completely unrelated units which won't work well. The best thing is to move the sun altitude to the second y-axis. In my example picture you can see that the altitude values are on the left axis with unit degree, and the illumination is on the right axis with unit percentage.

ozett commented 6 years ago

i exprimented a litte. and did maths on my light-values to scale down by 100. that works, and shows my desired curves. but now i have only a display-resolution of 100 degrees, instead of 1000.

why not maths (like log2) on the sun and moon values? too much coding work in the plugin?

see: scale

ozett commented 6 years ago

i googled a bit, found something, but what a pitty: i a not a coder...

there is a caculation to get a light-value from the sun-altitude. based on lat+lon

http://www.domoticz.com/wiki/Real-time_solar_data_without_any_hardware_sensor_:_azimuth,_Altitude,_Lux_sensor...

that would be a 🎁 😁 and then some maths on the values... 😁

fetzerch commented 6 years ago

why not maths (like log2) on the sun and moon values? too much coding work in the plugin?

It's not clean to do that in the addon. The addon outputs the correct values, if you need a different scale you have to apply the calculations afterwards. But again, best would be to just use a second y-Axis as explained above with a different scale.

Those calculations are interesting, but they access 2 webservices, not straight-forward to add this to the plugin unfortunately (and I also don't have much spare time at the moment).