Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add custom location for sunrise/sunset #162

Open
koko0815 opened this issue Jul 6, 2020 · 5 comments
Open

Add custom location for sunrise/sunset #162

koko0815 opened this issue Jul 6, 2020 · 5 comments

Comments

@koko0815
Copy link

koko0815 commented Jul 6, 2020

Hey folks,

any idea to use a custom location in the sunrise-plugin? I want to use my own one, because Berlin is to fare away, as we are located in the south of germany.

I find out that web-page https://astral.readthedocs.io/en/latest/
But I'm not able to integrat that in Bernds Code :-/

Any help will be appreciated.

TIA
Phil

BTW: We have some problems with the weather forecast, too. It seems that there is no connection to weather_dot_com or yahoo? Any ideas?

@FrankX0
Copy link
Contributor

FrankX0 commented Jul 6, 2020

Did you try to configure the location in the config file?

# Choose your city here http://pythonhosted.org//astral/#cities

And yes, there seems to be an issue with the weather forecast.

@koko0815
Copy link
Author

koko0815 commented Jul 7, 2020

Hello FrankX0,

yes I did. But there is a difference about nearly 30 minutes between Berlin and our location near Stuttgart...
That's the reason why I want to set a custom location.

http://pythonhosted.org//astral/#cities is not working any more. But I was looking for the astral cities in the link above.
There is no southern location which is next to us than berlin.

TIA
Phil

@FrankX0
Copy link
Contributor

FrankX0 commented Jul 7, 2020

Hi Phil,

Now I understand. The number of cities is indeed very limited.
In the Netherlands this is not such a big issue ;-) (I'm off by only 5 minutes)

The best way IMO would be to be able to specify not only a location but also coordinates in the config file.
Astral seems to support that. Let me see what I can do.

Regards,
Frank.

@FrankX0
Copy link
Contributor

FrankX0 commented Jul 8, 2020

Hi Phil,

Can you try following modifications in your clock?
So instead of being able to select a few cities, now you can set your own with coordinates and time zone.
So you need to modify your config file and two modifications to the sunrise plugin.
If you're happy with this I can make a pull request and make it backwards compatible.

Regards,
Frank.


Change to: location = "Den Bosch", "Netherlands", 51.6978162,5.3036748, "Europe/Amsterdam"

from astral import Astral

Change to: import astral

self.astral_at_location = Astral()[config.get('plugin_' + self.name, 'location')]

Change to: self.astral_at_location = astral.Location(info = eval(config.get('plugin_' + self.name, 'location')))

@bk1285
Copy link
Owner

bk1285 commented Dec 19, 2020

Hi @FrankX0

looks promising: Nice approach! I think I find the time within the next weeks to look into the various issues/PRs/etc. ...including this topic...

Best,
Bernd

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants