Skip to content

Added AuroraWatch UK Integration.#164544

Draft
agentgonzo wants to merge 5 commits intohome-assistant:devfrom
agentgonzo:dev
Draft

Added AuroraWatch UK Integration.#164544
agentgonzo wants to merge 5 commits intohome-assistant:devfrom
agentgonzo:dev

Conversation

@agentgonzo
Copy link
Copy Markdown

@agentgonzo agentgonzo commented Mar 1, 2026

https://aurorawatch.lancs.ac.uk/

Proposed change

Added integration for Aurora Watch UK
https://aurorawatch.lancs.ac.uk/

This adds the geomagnetic activity from the University of Lancaster

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

Checklist

  • I understand the code I am submitting and can explain how it works.
  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • The code has been formatted using Ruff (ruff format homeassistant tests)
  • Tests have been added to verify that the new code works.
  • Any generated code has been carefully reviewed for correctness and compliance with project standards.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies a diff between library versions and ideally a link to the changelog/release notes is added to the PR description.

To help with the load of incoming pull requests:

Copy link
Copy Markdown

@home-assistant home-assistant bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @agentgonzo,

When attempting to inspect the commits of your pull request for CLA signature status among all authors we encountered commit(s) which were not linked to a GitHub account, thus not allowing us to determine their status(es).

The commits that are missing a linked GitHub account are the following:

Unfortunately, we are unable to accept this pull request until this situation is corrected.

Here are your options:

  1. If you had an email address set for the commit that simply wasn't linked to your GitHub account you can link that email now and it will retroactively apply to your commits. The simplest way to do this is to click the link to one of the above commits and look for a blue question mark in a blue circle in the top left. Hovering over that bubble will show you what email address you used. Clicking on that button will take you to your email address settings on GitHub. Just add the email address on that page and you're all set. GitHub has more information about this option in their help center.

  2. If you didn't use an email address at all, it was an invalid email, or it's one you can't link to your GitHub, you will need to change the authorship information of the commit and your global Git settings so this doesn't happen again going forward. GitHub provides some great instructions on how to change your authorship information in their help center.

    • If you only made a single commit you should be able to run
      git commit --amend --author="Author Name <email@address.com>"
      
      (substituting "Author Name" and "email@address.com" for your actual information) to set the authorship information.
    • If you made more than one commit and the commit with the missing authorship information is not the most recent one you have two options:
      1. You can re-create all commits missing authorship information. This is going to be the easiest solution for developers that aren't extremely confident in their Git and command line skills.
      2. You can use this script that GitHub provides to rewrite history. Please note: this should be used only if you are very confident in your abilities and understand its impacts.
    • Whichever method you choose, I will come by to re-check the pull request once you push the fixes to this branch.

We apologize for this inconvenience, especially since it usually bites new contributors to Home Assistant. We hope you understand the need for us to protect ourselves and the great community we all have built legally. The best thing to come out of this is that you only need to fix this once and it benefits the entire Home Assistant and GitHub community.

Thanks, I look forward to checking this PR again soon! ❤️

Copy link
Copy Markdown

@home-assistant home-assistant bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @agentgonzo

It seems you haven't yet signed a CLA. Please do so here.

Once you do that we will be able to review and accept this pull request.

Thanks!

@agentgonzo agentgonzo changed the title Added AuroraWatch. Added AuroraWatch UK. Mar 1, 2026
@agentgonzo agentgonzo changed the title Added AuroraWatch UK. Added AuroraWatch UK Integration. Mar 1, 2026
Copy link
Copy Markdown

@home-assistant home-assistant bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @agentgonzo,

When attempting to inspect the commits of your pull request for CLA signature status among all authors we encountered commit(s) which were not linked to a GitHub account, thus not allowing us to determine their status(es).

The commits that are missing a linked GitHub account are the following:

Unfortunately, we are unable to accept this pull request until this situation is corrected.

Here are your options:

  1. If you had an email address set for the commit that simply wasn't linked to your GitHub account you can link that email now and it will retroactively apply to your commits. The simplest way to do this is to click the link to one of the above commits and look for a blue question mark in a blue circle in the top left. Hovering over that bubble will show you what email address you used. Clicking on that button will take you to your email address settings on GitHub. Just add the email address on that page and you're all set. GitHub has more information about this option in their help center.

  2. If you didn't use an email address at all, it was an invalid email, or it's one you can't link to your GitHub, you will need to change the authorship information of the commit and your global Git settings so this doesn't happen again going forward. GitHub provides some great instructions on how to change your authorship information in their help center.

    • If you only made a single commit you should be able to run
      git commit --amend --author="Author Name <email@address.com>"
      
      (substituting "Author Name" and "email@address.com" for your actual information) to set the authorship information.
    • If you made more than one commit and the commit with the missing authorship information is not the most recent one you have two options:
      1. You can re-create all commits missing authorship information. This is going to be the easiest solution for developers that aren't extremely confident in their Git and command line skills.
      2. You can use this script that GitHub provides to rewrite history. Please note: this should be used only if you are very confident in your abilities and understand its impacts.
    • Whichever method you choose, I will come by to re-check the pull request once you push the fixes to this branch.

