Home

Awesome

Hourly Weather Card by @decompil3d

An hourly weather card for Home Assistant. Visualize upcoming weather conditions as a colored horizontal bar.

GitHub Release License hacs_badge

Project Maintenance GitHub Activity

Lovelace Hourly Weather

Screenshot of Hourly Weather card

Installation

Easiest method:

✨ Install via HACS

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

Alternative method:

  1. Download hourly-weather.js from the Releases page
  2. Upload to /www/hourly-weather/hourly-weather.js (via Samba, File Editor, SSH, etc.)
  3. Visit the Resources page in your Home Assistant install and add /hourly-weather/hourly-weather.js as a JavaScript Module. Open your Home Assistant instance and show your dashboard resources.
  4. Refresh your browser

Usage

This card will show in the "Add card" modal. It has a GUI editor for configuring settings.

If you prefer YAML, here is a sample config:

type: custom:hourly-weather
entity: weather.my_weather_entity
num_segments: 18 # optional, defaults to 12
name: Next 18 hours # optional, defaults to "Hourly Weather"

Choosing the right entity

This card is focused on displaying hourly weather data. It will work with coarser- or finer-grained data, though. I've tested with the OpenWeatherMap integration using the onecall_hourly mode and that works very well.

As of Home Assistant 2023.9.0, most weather integrations provide data in multiple time increments. If your weather entity provides hourly data, the card will use that by default. Otherwise, the card will attempt to use the finest-grained increments available, unless you have configured otherwise.

ℹ️ NOTE: If your selected weather entity provides forecasts in increments of greater than one hour at a time, each segment of the bar will be for one segment, not one hour.

Prior to Home Assistant version 2023.9.0, if you already use OpenWeatherMap for daily data, you can add a second integration of the same component for hourly -- just adjust the latitude or longitude a tiny bit (i.e. change the last decimal by 1). Otherwise, the integration may complain of a duplicate unique ID.

Options

NameTypeRequirementDescriptionDefault
typestringRequiredcustom:hourly-weather
entitystringRequiredHome Assistant weather entity ID.
forecast_typestringOptionalThe type of forecast data to use. One of hourly, daily, or twice-daily. If not specified, the card will attempt to use the finest-grained data available.
namestringOptionalCard name (set to null to hide)Hourly Weather
iconsboolOptionalWhether to show icons instead of text labelsfalse
num_segmentsnumberOptionalNumber of forecast segments to show (integer >= 1)12
num_hoursnumberOptionalDeprecated: Use num_segments instead12
offsetnumberOptionalNumber of forecast segments to offset from start0
label_spacingnumberOptionalSpace between time/temperature labels (integer >= 1)2
colorsobjectOptionalSet colors for all or some conditions
hide_hoursboolOptionalWhether to hide hour labels under the barfalse
hide_temperaturesboolOptionalWhether to hide temperatures under the barfalse
round_temperaturesboolOptionalWhether to round temperatures to the nearest whole numberfalse
hide_barboolOptionalWhether to hide the bar itselffalse
icon_fillIcon FillOptionalWhether to repeat the icon inside the bar'single
show_windWindOptionalWhether to show wind speed and/or direction under the bar'false'
show_precipitation_amountsboolOptionalWhether to show precipitation (rain) amount under the barfalse
show_precipitation_probabilityboolOptionalWhether to show precipitation (rain) probability under the barfalse
show_datestringOptionalWhether to show date under the bar'false'
tap_actionobjectOptionalAction to take on tapaction: more-info
hold_actionobjectOptionalAction to take on holdnone
double_tap_actionobjectOptionalAction to take on double tapnone
languagestringOptionalLanguage to use for card (overrides HA & user settings)

Note that some of the more advanced options are not available in the card editor UI and must be configured via YAML.

Templating

The following options allow Home Assistant Jinja templates as values:

You may use any valid template expression that produces a string or number. For example, you can define offset based on the current time of day so that you see the next day's weather:

name: Tomorrow
num_segments: 24
offset: |
  {{ 24 - now().hour }}
label_spacing: 4

Or maybe show the rest of today's weather:

name: Today
num_segments: |
  {{ 24 - now().hour }}
label_spacing: |
  {% set segments = 24 - now().hour %}
  {{ 4 if segments > 12 else 2 }}

Action Options

NameTypeRequirementDescriptionDefault
actionstringRequiredAction to perform (more-info, toggle, call-service, navigate url, none)more-info
navigation_pathstringOptionalPath to navigate to (e.g. /lovelace/0/) when action defined as navigatenone
urlstringOptionalURL to open on click when action is url. The URL will open in a new tabnone
servicestringOptionalService to call (e.g. media_player.media_play_pause) when action defined as call-servicenone
service_dataobjectOptionalService data to include (e.g. entity_id: media_player.bedroom) when action defined as call-servicenone
hapticstringOptionalHaptic feedback success, warning, failure, light, medium, heavy, selectionnone
repeatnumberOptionalHow often to repeat the hold_action in milliseconds.none

Color Options

colors is specified as an object containing one or more of the keys listed below and values that are valid CSS colors or objects of foreground and/or background valid CSS colors. Invalid color values will be discarded and will trigger a warning.

Color value format

Colors may be specified as a valid CSS color string or as an object with one or more of the following fields, each containing a valid CSS color string:

If color is specified as a plain string, it will be used for background. Foreground color defaults to the primary text color in your Home Assistant theme.

Some conditions will default to whatever the value is of some other condition. For example, fog will default to whatever cloudy is.

KeyDefault
clear-night#000
cloudy#777
fogsame as cloudy
hail#2b5174
lightningsame as rainy
lightning-rainysame as rainy
partlycloudy#b3dbff
pouringsame as rainy
rainy#44739d
snowy#fff
snowy-rainysame as partlycloudy
sunny#90cbff
windysame as sunny
windy-variantsame as sunny
exceptional#ff9d00

Sample colors configuration

colors:
  sunny: '#bbccee' # note that hex colors must be quoted
  snowy-rainy: rgba(255, 255, 255, 0.8) # rgba works (and hsla too)
  exceptional: red # as do valid CSS color names
  windy:
    background: lightgray
    foreground: '#000'

Wind Options

show_wind can be one of the following values:

Note: If your weather entity uses cardinal directions (e.g. 'N', 'SW', etc.) rather than numeric degrees for wind_bearing, the barb option is not supported and will result in an error.

Date Options

show_date can be one of the following values:

Icon Fill Options

icon_fill can be one of the following values:

NOTE: If a forecast segment is not wide enough to fit an icon, the icon will not be shown. That means that on narrow screens or with many segments, you may not see all icons. If that happens, consider using a larger numeric value for icon_fill or use single to show one icon per forecast span.

Upgrades

Version 3 ➡️ 4

In version 4.x, the num_hours option was deprecated in favor of num_segments. This simplifies the card and makes it clear that it operates on whatever size forecast segment your entity provides. The num_hours option still works, but num_segments takes precedence, if set. num_hours will be removed in a later major version of the card.

Version 4 ➡️ 5

In version 5.x, the DOM structure of the weather bar and its labels was changed to allow for odd-numbered segment counts and label spacing. Labels now appear centered with the segment they are representing, and the first label shown on the bar represents the first segment of data where in prior versions labels would begin at the second segment. This change may cause some custom CSS to break. If you have custom CSS, you may need to adjust it to account for the new structure.