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

(Dexter) #33

great widget, very usefull. I will try it asap

(Christian) #34

Hi Patrick

The widget runs smoothly on one of my Ubuntu machines. Thank you very much.
On the other “identical” Ubuntu machine I receive the following error:
–> No results returned from InfluxDB History:

Log File:

2017-10-29 15:25:00.483 [INFO ] [lipse.smarthome.model.script.Shaddow] - Updating Shaddow SVG
2017-10-29 15:25:00.483 [INFO ] [lipse.smarthome.model.script.Shaddow] - Successfully got state from OpenHab: Sun_Azimuth
Successfully got state from OpenHab: Sun_Elevation
Successfully got state from OpenHab: Sunrise_Azimuth
Successfully got state from OpenHab: Sunset_Azimuth
Error getting data from InfluxDB: SELECT FIRST(*) FROM "Sun_Azimuth" where time>'2017-10-27T23:00:00Z' (HTTP Response 401)
No results returned from InfluxDB History: 

This behaviour is strange beacuse data is definitely in the database. If I query influx directly I’ll receive data for this select statement:

Connected to http://localhost:8086 version 1.3.7
InfluxDB shell version: 1.3.7
> USE openhab_db
Using database openhab_db
> SELECT FIRST(*) FROM "Sun_Azimuth" where time>'2017-10-28T22:00:00Z'
name: Sun_Azimuth
time                first_value
----                -----------
1509228000015000000 327.73

Do you have any clue why I receive this error message?

(Benjamin) #35

This http code stands for “Unauthorized”, thats why you didnt receive any results.

(Christian) #36

thank you!

Hmm, in this case the Python script is not authorized to access Influx DB? How can this be solved?

(Benjamin) #37

I am not using this stuff here, but a first look into the script: looks like it is not using authentication.

Therefore it seems like your influxdb is configured to not allow an unsecure communication. At least that is my conception.

(Christian) #38

Thanks for all the help!

I initially setup Influx based on the below manual:

There it’s recommended to set auth-enabled = true. The script started to work immediately after setting the parameter to false.

(Max1968) #39

This is really cool, I like it a lot. I want to change it to also add the position of the moon and the direction where the wind is coming from, the moon also indicating the current phase and the wind indicating the strength in beaufour. I was able to “include” svg files for sun, moon and wind residing in the same html directory which already gives the following:

(this is a testing version thus some persisted data is missing)

However I’d prefer to “include” icons from the icons directory instead, what path do i need to use for these ? Furthermore I’d like to use a different iconset ( which is not colored. When I use these the icons show up as “black on black underground”, thus invisible. How can I change the color of these “included svg files” ?

the corresponding lines of the created shaddow.svg look like this:

<image x="0.852620357054" y="68.4735781393" width="10" height="10" xlink:href="wind.svg" /> 
<image x="59.9686933371" y="92.7067942727" width="10" height="10" xlink:href="moon.svg" /> 
<image x="67.2083062338" y="89.7972223941" width="10" height="10" xlink:href="sun.svg" />

I will upload the modified script (using the REST interface, not InfluxDB) once I have this working.

Thx, Max

(Ralf Klüber) #40

Hi Patrick,

awesome. Looks great. Can you share the widget for the other views as well. Looks like you created some for the energy costs, energy consumption views as well.


(Marco) #42

Hmmmm, i think thats not the expecting result :roll_eyes:

Any ideas?

(Marco) #43

Problem seems to be solved, patience was the key :wink:

But the sun position is not correct, i think its because of a wrong shape of the house. How do you create it? The basic form is correct, but it seems to be inverted. How do i align the shape correctly?


Edit: Problem solved…

(Marco) #44

@pmpkk I have to give you a really big “Thank You” for your great theme and this script :heart_eyes::wink:

(Marco) #45


Would you be so kind to tell my how and where in the you inserted the icons?

(SiHui) #47

Needs to be Sun_Elevation :innocent:

(Salexes) #48

I do not use hab panel yet but I want to add exactly this once I have my habpanel set up.

But in additon to that…what I currently try to do is to automate my rollershutters and I think it could be possible to realize with parts of your script.

What I wan to do is the following:
I want to automatically close the rollershutters if the sun is shining through the window.

So my question is how can I use this script to achive this? Could you lead me the right way ? I am quite new to python code and do not understand much of it.

kind regards,

(SiHui) #49

All you need for that task is the azimuth angle from the astro binding:

(Ralf Klüber) #50

Eventuell hilft das:

var Number diffToFasade = 30  // Quasi Abweichung von Nord deiner Hausausrichtung
rule "Update Fassade"
  Item Sun_Height_ext changed or
  Item Sun_Azimut_ext changed
	logDebug("Sun","Update Fassade")
	var height                = Sun_Height_ext.state
 	var azimut                = Sun_Azimut_ext.state

	var eastFasadeIn   = (  90 - 90 + diffToFasade )   //For example: -26.09 or 333,91 - because 0 and 360 is north
	var eastFasadeOut  = (  90 + 90 + diffToFasade )   //153,91
	var southFasadeIn  = ( 180 - 90 + diffToFasade )   //63,91
    var southFasadeOut = ( 180 + 90 + diffToFasade )   //243,91
    var westFasadeIn   = ( 270 - 90 + diffToFasade )   //153,91
    var westFasadeOut  = ( 270 + 90 + diffToFasade )   //333,9 
    var northFasadeIn  = ( 360 - 90 + diffToFasade )   //243,91
    var northFasadeOut = ( 360 + 90 + diffToFasade )   //386,09 or 63,91 -  because 360 and 0 is north
    postUpdate(Sun_Fasade_Illum_East,             if (azimut > (eastFasadeIn.remainder(360)) && azimut < (eastFasadeOut.remainder(360)) && height > 18) ON else OFF)
    postUpdate(Sun_Fasade_Illum_South,            if (azimut > (southFasadeIn.remainder(360)) && azimut < (southFasadeOut.remainder(360)) && height > 18) ON else OFF)
    postUpdate(Sun_Fasade_Illum_West,             if (azimut > (westFasadeIn.remainder(360)) && azimut < (westFasadeOut.remainder(360)) && height > 18) ON else OFF)
    postUpdate(Sun_Fasade_Illum_North,            if (azimut > (northFasadeIn.remainder(360)) && azimut < (northFasadeOut.remainder(360)) && height > 18) ON else OFF)


Auf die Änderungen der Sun_Fassade_Illum_* wird dann jeweils in einer Regel der/die Rolläden gefahren.

(SiHui) #51

Same here …

How did you solve it?

(Marco) #52

I “inverted” my y-coordinate :wink:

100 - your “y” and then insert this into the

(Patrick) #53


As others have said in order to manage your shutters you really just need to check the sun azimuth and elevation. I do this for my shutters and it works perfectly all year round!


(SiHui) #54

Thx, that’s it! :grinning: