Commit Graph

126 Commits (25341f79b3796c83afd84510bf9bd6f690d94d6a)

Author SHA1 Message Date
SchiZzA 25341f79b3
fix: address review findings across forwarders and helpers
- wind_dir_to_text: treat 0/missing direction as None (calm) so a missing
  wind direction no longer renders as North; azimut lambdas pass None too.
- windy: log response status (was logging an un-awaited coroutine method);
  count "unexpected response" toward the disable threshold even when logging
  is off.
- pocasi: disable threshold >3 -> >=3 to match Windy's 3-strike behavior.
- ecowitt: always attach device_info to native sensors, including unknown
  sensor types (previously left orphaned without a device).
- const: stop remapping WSLink connection flags (t1cn/t234cXcn) into the
  payload; they had no entity and leaked ghost *_connection keys into data
  and persisted SENSORS_TO_LOAD. Gating uses the raw keys and is unaffected.
- config_flow: fix WSLink port fallback typo 433 -> 443; drop mutable default
  argument on async_step_init.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-21 12:51:35 +02:00
SchiZzA b72efa5985
fix(coordinator): pass config_entry to DataUpdateCoordinator
Pass config_entry explicitly to super().__init__() in both
WeatherDataUpdateCoordinator and HealthCoordinator instead of relying on the
implicit ContextVar (deprecated, breaks in HA 2026.8 for core and was breaking
async_config_entry_first_refresh outside the setup context).

Also resolve each discovered sensor's display name once in received_data
(the previous comprehension awaited translations() twice per key).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-21 12:51:25 +02:00
SchiZzA e20c23a3af
fix(routes): rebind sticky health route on reload; defensive resolve
After a config reload a new HealthCoordinator is created, but the sticky
/station/health route kept calling the previous (stale) instance. Add
Routes.rebind_handler() and call it from async_setup_entry's reload branch
so the endpoint always serves the current coordinator.

Also make _resolve_route() tolerant of requests without match_info/route/
resource instead of raising AttributeError.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-21 12:51:14 +02:00
SchiZzA b777296b52
fix(ecowitt): Connect Ecowitt bridge to sensor platform earlier 2026-06-21 11:28:24 +02:00
SchiZzA e3d712bd54
fix(wslink): Definiton of HCHO, VOC, T9 battery diplicates. 2026-06-21 11:17:38 +02:00
SchiZzA 2f7d96f8d3
Add stall sensor detection. 2026-06-01 17:47:30 +02:00
SchiZzA 0142c5412b
fix: coordinator reuse, route dispatcher, binary sensor translations & test suite alignment
- Reuse existing `WeatherDataUpdateCoordinator` instance across reloads instead of
  creating a new one; routes keep pointing to the same coordinator, so entities
  stay subscribed and updates never silently drop
- `update_listener` now skips full reload when only `SENSORS_TO_LOAD` changes
  (auto-discovery); avoids the "frozen UI" window caused by temporary platform unload
- Replaced direct `route._handler` mutation with a proper `Routes` dispatcher;
  all aiohttp routes are registered once and an internal dispatcher decides which
  handler is active — safe to switch at runtime without touching the router
- Fixed `self.config_entry` / `self.config` inconsistency in coordinator

- `BatteryBinarySensor` now carries correct `device_info` (same identifiers as
  `WeatherSensor`) → single device card in UI instead of two
- Translations for binary sensors must live under `entity.binary_sensor.*`,
  not `entity.sensor.*`

- Fixed all tests broken by new `register_path(hass, coordinator, coordinator_h, entry)` signature
- Updated `_RouterStub` to accept `name=` kwargs and return objects with `.method`
- Added `async post()` to `_RequestStub` stubs
- Aligned `Routes` tests with new `method:path` dispatch key format and `show_enabled()` output
- Replaced `WindyApiKeyError` with `WindyPasswordMissing` to match actual exceptions
- Updated `_FakeResponse` to use HTTP status codes instead of response text strings
- Patched `persistent_notification.create` in Windy push tests to avoid `SimpleNamespace` errors
2026-06-01 17:01:40 +02:00
SchiZzA 4001ff0ba4
fix: Fixed type errors 2026-05-28 11:30:05 +02:00
SchiZzA 7ea47e8591
fix DEV_DBG as constant not string literal 2026-05-27 21:50:14 +02:00
SchiZzA 463b922e83
fix bool truthy 2026-05-27 21:49:39 +02:00
SchiZzA e570ff0014
hmac compare ID / KEY 2026-05-27 21:41:40 +02:00
SchiZzA 1ad10b4b1e
fixed: Menu options 2026-05-27 21:34:32 +02:00
SchiZzA b9815713a0
fix value in wslink sensors
Fix VOCLevel value
2026-05-27 21:30:11 +02:00
SchiZzA 211965dd52
Ecowitt support
Update setiing (config_flow and translations) for Ecowitt settings.
Also updated utils.py to accept None for value.
2026-05-27 21:27:13 +02:00
SchiZzA 9288ae4a64
Updated config flow
Updated config flow's initial setup.
Ecowitt stations does not require `API_ID` and `API_KEY`, so we need to
separate Ecowitt setup from PWS/WSLink setup.
2026-05-27 17:27:10 +02:00
SchiZzA cc50f9babb
fix: Corrected RAIN and DAILYRAIN for PWS protocol.
The `RAININ` suppose to be accumulated rainfall in 60 minutes. So the
unit must be in `mm/h` or `in/h`.
In the opposite `DAILYRAIN` is rain in the day do far, represented in
accumulated `mm` or `in`.
2026-05-24 22:19:53 +02:00
SchiZzA 21dfa61cd5
Add HCHO / VOC air-quality sensors (T9 module)
Support the WSLink t9 air-quality module:
  - t9hcho (formaldehyde, ppb),
  - t9voclv (VOC level 1-5 -> ENUM state)
  - t9bat (0-5 battery -> percentage).

  The t9hcho/t9voclv/t9bat values are dropped when
  t9cn reports the module as disconnected,
  so no empty entities are created.

  - const: HCHO/VOC/T9_BATTERY keys, VOCLevel enum +
  VOC_LEVEL_MAP, BATTERY_NON_BINARY, CONNECTION_GATED_SENSORS,
  REMAP_WSLINK_ITEMS entries
  - utils: voc_level_to_text(),
  battery_5step_to_pct(), connection gating
  - sensors_wslink: HCHO / VOC / T9_BATTERY entity
  descriptions
  - translations (en, cs): hcho, voc (+ states),
  t9_battery
  - tests: tests/conftest.py +
  tests/test_t9_air_quality.py
2026-05-24 22:19:30 +02:00
SchiZzA 1d2c1b4be3
Introduce SWSRuntimeData dataclass for typed entry.runtime_data.
Adds the SWSRuntimeData dataclass and SWSConfigEntry type alias so
  per-entry state can move from loosely-typed hass.data[DOMAIN][entry_id]
  dicts to HA 2025+ typed entry.runtime_data. The legacy ENTRY_* string
  keys are kept in place for now so callers can be migrated incrementally.

  This commit is not final update. Just preparing for future complete refactor.
2026-05-11 13:49:40 +02:00
SchiZzA 202447405f
Typos corrected. 2026-04-11 17:37:53 +02:00
schizza 15e9df00ca
Implement Ecowitt protocol support and dynamic binary sensor discovery.
- Integrate aioecowitt to parse incoming weather station payloads and map sensors to the SWS pipeline.
- Add a new webhook endpoint at /weatherhub/{webhook_id} with support for dynamic route resolution.
- Expand battery binary sensor definitions and implement logic for dynamic entity creation.
- Bump version to 2.0.0-pre1.
2026-04-11 16:37:17 +02:00
SchiZzA 50fe9e35fe
Add Ecowitt compatibility and deprecate legacy battery sensors. 2026-04-10 18:35:33 +02:00
SchiZzA 7f72497e9e
Update version to 2.0.pre0 2026-03-23 18:35:29 +01:00
SchiZzA e737fb16d3
Use configured WSLink add-on port for health/status endpoints. 2026-03-23 18:32:02 +01:00
SchiZzA 159d465db5
Improve sensor value parsing and add battery binary sensors.
- Introduce `to_int`/`to_float` helpers to safely handle None/blank payload values.
- Use the converters across weather/wslink sensor descriptions and simplify wind direction handling.
- Add low-battery binary sensor entities and definitions.
2026-03-23 18:21:05 +01:00
SchiZzA 9d5fafa8d0
Add configuration options for WSLink Addon port. 2026-03-23 18:14:46 +01:00
SchiZzA 63660006ea
Add health diagnostics coordinator and routing snapshot
Track ingress/forwarding status, expose detailed health sensors and translations, and include redacted diagnostics data.
2026-03-14 17:39:52 +01:00
SchiZzA 39b16afcbc
Update constants to more readable form. 2026-03-05 11:47:52 +01:00
SchiZzA f0554573ce
Make routes method-aware and update related tests
Include HTTP method in route keys and dispatch, and fix
Routes.show_enabled.
Update register_path to accept a HealthCoordinator and adjust router
stubs in tests. Update WindyPush tests to use response objects
(status/text)
and adapt related exception/notification expectations.
2026-03-04 07:53:26 +01:00
SchiZzA 995f607cf7
Improve Windy error handling and retry logic 2026-03-03 14:17:34 +01:00
SchiZzA 3e573087a2
Add multiple health sensors and device info
Introduce HealthSensorEntityDescription and a tuple of sensor
descriptions for integration status, source IP, base URL and addon
response. Instantiate one HealthDiagnosticSensor per description in
async_setup_entry. Update HealthDiagnosticSensor to accept a
description, derive unique_id from description.key and add a cached
device_info returning a SERVICE-type device. Adjust imports.
2026-03-02 22:08:40 +01:00
SchiZzA 6a4eed2ff9
Validate hass data with py_typecheck.checked
Replace manual isinstance checks and casts with py_typecheck.checked()
to validate hass and entry data and return early on errors. Simplify
add_new_sensors by unwrapping values, renaming vars, and passing the
coordinator to WeatherSensor
2026-03-02 22:08:01 +01:00
SchiZzA b3aae77132
Replace casts with checked type helpers
Use checked and checked_or to validate option and hass.data types,
remove unsafe typing.cast calls, simplify coordinator and entry_data
handling, and cache boolean option flags for Windy and Pocasí checks
2026-03-02 22:06:09 +01:00
SchiZzA 7d1494f29b
Removed extended debugging info from sensors. Added descriptive method on route info. 2026-03-01 17:32:36 +01:00
SchiZzA 01058a07b4
Add WSLink support for additional sensor channels
- Extend constants and WSLink key remapping for channels 3–8 (temp, humidity, battery and connection)
- Add new WSLink sensor entity descriptions for the extra channel readings
- Update English translations for the newly added channel sensors and battery states
2026-03-01 16:56:46 +01:00
SchiZzA f06f8b31ae
Align Windy resend with Stations API response handling
- Add WINDY_MAX_RETRIES constant and use it consistently when deciding to disable resending
- Refactor Windy response verification to rely on HTTP status codes per stations.windy.com API
- Improve error handling for missing password, duplicate payloads and rate limiting
- Enhance retry logging and disable Windy resend via persistent notification on repeated failures
2026-03-01 13:51:17 +01:00
SchiZzA 95663fd78b
Stabilize webhook routing and config updates
- Register aiohttp webhook routes once and switch the active dispatcher handler on option changes
- Make the internal route registry method-aware (GET/POST) and improve enabled-route logging
- Fix OptionsFlow initialization by passing the config entry and using safe defaults for credentials
- Harden Windy resend by validating credentials early, auto-disabling the feature on invalid responses, and notifying the user
- Update translations for Windy credential validation errors
2026-03-01 12:48:23 +01:00
SchiZzA cc1afaa218
Organize imports in `__init__.py` 2026-02-26 17:59:25 +01:00
SchiZzA 9255820a13
Added support for GET and POST endpoints. 2026-02-26 17:58:12 +01:00
SchiZzA 1bbeab1ffe
Add health diagnostic sensor and extensive tests for sws12500
integration

