Home

Awesome

hacs_badge

Lovelace Horizon Card

A Home Assistant Dashboard Card available through the Home Assistant Community Store and inspired by Google Weather.

Lovelace Horizon Card is a fork of the original home-assistant-sun-card project by @AitorDB to continue the great work and distribute the responsibility of supporting and advancing the project among a team of people.

Consider joining us!

Introduction

The Horizon Card tracks the position of the Sun and the Moon over the horizon and shows the times of various Sun and Moon events, as well as their current azimuth and elevation, in a visually appealing and easy-to-read format.

Light theme default lookDark theme default look
Light theme full lookDark theme full look

How it works

The card will show the Sun and the Moon as they travel across the horizon from East to West. Both celestial bodies will be shown when above or below the horizon.

The current view shows a period of 24 hours centered around the local solar noon. This means that the Sun will continue to travel to the far end of the graph until it reaches solar midnight, which may be some time before or after midnight in your local time zone. Once solar midnight is reached, the view will reset and start showing the data for the next day.

In the Northern hemisphere, East is on the left, South is in the middle (when the Sun is in its highest position), and West is on the right. You are facing South and the Sun travels left-to-right.

In the Southern hemisphere, West is on the left, North is in the middle (when the Sun is in its highest position), and East is on the right. You are facing North and the Sun travels right-to-left. You can disable the direction flip by setting southern_flip: false.

The elevation of the Sun follows a predetermined curve that approximates the actual elevation, while the elevation of the Moon affects its vertical position in the graph. The scale for the Moon elevation is logarithmic, so lower elevations will appear higher (above horizon) or lower (below horizon).

If showing the moon phase is enabled, the icon will be rotated to match the approximate view for your latitude. You can disable this by setting moon_phase_rotation: 0 or set a different angle to match your location or preferences.

Installation

Please ensure you have HACS and the Sun integration enabled in your Home Assistant setup.

If you have My Home Assistant configured, simply click here:

Open your Home Assistant instance and open the lovelace-horizon-card project inside the Home Assistant Community Store.

Otherwise follow these steps:

  1. Make sure the HACS component is installed and working.
  2. Search for "Horizon Card" or lovelace-horizon-card in HACS and install the latest version.

Manual Installation

Installation via HACS is recommended, but a manual setup is supported.

<details> <summary>Show detailed instructions</summary>
  1. Download the latest lovelace-horizon-card.js file.

  2. If necessary, create a www folder in your configuration folder (where configuration.yaml is found).

  3. Copy the downloaded file into your www folder.

  4. Add the resources, depending on whether you manage your Lovelace resources via the UI or YAML:

    1. UI: Go to My Home Assistant and click Add resource (or navigate to Settings -> Dashboards -> Resources -> Add Resource) and enter:

      URL: /local/lovelace-horizon-card.js

      Type: JavaScript Module

    2. YAML: Add the configuration to your ui-lovelace.yaml:

      resources:
        - url: /local/lovelace-horizon-card.js
          type: module
      
  5. Restart Home Assistant.

</details>

Setup

Using UI

  1. Access your dashboard, enter edit mode, and click on Add card. You should be able to find Custom: Horizon Card in the list.
  2. In the UI editor, customize the card by modifying its configuration as detailed in the Config section below.

Note: If Custom: Horizon Card doesn't appear, clear the cache and reload the page.

Using YAML

  1. Add a new card with type: custom:horizon-card to your cards list and include any additional configuration from the Config section below.

Note: If you encounter an error like Custom element doesn't exist, clear the cache and reload the page.

Configuration

General options

NameAccepted valuesDescriptionDefault
titlestringCard titleDoesn't display a title by default
moonbooleanShows the Moon together with the Suntrue
refresh_periodnumberRefresh period between updates, in seconds60
fieldsSee belowFine-tuned control over visible fields
southern_flipbooleanDraws the graph in the opposite directiontrue in the Southern hemisphere, false in the Northern one
moon_phase_rotationnumberAngle in degrees for rotating the moon phase iconDetermined from the latitude

Advanced options

In general, you should not need to set any of these as they override Home Assistant's settings or set debug options.

NameAccepted valuesDescriptionDefault
languageSee belowChanges card languageHome Assistant language or English if not supported
time_formatlanguage, 12, 24Set to 12 or 24 to force 12/24 hour clocklanguage - uses default for configured language
number_formatlanguage, comma_decimal, decimal_commaSet to comma_decimal or decimal_comma to force 123.45/123,45 number formatlanguage - uses default for configured language
latitudenumberLatitude used for calculationsHome Assistant's latitude
longitudenumberLongitude used for calculationsHome Assistant's longitude
elevationnumberElevation (above sea) used for calculationsHome Assistant's elevation
time_zonestringTime zone (IANA) used for calculations and time presentationHome Assistant's time zone
nowDateOverrides the current moment shown on the cardNone, i.e., always show the current moment
debug_levelnumberSets debug level, 0 and up0, i.e., no debug

Visibility Fields

Supported settings inside the fields setting:

NameAccepted valuesDescriptionDefault
sunrisebooleanShow sunrise timetrue
sunsetbooleanShow sunset timetrue
dawnbooleanShow dawn timetrue
noonbooleanShow solar noon timetrue
duskbooleanShow dusk timetrue
azimuthbooleanShow Sun and Moon azimuthfalse
sun_azimuthbooleanShow Sun azimuththe value of azimuth
moon_azimuthbooleanShow Moon azimuththe value of azimuth
elevationbooleanShow Sun and Moon elevationfalse
sun_elevationbooleanShow Sun elevationthe value of elevation
moon_elevationbooleanShow Moon elevationthe value of elevation
moonrisebooleanShow moonrise timefalse
moonsetbooleanShow moonset timefalse
moon_phasebooleanShow the Moon phasefalse

Languages

Supported options for the language setting:

Caveats

The Moon phase name (if the field moon_phase is enabled) is obtained via the Moon integration. If the integration is not installed, the card will still show the Moon phase as a human-readable constant followed by (!), e.g., waning_gibbuous (!). Due to the way Home Assistant works, the localized Moon phase name will always be in Home Assistant's language and not in the language set for the card via the language option.

Example config

The following YAML configuration illustrates the use of all options.

type: custom:horizon-card
title: Example Horizon Card
moon: true
refresh_period: 60
fields:
  sunrise: true
  sunset: true
  dawn: true
  noon: true
  dusk: true
  azimuth: true
  sun_azimuth: true
  moon_azimuth: true
  elevation: true
  sun_elevation: true
  moon_elevation: true
  moonrise: true
  moonset: true
  moon_phase: true
southern_flip: false
moon_phase_rotation: -10
language: en
time_format: language
number_format: language
latitude: 42.55
longitude: 23.25
elevation: 1500
time_zone: Europe/Sofia
now: 2023-07-06T00:30:05+0300
debug_level: 0