🌘 Lunar Phase Integration for Home Assistant

:waning_crescent_moon: Lunar Phase Integration for Home Assistant

The Lunar Phase integration is a custom component for Home Assistant that provides detailed information about the current phase of the moon. This integration leverages precise astronomical calculations to deliver accurate lunar data, making it a valuable addition for those interested in astronomy, astrology, or just tracking the moon’s phases.

Features

  • Moon Phase Sensor: Displays the current phase of the moon (e.g., New Moon, Waxing Crescent, First Quarter, etc.).
  • Moon Age: Shows the age of the moon in days.
  • Distance to Moon: Provides the distance to the moon in kilometers.
  • Illumination Fraction: Indicates the fraction of the moon that is illuminated.
  • Moon Rise and Set Times: Displays the moon rise and set times.
  • Next New and Full Moon: Provides the dates for the next new moon and full moon.


Installation

HACS Installation

  1. Go to the HACS settings and add this repository as a custom repository.
  2. Search for “Lunar Phase” in HACS and install it.
  3. Restart Home Assistant.

Open your Home Assistant instance and open a repository inside the Home Assistant Community Store.

Manual Installation

  1. Download the lunar_phase folder from this repository.
  2. Copy the lunar_phase folder to your Home Assistant custom_components directory. The custom_components directory resides in the same directory as your configuration.yaml file.
  3. Restart Home Assistant.

Configuration

Using the Home Assistant UI

To configure the Lunar Phase integration, follow these steps:

  1. Go to the Home Assistant dashboard.
  2. Navigate to Configuration > Devices & Services > Add Integration.
  3. Search for Lunar Phase and select it.
  4. You will be prompted to enter the city for your location.
    • City: Enter the name of your city. If the city is not found in the database, you will be prompted to provide additional information:
      • Region: The region or state where the city is located.
      • Timezone: The timezone of the city.
      • Latitude: The latitude coordinate of the city.
      • Longitude: The longitude coordinate of the city.

Once configured, the integration will add the Moon Phase sensor along with other diagnostic sensors that provide detailed lunar information.

Sensor Details

Moon Phase Sensor

  • Name: Moon Phase
  • Attributes:
    • age: The age of the moon in days.
    • distance_km: The distance to the moon in kilometers.
    • illumination_fraction: The fraction of the moon that is illuminated.
    • moon_rise: The moon rise time.
    • moon_set: The moon set time.
    • next_full: The next full moon date.
    • next_new: The next new moon date.

Moon Age Sensor

  • Name: Moon Age
  • Unit: days

Moon Distance Sensors

  • Name: Moon Distance
  • Unit: km

Moon Illumination Fraction Sensor

  • Name: Moon Illumination Fraction
  • Unit: %

Moon Rise and Set Sensors

  • Name: Moon Rise
  • Device Class: timestamp
  • Name: Moon Set
  • Device Class: timestamp

Next Full and New Moon Sensors

  • Name: Next Full Moon
  • Device Class: timestamp
  • Name: Next New Moon
  • Device Class: timestamp

Contribution

Contributions are welcome! If you have any suggestions, issues, or feature requests, please open an issue or submit a pull request.


If you’re looking to add a visually appealing and informative lunar phase tracker to your Home Assistant dashboard, check out my custom Lunar Phase Card. This card provides detailed monthly phase information and integrates seamlessly with your existing setup. It’s a great addition for anyone interested in astronomy or simply wanting to keep track of the moon’s phases in a stylish way. You can find and install the Lunar Phase Card here.

Enjoy tracking the lunar phases with the Lunar Phase integration for Home Assistant! :moon:

8 Likes

Nice, but shouldn’t it take my latitude and longitude from my existing setup?

Also I don’t understand what moon age means? Currently 321:52:09 days. I am sure the moon is older than that :slight_smile:

Couldn’t resist,

1 Like