- Introduce HealthDiagnosticSensor for device health status reporting
- Add new constants and data keys for health sensor integration
- Wire health_sensor module into sensor platform setup
- Refactor sensor descriptions to improve derived sensor handling
- Implement pytest fixtures and comprehensive tests covering:
  - Config flows and options validation
  - Data reception and authentication
  - Sensor platform setup and dynamic sensor addition
  - Push integration with Pocasi.cz and Windy API
  - Route dispatching and error handling
  - Utilities, conversions, and translation functions
2026-02-21 11:29:40 +01:00
SchiZzA 214b8581b0
Remove numpy dependency and simplify range checks in heat_index function 2026-02-06 18:32:56 +01:00
SchiZzA c84e112073
Fix typo in fallback handler name from unregistred to unregistered 2026-02-06 18:22:31 +01:00
SchiZzA fa3b5aa523
Anonymize data payload in PocasiPush logging 2026-02-06 18:20:17 +01:00
SchiZzA f608ab4991
Remove verify_ssl=False from async_get_clientsession calls 2026-02-06 18:14:02 +01:00
SchiZzA 0c67b8d2ab
Update Windy integration to use station ID and password authentication
- Replace API key with station ID and password for authentication
- Change Windy API endpoint to v2 observation update
- Adapt data conversion for WSLink to Windy format
- Update config flow and translations accordingly
2026-02-06 15:16:05 +01:00
SchiZzA 1fec8313d4
Refactor SWS12500 integration for push-based updates
- Add detailed architecture overview in __init__.py
- Introduce shared runtime keys in data.py to avoid key conflicts
- Implement dual route dispatcher for webhook endpoint selection
- Enhance sensor platform for dynamic sensor addition without reloads
- Rename battery level "unknown" to "drained" with updated icons
- Improve utils.py with centralized helpers for remapping and discovery
- Update translations and strings for consistency
2026-01-27 09:21:27 +01:00
SchiZzA a3dc3d0d53
Improve data validation and error logging in utils.py 2026-01-18 21:48:24 +01:00
SchiZzA 234840e115
Rename battery_level_to_text to battery_level and update docstring 2026-01-18 19:36:33 +01:00
SchiZzA a20369bab3
Fix logging of unregistered route to include path 2026-01-18 19:35:51 +01:00
SchiZzA 08b812e558
Improve type safety, add data validation, and refactor route handling
- Add typing and runtime checks with py_typecheck for config options and
  incoming data
- Enhance authentication validation and error handling in data
  coordinator
- Refactor Routes class with better dispatch logic and route
  enabling/disabling
- Clean up async functions and improve logging consistency
- Add type hints and annotations throughout the integration
- Update manifest to include typecheck-runtime dependency
2026-01-18 17:53:28 +01:00
SchiZzA 39cd852b36
Merge remote-tracking branch 'origin/stable' into ecowitt_support 2025-12-22 16:43:04 +01:00