/uvindex-chart-card

UV Index integration for Home Assistant

Primary LanguagePythonApache License 2.0Apache-2.0

Home Assistant EPA UV Index Integration

Note

This integration only provides data for locations in the United States.

Dashboard card showing UV Index

Dashboard card showing UV Index Hourly

Install instructions

Recommended: Install with HACS

hacs_badge

  1. Navigate to the HACS add-on. Go to "Integrations", if HACS has separate pages for Integrations and Frontend.

  2. Via the "..." menu at the top right, select "Custom repositories" and add https://github.com/davidn/epa_uvindex as type "Integration".

  3. If there is a "Explore & download respositories" button, click on and find the "EPA UV Index" integration. If you directly see a list of integrations, find the "EPA UV Index" integration (you may need to clear filters to see integrations that haven't been downloaded). Click on the integration and then click "Download".

  4. Restart Home Assitant.

  5. Go to Settings > Devices & Services, and on the Integration tab click "Add Integration". Select "EPA UV Index"

  6. Enter the nearest city and state.

You will now have a sensor that provides the UV Index in that city.

Manual Install

  1. Copy all files to config/custom_components.

  2. Restart Home Assistant.

  3. Go to Settings > Devices & Services, and on the Integration tab click "Add Integration". Select "EPA UV Index"

  4. Enter the nearest city and state.

You will now have a sensor that provides the UV Index in that city.

Example dashboard card

The gauge screenshot above is from the following dashboard card:

type: gauge
    entity: sensor.uv_index
    segments:
      - from: 0
        color: '#299501'
      - from: 3
        color: '#f7e401'
      - from: 6
        color: '#f95901'
      - from: 8
        color: '#d90011'
      - from: 11
        color: '#6c49C9'
    min: 1
    max: 12
    needle: true

The hourly card is can be found at https://github.com/davidn/uvindex-hourly.

Usage

This integration provides a single sensor called sensor.uv_index. The value of the sensor is the max UV index for the current day. The sensor also has a forecast attribute that provides hourly UV index predictions. This attribute is an array of dicts, each dict having a datetime and a uv_index entry with the time and UV index for that prediction. This comes directly from the EPA source, which currently provides a prediction for a sensible range of hours, on the hour, but could potentially change.

If you want a separate sensor with the current UV index, create a template sensor using the following template:

{% for forecast in state_attr("sensor.uv_index", "forecast") %}
  {% if forecast.datetime | as_local >= now() %}
    {{ forecast.uv_index }}
    {% break %}
  {% endif %}
{% endfor %}