Home assistant support for Opendata CWA (prvious Opendata CWB). The readme in Traditional Chinese.
This integration is based on OpenWeatherMap (@csparpa, pyowm) to develop.
You can install component with HACS custom repo: HACS > Integrations > 3 dots (upper top corner) > Custom repositories > URL: tsunglung/OpenCWB > Category: Integration
Or manually copy opencwb folder to custom_components folder in your config folder.
Then restart HA.
- Model one OpenCWA config entry as a farm/location with any number of native Home Assistant crop subentries.
- Add, edit, and remove crop records independently. Each crop keeps its own growth stage, planting date, area, warnings, notification, and irrigation-reference entities.
- Fetch city crop weather, catalog, and warning rules once per farm update, then build isolated per-crop snapshots. Stable subentry IDs prevent entity churn when crops are renamed or reordered.
- Existing 1.4.x single-crop settings migrate losslessly to the first crop subentry.
- Change the crop-name field to a searchable dropdown containing 127 official 高雄農來訊 crop names, while retaining custom entry for newly added or uncommon crops.
- Rendering the form does not contact the agricultural provider; agriculture remains disabled by default and failure-isolated.
- Add a fully optional nationwide agricultural guidance provider backed by 高雄農來訊: crop warnings/advisories, support status, notification payloads, and token-gated ET0/Kc/ETc/water-requirement references.
- The provider is disabled by default and failure-isolated. Missing configuration, timeout, authentication failure, malformed/stale data, or an unsupported crop never prevents CWA weather, forecasts, or official warnings from loading.
- Keep CWA and agricultural attribution separate. Missing agricultural data is never presented as a safe condition.
- Parse the CWA REST API
dataset/records/recordresponse shape as independent alert records, restoring each alert's official issue time, validity period, description, wind level, and expiry handling in Home Assistant.
- Preserve each CWA hazardous-weather dataset's own issue time, validity window, and official description instead of mixing metadata across simultaneous alerts.
- For land strong-wind advisories, show the official yellow/orange/red level, average-wind and gust Beaufort thresholds, equivalent lower-bound speeds, validity period, danger explanation, and actionable crop/greenhouse risk guidance.
- Agricultural impacts are explicitly labelled as threshold-based guidance, not an official CWA crop-loss forecast.
- Alert only when the CWA track approaches Taiwan, may affect the configured coordinates, and an official CWA typhoon warning is active; otherwise expose
monitoringwithout recommending a push notification. - Expose closest-distance, closest-approach-time, and risk-decision attributes for explainable dashboards and automations.
- Display unnamed systems using their CWA tropical-depression number, such as
Unnamed tropical depression TD12, instead ofUnknown ().
- Fix hazardous-weather notifications mixing the title and affected areas of an unmatched alert with aggregate location matches from other alerts.
- When multiple alerts match the configured location, include every matched alert in the notification and omit unrelated alerts.
- Add three ready-to-use notification sensors for official typhoon warnings, tropical cyclone pre-alerts, and hazardous weather alerts.
- Notification sensor attributes expose
title,message,severity,summary, andsource_datasetso automations can callnotify.*without complex templates.
- Improve hazardous-weather alert location matching for CWA special areas such as
恆春半島,蘭嶼綠島,基隆北海岸, and county mountain-area labels. - Add
matched_locations,unmatched_special_areas, andmatch_methodattributes to weather alert sensors. - Add parser regression tests for expired typhoon warnings, multiple tropical cyclones, missing track values, and special-area alert matching.
- Document optional CWA warning entities and automation examples.
- When an optional warning group is disabled in the integration options, remove its stale Home Assistant entities from the entity registry and current states.
- Add optional CWA official typhoon warning, tropical cyclone track, and hazardous weather alert entities.
- New integration options: official typhoon warning, tropical cyclone track, and hazardous weather alerts.
- Fix
onecall_dailystartup failure. - Root cause: the current / UV one-call request was incorrectly sent to
F-D0047-093, which returns404 Resource not foundfor the lon/lat/locationName/interval request shape. - Switch back to
F-D0047-091for one-call current / UV; daily forecast still comes from the existing legacy district-level forecast path. - This keeps
onecall_dailyworking without losing district-level forecast granularity.
- Fix
onecall_*UV index lookup for township / district locations such as新店區. - Keep the configured location name unchanged in Home Assistant.
- Internally upgrade district names to their parent city only for onecall current / UV requests.
- Keep forecast sensors on the original district-level forecast source, so UV works without sacrificing local forecast granularity.
- Verified live: UV index restored while forecast sensors remain normal.
- Restore forecast sensors that were stuck at
unknownafter the forecast model refactor. - Make forecast sensor extraction compatible with both native and serialized Forecast field names.
- Remove invalid hourly
templowhandling.
- Fix the update button so it no longer depends on a non-existent coordinator attribute.
- The button now records its own status fields in attributes:
update_statuslast_update_timeprevious_update_timelast_error(only when refresh fails)
- Keep the button grouped under the same device as the weather/sensor entities.
- Improve Home Assistant Weather Entity compatibility.
- Return proper
Forecastobjects for daily / hourly forecast. - Add native weather properties such as UV index and precipitation.
- Add an update button entity for immediate weather refresh.
- Fix older Home Assistant import compatibility issues.
Enable KCG agricultural guidance from Settings > Devices & services > OpenCWA > Configure. When disabled, OpenCWA does not construct the provider client/coordinator or make agricultural HTTP requests.
The main OpenCWA entry represents the farm/location and stores the shared enable switch and password-masked provider token. Use the native Add crop action on the OpenCWA integration page to add as many crop records, planting batches, or fields as needed. Every crop record independently stores its searchable crop name, growth stage, planting date, and cultivation area. Crop records can be edited or removed without changing other crop entities.
Each crop creates an independent agriculture device with warning, advisory, support, notification, ET0, Kc, ETc, and water-requirement entities. Entity identity uses the stable Home Assistant crop subentry ID rather than the editable crop name or list order.
The token is only required for ET0, Kc, ETc, and water-requirement endpoints; crop warnings and support checks remain tokenless. City crop weather, catalog, and warning rules are downloaded once per farm update and then filtered locally for every configured crop. Provider or parser failure for one crop never stops CWA coordinators or replaces another crop's valid snapshot.
If a legacy area value is invalid, OpenCWA creates a visible ⚠ crop record and retains the original value as recovery metadata; edit that crop once to repair it. In Options, leave the token field blank to keep the stored token, or check Clear stored agricultural token to remove it.
Agricultural guidance is attributed to 高雄農來訊; weather remains attributed to CWA. OpenCWA-derived guidance is not an official CWA crop-loss forecast, and no data/unsupported/stale/unavailable never means safe.
OpenCWA can optionally create dedicated CWA warning entities. They are disabled by default to avoid extra API calls for existing users.
Enable them from Settings > Devices & services > OpenCWA > Configure:
- Enable official typhoon warning (
enable_typhoon_warning): uses CWAW-C0034-001CAP data to identify an official Taiwan typhoon warning. Tropical-cyclone track data alone is not treated as an official warning. - Enable tropical cyclone track (
enable_tropical_cyclone_track): uses CWAW-C0034-005for active tropical cyclone track/fix data. - Enable hazardous weather alerts (
enable_weather_alerts): uses CWA hazardous-weather warnings and matches affected areas against the configured location and its parent city when available.
Created entities, using 安平區 as an example location:
| Entity | Meaning |
|---|---|
binary_sensor.opencwa_an_ping_qu_typhoon_warning |
on only when an official typhoon warning is currently active. Cancel, END, expired CAP messages, and解除 notices are off. |
sensor.opencwa_an_ping_qu_typhoon_warning_status |
Typhoon warning status and CAP attributes such as headline, report number, warning type, affected areas, effective/expires, and typhoon position. |
sensor.opencwa_an_ping_qu_typhoon_warning_notification |
Ready-to-use official typhoon warning notification payload. Attributes include title, message, severity, and summary. |
sensor.opencwa_an_ping_qu_tropical_cyclone |
Number of active tropical cyclones; attributes include latest fix, analysis fixes, forecast fixes, wind speed, pressure, and storm radius data. |
sensor.opencwa_an_ping_qu_tropical_cyclone_notification |
Ready-to-use tropical cyclone pre-alert payload. State becomes suppressed when an official typhoon warning is already active. |
binary_sensor.opencwa_an_ping_qu_weather_alert |
on when a hazardous-weather alert matches the configured location. |
sensor.opencwa_an_ping_qu_weather_alerts |
Count and details for hazardous-weather alerts. Attributes include matched_locations, unmatched_special_areas, and match_method. |
sensor.opencwa_an_ping_qu_weather_alert_notification |
Ready-to-use hazardous-weather alert notification payload with matched locations, special areas, and CWA text. Land strong-wind advisories also expose official warning level/thresholds plus clearly labelled crop and greenhouse risk guidance. |
Special-area matching covers common CWA area labels such as 恆春半島, 蘭嶼綠島, 基隆北海岸, and county mountain-area labels such as 高雄山區. Generic labels such as 山區 or 沿海空曠地區 may be reported in unmatched_special_areas when they cannot be safely mapped to the configured location.
Example automation:
alias: Notify when CWA typhoon warning starts
trigger:
- platform: state
entity_id: binary_sensor.opencwa_an_ping_qu_typhoon_warning
to: "on"
action:
- service: notify.mobile_app_your_phone
data:
title: CWA Typhoon Warning
message: >-
{{ state_attr('binary_sensor.opencwa_an_ping_qu_typhoon_warning', 'headline') }}Apply a API key in Opendata CWA
- Open the Opendata CWA Web Site
- Register your account
- Get your personal API Key.
Please use the config flow of Home Assistant
- With GUI. Configuration > Integration > Add Integration > OpneCWA
- If the integration didn't show up in the list please REFRESH the page
- If the integration is still not in the list, you need to clear the browser cache.
- Enter API key.
- Enter the location name of Taiwan. Please reference to the name in the doc.
- Some location names need to include the city name.
- Township / district names are allowed, for example
新店區,板橋區,大安區. - For ambiguous names such as
東區,北區,中山區, include the city name, for example嘉義市東區or臺中市東區. - In
onecall_*modes, the integration keeps your configured township / district name in Home Assistant, but internally upgrades it to the parent city only for current / UV lookup when required by the CWA onecall dataset. - Forecast data still stays on the original township / district source, so using
onecall_*does not force you to give up local forecast granularity.
Buy Me A Coffee
| LINE Pay | LINE Bank | JKao Pay |
|---|---|---|
![]() |
![]() |
![]() |


