Show Current Sun Position and Shadow of House (Generate SVG)

(Kurt S) #125

Super @vzorglub and @rotulet!
Thanks to both of you for the fast fix!


(Ewan Fleming) #126

Dumb question.

Do I need to do anything special to run the python scripts? If I put them in the scripts folder, is that sufficient or do they need to be executed?

(Vincent Regaud) #127

See post #1

(Ewan Fleming) #128

I’ve now got it running using your code, vzorglub and all looking good, except the actual graphics don’t update in HabPanel. Only if I delete the widget and add it again will it update to show the correct sun position.

I’m using this in the widget template:

<object data="/static/matrix-theme/shaddow.svg?{{itemValue('Sun_Elevation')}}" type="image/svg+xml"></object>      

Logs show that Sun_Elevation and Sun_Azimuth are all updating every 300 seconds. Any ideas why it won’t update?

(Vincent Regaud) #129

Are you sure that your svg file is saved in /html/matrix-theme ?
If yes, then I have no idea. Not good with html and web dev.

(Ewan Fleming) #130

Yeah, it’s being created there each time. It looks great, just not changing. Mmm…

(Alpoy) #131

I just don’t understand why I’m not getting any circles around the image?
This is how it looks for me:


(Vincent Regaud) #132

Which code are you using,
from what post number?

(Alpoy) #133

Sorry, I’m using the original code (on top/first post).

(I tried the astral version but it failed saying “astral.AstralError: Sun never reaches 6 degrees below the horizon, at this location”. Apparently I live too far north?) :wink:

(Vincent Regaud) #134

Where do you live if I may ask?

(Alpoy) #135

In Norway, in the northern parts

(Vincent Regaud) #136


Now the original script uses persistence to draw the circles so the whole set-up needs to run for a full 24 hours from midnight to midnight before the persistence can pick up all the values needed to draw the circles.
Let it run for 48 hours and you should be good.

(Alpoy) #137

Ah! Thanks! :slightly_smiling_face:

(Kris K) #138

@pmpkk Can you please share this widget that has energy cost, gas usage etc? It looks fantastic.

(Vítor ângelo) #139

I got errors when i run the script:

File “/etc/openhab2/scripts/”, line 5, in

from myopenhab import openhab

File “/etc/openhab2/scripts/”, line 3, in

import requests

ImportError: No module named requests

Anyone can help?

(Vincent Regaud) #140

You need to download the script and put it in the same folder as for your fisrt issue

For the second, you need to run:
pip install requests from the console