We apologize for this inconvenience, especially since it usually bites new contributors to Home Assistant. We hope you understand the need for us to protect ourselves and the great community we all have built legally. The best thing to come out of this is that you only need to fix this once and it benefits the entire Home Assistant and GitHub community.

Thanks, I look forward to checking this PR again soon! ❤️

agentgonzo pushed a commit to agentgonzo/home-assistant.io that referenced this pull request Mar 1, 2026
agentgonzo added a commit to agentgonzo/home-assistant.io that referenced this pull request Mar 1, 2026
agentgonzo added a commit to agentgonzo/home-assistant.io that referenced this pull request Mar 1, 2026
@agentgonzo agentgonzo marked this pull request as ready for review March 17, 2026 21:07
Copilot AI review requested due to automatic review settings March 17, 2026 21:07
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new Home Assistant core integration (aurorawatch) to monitor AuroraWatch UK geomagnetic/aurora status via cloud polling.

Changes:

  • Introduces a new AuroraWatch UK config flow, coordinator, base entity, and sensor platform.
  • Adds translations (strings.json) and icons metadata (icons.json) plus integration artwork.
  • Adds initial test coverage for config flow and sensor behavior.

Reviewed changes

Copilot reviewed 13 out of 15 changed files in this pull request and generated 16 comments.

Show a summary per file
File Description
homeassistant/components/aurorawatch/__init__.py Sets up/unloads the config entry and wires the coordinator to the sensor platform
homeassistant/components/aurorawatch/config_flow.py Provides a simple “confirm setup” config flow (single-instance)
homeassistant/components/aurorawatch/const.py Defines API endpoints, polling interval, and attribute keys
homeassistant/components/aurorawatch/coordinator.py Fetches/parses the AuroraWatch XML endpoints and exposes coordinator data
homeassistant/components/aurorawatch/entity.py Defines the shared CoordinatorEntity base, device info, unique IDs
homeassistant/components/aurorawatch/sensor.py Implements the “aurora status” and “geomagnetic activity” sensors
homeassistant/components/aurorawatch/manifest.json Declares integration metadata (domain, docs URL, config flow, etc.)
homeassistant/components/aurorawatch/strings.json Adds config flow and entity translation strings
homeassistant/components/aurorawatch/icons.json Adds default icons for the sensors
homeassistant/components/aurorawatch/icon.png / logo.png Adds integration icon and logo assets
tests/components/aurorawatch/__init__.py Adds a small helper to set up the integration in tests
tests/components/aurorawatch/conftest.py Adds fixtures and sample XML payloads for tests
tests/components/aurorawatch/test_config_flow.py Tests the basic config flow and “already configured” abort
tests/components/aurorawatch/test_sensor.py Tests entity creation, states/attributes, and error scenarios

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines +53 to +57
@property
def extra_state_attributes(self):
"""Return the state attributes."""
if not self.coordinator.data:
return {}
Comment thread homeassistant/components/aurorawatch/sensor.py Outdated
Comment thread tests/components/aurorawatch/conftest.py Outdated
Comment thread homeassistant/components/aurorawatch/entity.py Outdated
Comment thread homeassistant/components/aurorawatch/coordinator.py Outdated
Comment on lines +170 to +174
# Mock invalid XML response (missing required fields)
mock_response = AsyncMock()
mock_response.text = AsyncMock(return_value=MOCK_INVALID_STATUS_XML)
mock_response.raise_for_status = AsyncMock()
mock_session.get.return_value = mock_response
Comment thread homeassistant/components/aurorawatch/sensor.py Outdated
Comment on lines +47 to +51
def native_value(self):
"""Return the state of the sensor."""
if self.coordinator.data:
return self.coordinator.data.get("status")
return None
Comment on lines +109 to +111
except Exception as err:
_LOGGER.error("Error fetching AuroraWatch data: %s", err)
raise UpdateFailed(f"Error communicating with API: {err}") from err
Comment thread homeassistant/components/aurorawatch/coordinator.py Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 17, 2026 21:29
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a new Home Assistant integration, aurorawatch, to monitor AuroraWatch UK geomagnetic/aurora status via a cloud-polled API, including config flow, coordinator-based data fetching, sensor entities, and accompanying tests/translations/icons.

Changes:

  • Added aurorawatch integration scaffolding (manifest, config flow, coordinator, entities, sensors, translations, icons).
  • Implemented polling of AuroraWatch UK XML endpoints and exposed two sensors (status + geomagnetic activity).
  • Added pytest coverage for config flow and sensor behavior (including failure scenarios).

Reviewed changes

Copilot reviewed 13 out of 15 changed files in this pull request and generated 12 comments.

Show a summary per file
File Description
homeassistant/components/aurorawatch/__init__.py Sets up/unloads the integration and forwards platforms
homeassistant/components/aurorawatch/config_flow.py Provides UI-based setup flow
homeassistant/components/aurorawatch/const.py Defines domain/constants, endpoints, and polling interval
homeassistant/components/aurorawatch/coordinator.py Fetches/parses AuroraWatch XML data via a coordinator
homeassistant/components/aurorawatch/entity.py Base coordinator entity + device info + unique ID
homeassistant/components/aurorawatch/sensor.py Implements the two sensor entities
homeassistant/components/aurorawatch/manifest.json Declares integration metadata
homeassistant/components/aurorawatch/strings.json Adds config flow + entity name translations
homeassistant/components/aurorawatch/icons.json Supplies entity icons
homeassistant/components/aurorawatch/icon.png Integration icon asset
homeassistant/components/aurorawatch/logo.png Integration logo asset
tests/components/aurorawatch/__init__.py Test helper for setting up the integration
tests/components/aurorawatch/conftest.py Test fixtures and mocked XML responses
tests/components/aurorawatch/test_config_flow.py Config flow tests
tests/components/aurorawatch/test_sensor.py Sensor/entity/coordinator behavior tests

You can also share your feedback on Copilot code review. Take the survey.

Comment thread homeassistant/components/aurorawatch/coordinator.py
Comment on lines +109 to +111
except Exception as err:
_LOGGER.error("Error fetching AuroraWatch data: %s", err)
raise UpdateFailed(f"Error communicating with API: {err}") from err
Comment thread homeassistant/components/aurorawatch/coordinator.py
Comment thread homeassistant/components/aurorawatch/__init__.py
Comment thread homeassistant/components/aurorawatch/config_flow.py
Comment on lines +34 to +42
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload a config entry."""
# Unload platforms
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)

# Remove coordinator from hass.data
if unload_ok:
hass.data[DOMAIN].pop(entry.entry_id)

Comment thread homeassistant/components/aurorawatch/sensor.py Outdated
Comment thread homeassistant/components/aurorawatch/sensor.py Outdated
Comment thread homeassistant/components/aurorawatch/entity.py Outdated
Comment on lines +26 to +31
self._attr_unique_id = (
f"{coordinator.config_entry.entry_id}_{translation_key}"
)
self._attr_device_info = DeviceInfo(
entry_type=DeviceEntryType.SERVICE,
identifiers={(DOMAIN, coordinator.config_entry.entry_id)},
Copy link
Copy Markdown
Member

@joostlek joostlek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey 👋🏻,

There are a couple things going on with the PR:

  1. The CI is failing.
  2. You don't seem to have a proper development environment. Please make sure you have one as some files are missing from the PR
  3. The service specific details should be put in a package hosted on PyPI

@home-assistant home-assistant bot marked this pull request as draft March 17, 2026 21:43
@home-assistant
Copy link
Copy Markdown

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍

Learn more about our pull request process.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 17, 2026 23:28
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new Home Assistant core integration (aurorawatch) to monitor AuroraWatch UK geomagnetic activity and expose it via sensor entities, including config flow, translations, icons, and tests.

Changes:

  • Introduces the AuroraWatch UK integration with config flow, data update coordinator, base entity, and sensor platform.
  • Adds translations (strings.json) and entity icons (icons.json) plus integration branding assets.
  • Adds initial pytest coverage for config flow and sensor behavior/error handling.

Reviewed changes

Copilot reviewed 13 out of 15 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
homeassistant/components/aurorawatch/__init__.py Sets up/unloads the config entry and initializes the coordinator/platforms
homeassistant/components/aurorawatch/config_flow.py Implements a simple UI config flow (single-instance setup)
homeassistant/components/aurorawatch/const.py Defines domain, API endpoints, polling interval, and attribute keys
homeassistant/components/aurorawatch/coordinator.py Fetches and parses AuroraWatch XML data via DataUpdateCoordinator
homeassistant/components/aurorawatch/entity.py Provides a coordinator-backed base entity with device info/IDs
homeassistant/components/aurorawatch/sensor.py Exposes status + activity sensors backed by the coordinator
homeassistant/components/aurorawatch/strings.json Adds config flow and entity naming strings
homeassistant/components/aurorawatch/icons.json Adds default icons for the new sensors
homeassistant/components/aurorawatch/manifest.json Declares integration metadata and capabilities
homeassistant/components/aurorawatch/icon.png Integration icon asset
homeassistant/components/aurorawatch/logo.png Integration logo asset
tests/components/aurorawatch/__init__.py Test helper to set up the integration
tests/components/aurorawatch/conftest.py Shared fixtures and mocked XML responses
tests/components/aurorawatch/test_config_flow.py Tests config flow creation and duplicate handling
tests/components/aurorawatch/test_sensor.py Tests sensor states/attributes and failure behaviors

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines +17 to +23
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up AuroraWatch UK from a config entry."""
coordinator = AurowatchDataUpdateCoordinator(hass)

