AitorDB / home-assistant-sun-card

Home assistant sun card based on Google weather design
MIT License
407 stars 184 forks source link

Proposal: Show moon #45

Open ChristophHoltmann opened 3 years ago

ChristophHoltmann commented 3 years ago

It would be great to the the moon as well.

AitorDB commented 3 years ago

I have seen this request on Reddit too, I'm bit on the fence with this (whether it should be another card or not), the reasons for it are the needs of probably a new graph, new integration, etc.

rphlwnk commented 3 years ago

How about just adding a second object as the Moon behind the sun, and this object will appear as soon the sun hits the Horizon? Currently the sun is disappearing on the Horizon, so this might be an easy first solution for this.

Something like that - red is the "rising" Moon: image

AitorDB commented 3 years ago

But the moon can be out at the same time than the sun, for example here the moonrise is at 14:06. Also in that way it would be difficult to represent the moon phase in a way that looks good enough

LiJu09 commented 3 years ago

Graph like this looks great. It's from app Trail Sense. But there isn't moon entity in Home Assistant.

3

AitorDB commented 3 years ago

@LiJu09 there's a moon integration, however it seems to only showthe current state of it (new moon, full moon, etc.) and not very used, "it's used by 3.7% of the active installations"

rct commented 3 years ago

I'd love see the moon rise/set times and elevation too, but unfortunately it is currently a gap in Home Assistant integrations.

I've been pulling moon information from my weather integration, but that's kind of kludgy to try to integrate in a general way.

The Python Astral package, https://pypi.org/project/astral/, which I believe is used by both the builtin Sun sensor and pnbruckner's much improved ha-sun2 sensor only calculates moon phase. So a new library or some work on astral would be needed.

ChristophHoltmann commented 3 years ago

Ok I understand the problem here.

Not sure if it is possible, but there might be a way to calculate the moon rise.

https://boards.straightdope.com/t/algorithm-to-calculate-sun-moon-rise-set-with-example/236751/13

I had no time to do the math yet, but if there are others interested in it, it might be worth it.

rct commented 3 years ago

There is an old, open pull request against Astral to add next new moon and next full moon. Looks like it was created by someone trying to get support into Home Assistant.

PyEphem can do calculations for the moon and many other celestial bodies. It isn't currently used in Home Assistant.

Misiu commented 3 years ago

@AitorDB there is a TypeScript package from the author of Astral: https://github.com/sffjunkie/astral-ts maybe this can be used to add the moon to the graph (probably with an option to show only the sun, only the moon, or both). The view from @LiJu09 would be awesome 👍

Misiu commented 1 year ago

@AitorDB astral v3.0 supports this. so if new version is added to HA this will be possible to add.