Skip to content

Implement beach_conditions and wind_conditions providers via CatalunyaBeachesAdapter - #70

Merged
tamaygz merged 6 commits into
mainfrom
copilot/implement-beach-conditions-wind-conditions
Jul 2, 2026
Merged

Implement beach_conditions and wind_conditions providers via CatalunyaBeachesAdapter#70
tamaygz merged 6 commits into
mainfrom
copilot/implement-beach-conditions-wind-conditions

Conversation

Copilot AI commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Both beach_conditions and wind_conditions providers were scaffold stubs inheriting StubBriefingProvider and returning placeholder text. This replaces them with real implementations backed by the ha-catalunya-beaches HACS integration.

Adapter (adapters/catalunya_beaches.py)

Expanded from a 2-line stub to a full multi-entity reader. Accepts any Catalunya Beaches entity as source_ref, extracts the beach name prefix by stripping known suffixes, then reads all 10 sensor and 5 binary sensor entities in a single fetch:

# User picks any beach entity, e.g. sensor.platja_de_barcelona_water_quality
# Adapter derives prefix "platja_de_barcelona" and reads:
{
    "sensors": {"water_quality": "Excellent", "water_temperature": "24", "wind_speed": "18", ...},
    "binary_sensors": {"lifeguard_present": True, "jellyfish_alert": False, ...}
}

providers/beach_conditions.py

  • Summarises water quality, temperature, jellyfish presence, UV index, lifeguard status
  • Alert rules: jellyfish binary on → warning; water quality Poorwarning, Very Poorcritical; water quality binary off (fallback) → warning; out of season → info
  • Dedicated out_of_season scenario when beach is closed for the season

providers/wind_conditions.py

  • Summarises wind speed, wave height, sky condition, air temperature
  • Alert rules: wind ≥ 40 km/h → warning, ≥ 60 km/h → critical; waves ≥ 1.5 m → warning, ≥ 2.5 m → critical

Tests

14 new tests in test_providers.py covering normalization, alert emission for each threshold, error/unavailable handling, and dashboard fragment structure. test_provider_schemas.py updated to reflect that both providers now have supports_alerts = True (only home_status remains a stub with alerts off).

Docs

docs/setup.md documents the ha-catalunya-beaches prerequisite and explains how prefix derivation works so users know they can pick any beach entity as the source.

…talunyaBeachesAdapter

- Expand adapters/catalunya_beaches.py to read all related beach entities
  by deriving the beach prefix from any Catalunya Beaches entity_id
- Replace beach_conditions scaffold with real provider: collects water quality,
  temperature, jellyfish status, UV index, lifeguard presence; emits alerts for
  jellyfish (warning), poor/very-poor water quality (warning/critical), and
  out-of-season (info)
- Replace wind_conditions scaffold with real provider: collects wind speed,
  wave height, sky condition, air temperature; emits alerts for elevated/
  dangerous wind (warning/critical) and rough/dangerous waves (warning/critical)
- Neither provider inherits StubBriefingProvider logic for normalize(); both
  implement get_adapter() and normalize() with real data
- Add 14 new provider tests covering normalization, alert emission, error
  handling, and dashboard fragments
- Update test_provider_schemas to reflect that beach/wind now support alerts
- Update docs/setup.md with prerequisites for beach/wind snippets
- Update TODO.md and AGENTS.md to mark issue #55 complete

Closes #55
Copilot AI changed the title [WIP] Implement beach_conditions and wind_conditions providers Implement beach_conditions and wind_conditions providers via CatalunyaBeachesAdapter Jul 2, 2026
Copilot AI requested a review from tamaygz July 2, 2026 15:21
@tamaygz
tamaygz requested a review from Copilot July 2, 2026 15:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 replaces the previously scaffolded beach_conditions and wind_conditions providers with real implementations backed by a new CatalunyaBeachesAdapter, enabling adapter-based multi-entity beach snapshots (including alert emission) and adding tests/docs to support the new functionality.

Changes:

  • Implemented CatalunyaBeachesAdapter to derive a beach prefix from a chosen entity and fetch a structured set of related sensor/binary_sensor states.
  • Implemented real BeachConditionsProvider and WindConditionsProvider with human-readable summaries, alert thresholds, and dashboard fragments.
  • Added/updated tests and documentation to reflect the new providers and their prerequisites.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
TODO.md Marks the beach/wind provider task as completed.
custom_components/user_briefing/adapters/catalunya_beaches.py Replaces adapter stub with multi-entity fetch logic and prefix extraction.
custom_components/user_briefing/providers/beach_conditions.py Implements beach conditions summary + alert emission via CatalunyaBeachesAdapter.
custom_components/user_briefing/providers/wind_conditions.py Implements wind/sea conditions summary + alert emission via CatalunyaBeachesAdapter.
tests/test_providers.py Adds provider-level tests for beach/wind normalization and alert thresholds.
tests/test_provider_schemas.py Updates schema expectations to reflect beach/wind now supporting alerts.
docs/setup.md Documents the ha-catalunya-beaches prerequisite and how source entity selection works.
AGENTS.md Updates project status/docs to reflect beach/wind providers are no longer stubbed.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread custom_components/user_briefing/adapters/catalunya_beaches.py
Comment thread custom_components/user_briefing/adapters/catalunya_beaches.py Outdated
Comment thread docs/setup.md Outdated
tamaygz and others added 2 commits July 2, 2026 17:38
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.

Comment thread custom_components/user_briefing/providers/beach_conditions.py Outdated
Comment thread custom_components/user_briefing/providers/wind_conditions.py Outdated
Comment thread custom_components/user_briefing/adapters/catalunya_beaches.py Outdated
Comment thread docs/setup.md Outdated
@tamaygz
tamaygz marked this pull request as ready for review July 2, 2026 18:18
@tamaygz
tamaygz merged commit bfe7f04 into main Jul 2, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement beach_conditions and wind_conditions providers

3 participants