# Perform the first refresh and raise ConfigEntryNotReady on failure
await coordinator.async_config_entry_first_refresh()

Comment on lines +30 to +34
"""Set up the AuroraWatch sensor."""
coordinator = cast(
AurowatchDataUpdateCoordinator,
hass.data[DOMAIN][entry.entry_id],
)
Comment on lines +57 to +67
@property
def extra_state_attributes(self):
"""Return the state attributes."""
data = self.coordinator.data or {}
return {
ATTR_LAST_UPDATED: data.get("last_updated"),
ATTR_PROJECT_ID: data.get("project_id"),
ATTR_SITE_ID: data.get("site_id"),
ATTR_SITE_URL: data.get("site_url"),
ATTR_API_VERSION: data.get("api_version"),
}
Comment on lines +27 to +42
# Try to obtain the config entry ID from the coordinator if available.
config_entry = getattr(coordinator, "config_entry", None)
entry_id = getattr(config_entry, "entry_id", None)

if entry_id is not None:
base_id = entry_id
else:
# Fallback base ID when the coordinator has no config_entry.
# This avoids AttributeError while still providing a stable ID.
base_id = translation_key

self._attr_unique_id = f"{base_id}_{translation_key}"
self._attr_device_info = DeviceInfo(
entry_type=DeviceEntryType.SERVICE,
identifiers={(DOMAIN, base_id)},
manufacturer="Lancaster University",
except (AttributeError, KeyError) as err:
_LOGGER.error("Failed to extract data from XML: %s", err)
raise UpdateFailed(f"Failed to parse XML structure: {err}") from err

Comment on lines +76 to +92
# Mock session.get to return different responses based on URL
async def mock_get(url: str, *args, **kwargs):
"""Return an async context manager yielding the appropriate response."""
if "current-status.xml" in url:
response = mock_status_response
elif "sum-activity.xml" in url:
response = mock_activity_response
else:
response = AsyncMock()

context_manager = AsyncMock()
context_manager.__aenter__.return_value = response
context_manager.__aexit__.return_value = AsyncMock(return_value=None)

return context_manager

mock_session.get = mock_get
Comment on lines +137 to +148
with patch(
"homeassistant.components.aurorawatch.coordinator.async_get_clientsession"
) as mock_session_factory:
mock_session = AsyncMock()
mock_session_factory.return_value = mock_session

# Mock malformed XML response
mock_response = AsyncMock()
mock_response.text = AsyncMock(return_value=MOCK_MALFORMED_XML)
mock_response.raise_for_status = Mock()
mock_session.get.return_value = mock_response

Comment on lines +172 to +183
with patch(
"homeassistant.components.aurorawatch.coordinator.async_get_clientsession"
) as mock_session_factory:
mock_session = AsyncMock()
mock_session_factory.return_value = mock_session

# Mock invalid XML response (missing required fields)
mock_response = AsyncMock()
mock_response.text = AsyncMock(return_value=MOCK_INVALID_STATUS_XML)
mock_response.raise_for_status = Mock()
mock_session.get.return_value = mock_response

"config_flow": true,
"documentation": "https://www.home-assistant.io/integrations/aurorawatch",
"integration_type": "service",
"iot_class": "cloud_polling",
_LOGGER = logging.getLogger(__name__)


class AurowatchDataUpdateCoordinator(DataUpdateCoordinator):
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants