How to get planet constellation data (azimuth & elevation) into HA

Since I’ve seen this great card here I’m trying to create the same for my dashboard.

For the card I would need the constellation data (azimuth & elevation) of all visible planets.

For the sun I can get the data via state_attr(‘sun.sun’, ‘azimuth’) and state_attr(‘sun.sun’, ‘elevation’).

For the moon I can get the same via Lunar Phase (or via Moon Astro).

For planets I found ha_skyfield which is only for displaying the planets, not for providing raw-data.

My question is now, how I get the planet information into an HA-sensor?

Search here is a wonderful tool.

I’m not sure how this could solve my issue.

Here is the template sensor code I’m using for the sun.

- sensor:
    - name: "Sun Azimuth"
      unique_id: 8eb9eec1-409c-447e-ad60-aeb3d6d043d4
      icon: mdi:sun-compass
      unit_of_measurement: "°"
      state_class: measurement
      state: "{{ state_attr('sun.sun', 'azimuth') }}"
- sensor:
    - name: "Sun Elevation"
      unique_id: cb321e75-73e1-45a3-84f2-d3306bb579f4
      icon: mdi:sun-angle
      unit_of_measurement: "°"
      state_class: measurement
      state: "{{ state_attr('sun.sun', 'elevation') }}"

It’s working fine, but for creating such a template sensor also for planet data, I would need the planet data first.

I could not help on the planet data feeds, but am curious: What kind of automation would you need the planet data for?

It’s not an automation, it’s a very nice card showing the movement of sun & moon and the positions of the planets.

I am using this one in combination with compass-card: Astronomy API - Free To Use, Astronomy API For Developers

this is the sensor from which I can use it in the card…with jq one can bend/squeeze/fold more if/where needed of course

command_line:
  - sensor:
        name: Planetary Positions
        command: >
            curl -X GET 'https://api.astronomyapi.com/api/v2/bodies/positions?longitude=YOURLON&latitude=YOURLAT&elevation=50&from_date={{ now().date() }}&to_date={{ now().date() }}&time={{ now().strftime('%H:%M:%m') }}' -H 'Authorization: Basic YOURAPIKEY' | jq '{"planets": .[].table.rows}'
        value_template: "{{ now() }}"
        json_attributes:
            - planets
        scan_interval: 600
1 Like

At the risk of being shouted down here, I find the separate app Heavens Above is up to date, knows my current orientation in all four dimensions, and even has night mode and search abilities for when I actually venture outside to see a new passing comet. Highly recommended.

Now back to trying to squeeze all the stars into your display, and have it update in real time, and add random star music in the background…

You want it for when? Yesterday, tomorrow? 2038? Music too?

A beautiful sympathy for you if you missed out on the lovely aurora display the other evening. [Not my video - done in 2018 - click through for the back story - actually time lapse, not direct video]

I have seen a most wonderful aurora display around 30 years ago in unexpected latitudes that reminds me of this. Enjoy the beautifully haunting music too.

For Sun and Moon data, you can that from the following integration:

And from the same author, there is the UpTonight scripts to get the planet data but it looks a little more involved to get setup.

Thanks a lot for this command_line sensor, this was exactly the solution I was searching for - and it’s already working.