To be honest, this is my first custom component, which I drew from various tutorials and code studies from other developers. :sweat_smile: As a first attempt I tried to use data from configs, but the results for time attributes like next full moon etc were strange. So I finally chose the option for prime time zone setting, lat lon, then it gave better results.

This is the time in hours, as default for duration. Try selecting a different display for the sensor

The screenshot shows the unit of measurement is d or days. But what is it actually measuring?

That sensor shows the current age of the moon in days. It calculates the number of days since the last new moon


1 Like

Well mine says 320 days. I think this line should be HOURS rather than DAYS.

1 Like

The history tracking actually shows moon_age correctly as days but the UI for the integration shows hours despite the settings, sounds like a display bug to me.

1 Like

Mine has been stuck on 321:52:09 since I installed 24 hours hours ago.

I made a fix for the correct display, the problem was the device class duration, I set the unit directly as days.

1 Like

That seems to work, thanks :slightly_smiling_face:

1 Like

A custom card is available for this integration, offering a visually appealing and informative lunar phase tracker. Find and install the Lunar Phase Card here. :love_you_gesture:

2 Likes

Wonderfull ! Exactly what i’m looking for :slight_smile:
I would like to translate into french ? Could you tell me if it is possible and how ? :slight_smile:

Thanks for the job

Nice. Thanks.

1 Like

Hi, you can add another fr.json file to the translations folder. And when you have it, can I ask you to make it as PR, then I will add the update component? Thanks :smiley:

I like the latest update, thanks. However I’m left with this, should I be deleting these ‘Unavailable’ entities?

Hi, these entities are relegated to the diagnostic category. You can delete them. Or delete the integration and recreate with the same inputs. :slightly_smiling_face:

That’s what I though, just wanted to confirm. Thanks :slightly_smiling_face:

{
"name": "PortuguĂȘs BR",
"nativeName": "PortuguĂȘs",
"card": {
"phase": {
"firstQuarterMoon": "Primeiro quarto",
"fullMoon": "Lua cheia",
"thirdQuarterMoon": "Último quarto",
"newMoon": "Lua nova",
"waxingCrescentMoon": "Lua crescente crescente",
"waxingGibbousMoon": "Lua crescente convexa",
"waningCrescentMoon": "Lua minguante crescente",
"waningGibbousMoon": "Lua minguante convexa"
},
"illumination": "Iluminação",
"illuminated": "Iluminada",
"moonRise": "Nascer da lua",
"moonSet": "PĂŽr da lua",
"moonHigh": "Lua mais alta",
"moonAge": "Idade da lua",
"distance": "DistĂąncia",
"azimuth": "Azimute",
"altitude": "Altitude",
"fullMoon": "Lua cheia",
"newMoon": "Lua nova",
"relativeTime": {
"days": "dias",
"justNow": "agora mesmo",
"minutesAgo": "hĂĄ {0} minutos",
"hoursAgo": "hĂĄ {0} horas",
"inMinutes": "em {0} minutos",
"inHours": "em {0} horas"
}
},
"editor": {
"viewConfig": {
"title": "Idioma e modo de visualização",
"description": "Definir uma configuração para idioma e plano de fundo"
},
"baseConfig": {
"title": "Latitude e Longitude",
"description": "Definir uma configuração para latitude e longitude"
},
"optionsConfig": {
"useDefault": "Usar sistema",
"useEntity": "Usar entidade",
"useCustom": "Usar personalizado"
},
"compactView": "Visualização compacta",
"showBackground": "Mostrar plano de fundo",
"timeFormat": "Formato de 12 horas",
"placeHolder": {
"latitude": "Inserir latitude",
"longitude": "Inserir longitude",
"customBackground": "URL ou caminho para a imagem",
"language": "Selecionar idioma"
}
}
}

i dont know how to add the pt-br.json file in git, here it is, if you can upload hahaha

Hi @nickrout , I’ve seen the PR on the repo. New translations are added to main branch. I’ll add them to the new release in a week, thanks.