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

(Paul Hansen) #145

Can anyone give me a hint on how to get the inner circle highlighted in respect of where the sun is for someone in the southern hemisphere? Everything else looks good, but my wife just commented that the bright section of the inner circle wasn’t in the right place… now it’s all I can see and i’m not sure where to begin with the script.

The attached image was taken just before midday and the inner and outer markers look good.

0 Likes

(Vincent Regaud) #146

Hi @pahansen

These two lines:

svg = svg + self.generateArc(WIDTH/2,PRIMARY_COLOR,self.sunset_azimuth,self.sunrise_azimuth)
svg = svg + self.generateArc(WIDTH/2,LIGHT_COLOR,self.sunrise_azimuth,self.sunset_azimuth)

Change the first one the LIGHT_COLOR and the second one to PRIMARY_COLOR

1 Like

(Gaël L'hopital) #148

Small evolution, if you happen to have moon age and want to display it directly :

Add a moon_age property :

		self.moon_azimuth = float(self.oh.getState('Astro_Moon_Azimuth').replace(" °",""))
		self.moon_elevation = float(self.oh.getState('Astro_Moon_Elevation').replace(" °",""))
		self.moon_age = self.oh.getState('Astro_Moon_Age')

Modification of the moon rendering :

# moon
moon = self.degreesToPoint(self.moon_azimuth, WIDTH / 2)
#svg = svg + '<circle cx="' + str(moon['x']) + '" cy="' + str(moon['y']) + '" r="' + str(MOON_RADIUS -1) + '" stroke="' + MOON_COLOR + '" stroke-width="0" fill="' + MOON_COLOR + '" />'
		
svg = svg + '<image x="' + str(moon['x']) + '" y="' + str(moon['y']) + '" width="' + str(MOON_RADIUS *2 ) + '" height="' + str(MOON_RADIUS *2) + '" xlink:href="/icon/moon?state=' + self.moon_age +'&amp;format=svg" />'
		svg = svg + '</svg>'

And here you are :
Capture%20d%E2%80%99%C3%A9cran%20du%202019-03-14%2009-17-50

1 Like

(Andrew Pawelski) #149

Dumb question but is north up on the svg?

0 Likes

(Gaël L'hopital) #150

Yes, it should

0 Likes

(Vincent Regaud) #151

Yes, but you’ll have to make some code changes if you live in the southern hemisphere

1 Like

(Andrew Pawelski) #152

And altitude in meters?

0 Likes

(Andrew Pawelski) #153

Ah I do I think there’s a post a bit up about that…

0 Likes

(Vincent Regaud) #154

Yes in meters

0 Likes

(Andrew Pawelski) #155

I have a black background - what line can I change the colour of the shadow on? I found two “black” references but they didnt seem to do anything or is this in CSS? I also dont seem to have the hour slots?

0 Likes

(Andrew Pawelski) #156

anyone? my other question is - what could I do to use this information to help me raise and lower blinds as they come out of shadow?

0 Likes

(Daniel Hampson) #157

Hi, I need help, I used the code from llegovich (Show Current Sun Position and Shadow of House (Generate SVG)) to have the moon, but for some reason the svg iisn’t showing the moon. When i do

python /etc/openhab2/scripts/shaddow.py update

it shows the

Sun azimuth: 314.954392516
Sun elevation: -13.147332433
Moon azimuth: 97.0532998037
Moon elevation: -22.8624873031
Done in 0:00:00.165627 seconds

but no moon is displayed, Do i have to do some other changes or just in the shadow.py?

0 Likes

(Lalala) #158

Hello,

would it be possible to change the “SHAPE” part to 2 separate shapes? I have a detached garage i would like to include in the image, but have no idea about the needed syntax.

Thanks in advance!

0 Likes

(Andrew Pawelski) #159

can someone post a fully working script ive tried to grab bits from a few posts above but only have it “kind of” working

0 Likes