UK Health Security Agency Alerts

I think this is quite new, so if anyone’s interested…

The UK Health Security Agency has a free API which carries health alerts. The first of the summer’s heat warnings was issued today, but it also includes warnings about covid, flu etc. Same principle as weather and flood warnings.

https://ukhsa-dashboard.data.gov.uk/access-our-data/overview

1 Like

Thanks!

I was scraping the hot weather alerts until now and will take a look at this tomorrow,

I’ll be sure to copy whatever you come up with! :grin:

well that was fun.

The documentation isn’t great but, whilst I found the API metric heat-alert_headline_matrixNumber, I cannot find the path to get to it (beyond https://api.ukhsa-dashboard.data.gov.uk/ as following that path always ends up with historical data.

Perhaps someone else can see what I am missing? …I’ve popped off a request via their feedback page but not holding my breath.


edit: In the interim, if anyone wants to scrape, this is what I am using:

  • Set for the south-east but just change that in the url. You can work out your area here.
  • All but sensor.uk_cold_alert & sensor.uk_heat_alert will show as unavailable if there is no alert. I use jazzyisj’s excellent unavailable-entities-sensor and ignore them with a label.
  • the markdown cards are sensitive to spaces and newlines so copy exactly.
Scrape
scrape: #- restart required for changes ----------------------------------------

  - resource:  https://ukhsa-dashboard.data.gov.uk/weather-health-alerts/cold/south-east
    scan_interval: 86400 # 1/day in secs # default is 600
    sensor:

      - name: "uk_cold_alert"
        unique_id: "uk_cold_alert"
        icon: mdi:thermometer-low
        select: "#main-content > div > div.govuk-grid-row > div:nth-child(2) > div.govuk-grid-row > div > dl > div:nth-child(2) > div"
        value_template: "{{ value }}"

      - name: "uk_cold_alert_score"
        unique_id: "uk_cold_alert_score"
        icon: mdi:thermometer-low
        select: "#main-content > div > div.govuk-grid-row > div:nth-child(2) > div.govuk-grid-row > div > dl > div:nth-child(3) > dd"
        value_template: "{{ value }}"

      - name: "uk_cold_alert_liklihood"
        unique_id: "uk_cold_alert_liklihood"
        icon: mdi:thermometer-low
        select: "#main-content > div > div.govuk-grid-row > div:nth-child(2) > div.govuk-grid-row > div > dl > div:nth-child(5) > dd"
        value_template: "{{ value }}"

      - name: "uk_cold_alert_start"
        unique_id: "uk_cold_alert_start"
        icon: mdi:thermometer-low
        select: "#main-content > div > div.govuk-grid-row > div:nth-child(2) > div.govuk-grid-row > div > dl > div:nth-child(6) > dd"
        value_template: "{{ value }}"

      - name: "uk_cold_alert_end"
        unique_id: "uk_cold_alert_end"
        icon: mdi:thermometer-low
        select: "#main-content > div > div.govuk-grid-row > div:nth-child(2) > div.govuk-grid-row > div > dl > div:nth-child(7) > dd"
        value_template: "{{ value }}"

  - resource:  https://ukhsa-dashboard.data.gov.uk/weather-health-alerts/heat/south-east
    scan_interval: 86400 # 1/day in secs # default is 600
    sensor:

      - name: "uk_heat_alert"
        unique_id: "uk_heat_alert"
        icon: mdi:thermometer-high
        select: "#main-content > div > div.govuk-grid-row > div:nth-child(2) > div.govuk-grid-row > div > dl > div:nth-child(2) > div"
        value_template: "{{ value }}"

      - name: "uk_heat_alert_score"
        unique_id: "uk_heat_alert_score"
        icon: mdi:thermometer-high
        select: "#main-content > div > div.govuk-grid-row > div:nth-child(2) > div.govuk-grid-row > div > dl > div:nth-child(3) > dd"
        value_template: "{{ value }}"

      - name: "uk_heat_alert_liklihood"
        unique_id: "uk_heat_alert_liklihood"
        icon: mdi:thermometer-high
        select: "#main-content > div > div.govuk-grid-row > div:nth-child(2) > div.govuk-grid-row > div > dl > div:nth-child(5) > dd"
        value_template: "{{ value }}"

      - name: "uk_heat_alert_start"
        unique_id: "uk_heat_alert_start"
        icon: mdi:thermometer-high
        select: "#main-content > div > div.govuk-grid-row > div:nth-child(2) > div.govuk-grid-row > div > dl > div:nth-child(6) > dd"
        value_template: "{{ value }}"

      - name: "uk_heat_alert_end"
        unique_id: "uk_heat_alert_end"
        icon: mdi:thermometer-high
        select: "#main-content > div > div.govuk-grid-row > div:nth-child(2) > div.govuk-grid-row > div > dl > div:nth-child(7) > dd"
        value_template: "{{ value }}"
Card
    - type: conditional
      conditions:
        - entity: sensor.uk_heat_alert
          state_not: "No alert"
      card:
        type: markdown
        content: >
          {% set heat = states('sensor.uk_heat_alert')[:-6] %}
          
          |  |  |

          | -: | -- |

          | <font color = {%- if 'yellow' == heat %} 'gold' {%- elif 'amber' == color %}'darkorange' {%- else %}'firebrick' {%- endif %}>
          <ha-icon icon="mdi:fire">
          </ha-icon></font>
          | <a href='https://ukhsa-dashboard.data.gov.uk/weather-health-alerts/heat/south-east'> **{{ heat }} heat alert** </a>
          |

          | from: | **{{ states('sensor.uk_heat_alert_start') }}** |

          | to: | **{{ states('sensor.uk_heat_alert_end') }}** |

    - type: conditional
      conditions:
        - entity: sensor.uk_cold_alert
          state_not: "No alert"
      card:
        type: markdown
        content: >
          {% set cold = states('sensor.uk_cold_alert')[:-6] %}

          |  |  |

          | -: | -- |

          | <font color = {%- if 'yellow' == cold %} 'gold' {%- elif 'amber' == color %}'darkorange' {%- else %}'firebrick' {%- endif %}>
          <ha-icon icon="mdi:fire">
          </ha-icon></font>
          | <a href='https://ukhsa-dashboard.data.gov.uk/weather-health-alerts/cold/south-east'> **{{ cold }} cold alert** </a>
          |

          | from: | **{{ states('sensor.uk_cold_alert_start') }}** |

          | to: | **{{ states('sensor.uk_cold_alert_end') }}** |

The result are 2 cards that compliment the Severe Weather Warnings from this thread (The heat card is the bottom one, the Severe Weather Warning is the top one).

2 Likes

How about this: https://ukhsa-dashboard.data.gov.uk/api/proxy/alerts/v1/heat ?

GET /api/proxy/alerts/v1/heat HTTP/1.1
Host: ukhsa-dashboard.data.gov.uk

It returns a JSON response:

[
    {
        "status": "Green",
        "geography_name": "North East",
        "geography_code": "E12000001",
        "refresh_date": "2025-06-11T10:14:35+01:00"
    },
    {
        "status": "Green",
        "geography_name": "North West",
        "geography_code": "E12000002",
        "refresh_date": "2025-06-11T10:14:35+01:00"
    },
    ...
    {
        "status": "Green",
        "geography_name": "South West",
        "geography_code": "E12000009",
        "refresh_date": "2025-06-11T10:14:35+01:00"
    }
]
1 Like

how did you work that out? …eager to learn!

Just poking around behind the scenes of the UKHSA data dashboard—basically opening up developer tools in the browser and checking out the network traffic. Sometimes you get lucky and find a proper API, but no such luck with this one.

1 Like

The UKHSA API might still be under development. There are API docs showing a public API v2. But, when I navigate the tree, I can’t yet find a sub_theme for heat or cold alerts.

1 Like

I’ll circle back to this every so often and check