Skip to content

Feat/release please automation - #569

Closed
brianegge wants to merge 27 commits into
rroller:mainfrom
brianegge:feat/release-please-automation
Closed

Feat/release please automation#569
brianegge wants to merge 27 commits into
rroller:mainfrom
brianegge:feat/release-please-automation

Conversation

@brianegge

Copy link
Copy Markdown
Contributor

No description provided.

renovate Bot and others added 27 commits April 12, 2026 19:46
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
* Improve integration quality toward HA bronze tier

- Add has_entity_name = True to base entity; entity names now return
  suffix only (HA auto-prefixes the device name)
- Migrate from hass.data[DOMAIN] to ConfigEntry.runtime_data with
  DahuaConfigEntry type alias
- Add removal instructions to README
- Add config flow tests covering success, invalid credentials,
  duplicate device, and options flow

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Apply black formatting to all changed files

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Fix config flow tests: load integration before running

Use async_get_integration fixture so HA discovers the custom component
config flow handler before tests attempt to init flows.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Fix test discovery: import config_flow to register handler

Replace async_get_integration fixture with a direct import of the
config_flow module, which registers the flow handler at import time.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Fix test discovery by enabling custom integrations in conftest

Add auto_enable_custom_integrations fixture so HA's loader can find the
dahua integration under custom_components/ during test runs.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
…s, docs (#30)

Add dahua_command decorator to wrap all entity action methods with proper
HomeAssistantError handling for device communication failures. Set
PARALLEL_UPDATES on all platform files. Fix ValueError when selecting
"Manual" preset position. Document channel parameter and configuration
options in README.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
* Address silver tier quality scale: action-exceptions, parallel-updates, docs

Add dahua_command decorator to wrap all entity action methods with proper
HomeAssistantError handling for device communication failures. Set
PARALLEL_UPDATES on all platform files. Fix ValueError when selecting
"Manual" preset position. Document channel parameter and configuration
options in README.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Add comprehensive test suite achieving 95% line coverage

428 tests covering all entity platforms (camera, light, switch, select,
binary_sensor, button), coordinator properties/events/init, client API
methods, config flow with reauth, utilities, models, and base entity.
Excludes protocol helpers (vto, rpc2, digest) from coverage via .coveragerc.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Add PyTurboJPEG dependency for camera test support in CI

The camera platform imports homeassistant.components.camera which
requires turbojpeg. Add system library and pip package to CI workflow.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Add diagnostics, entity translations, icon translations, exception
translations, entity categories, BinarySensorDeviceClass enums,
reconfigure flow, stale device cleanup, serial_number in DeviceInfo,
and disabled-by-default for preset position select.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
…eshooting, limitations (#33)

Complete remaining gold tier quality scale documentation items:
- docs-use-cases: security monitoring, doorbell automation, PTZ, overlays
- docs-data-update: polling (30s) and real-time event streaming
- docs-examples: five example automations (motion notification, night
  lights, doorbell snapshot, PTZ preset, event bus)
- docs-troubleshooting: connection, events, unavailable, streams, NVR, debug
- docs-known-limitations: iMou, firmware quirks, auto mode, siren, discovery
- docs-supported-functions: comprehensive entity and service tables
- docs-supported-devices: existing tables retained and referenced

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
* Address platinum tier: async-dependency and inject-websession (#34)

Remove unused `requests` dependency from VTO client and replace
self-managed aiohttp ClientSession with HA-managed sessions via
`async_create_clientsession(hass, verify_ssl=False)` in both the
coordinator and config flow.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Add pre-commit with ruff linting and formatting

Set up pre-commit hooks with ruff for linting (--fix) and formatting.
Fix all ruff violations: unused imports, unused variables, lambda
assignments, E402 import ordering, and apply consistent formatting.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Replace black with ruff in GitHub Actions workflows

Use astral-sh/ruff-action@v3 for both linting and format checking
in pull request and push workflows.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Add strict typing: py.typed marker, mypy --strict passes all 17 source files

Add PEP 561 py.typed marker and pyproject.toml with mypy strict config.
Add comprehensive type annotations across all source files including
typed decorators, generic DataUpdateCoordinator, ConfigFlowResult
return types, and proper str/int casts for dict[str, Any] values.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
…N.md

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Add media_player platform for camera speaker audio playback

Adds a media_player entity that plays audio through Dahua camera speakers
via the postAudio CGI endpoint with G.711A encoding. Speaker support is
detected from Dahua model suffixes (-AS, -ASE, -PV) checking both
deviceType and updateSerial to handle cameras that report generic
deviceType values.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Fix async_post_audio for Dahua streaming audio endpoint

The camera's postAudio CGI is a streaming endpoint that never sends
HTTP response headers. Two fixes:

1. Prime digest auth with a GET before the POST - the camera resets
   unauthenticated POST connections, breaking DigestAuth's 401 retry.
2. Use a 2-second response timeout and treat TimeoutError as success,
   since the camera holds the connection open after accepting audio.

Also use channel_number (1-indexed) instead of channel (0-indexed)
for the audio endpoint URL.

Tested successfully on IPC-HFW1841EN-PV (front-entry-cam).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Switch audio encoding to AAC with wall-clock timed streaming

AAC produces much cleaner audio than G.711A on camera speakers.
Stream audio at real-time rate using wall-clock timing with 0.5s
chunks to avoid buffer underruns on cameras that use streaming
mode (e.g. IPC-HFW1841EN-PV). Cameras that respond immediately
(e.g. IPC-HDW5849HP-ASE-LED) also work with AAC.

- Convert audio to AAC (8kHz, mono, 64kbps ADTS) instead of G.711A
- Pass audio duration from ffmpeg to async_post_audio for accurate
  timeout and pacing calculations
- Use wall-clock synchronized chunk delivery to prevent drift

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Use multipart MIME for audio playback to eliminate gaps

Switch from httptype=singlepart to httptype=multipart for posting audio
to camera speakers. Each ADTS frame is sent as a separate MIME part with
explicit Content-Type and Content-Length, giving the camera's decoder
clean frame boundaries. Parts are paced at the AAC frame rate (128ms)
to keep the playback buffer fed.

This dramatically reduces audible gaps and clicks compared to singlepart
streaming, which suffered from buffer underruns regardless of pacing
strategy (chunked encoding, Content-Length, ffmpeg -re, etc).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
…re (#37)

* Add RTSP backchannel fallback and local media support for speaker audio

Cameras running Lorex or older Dahua firmware do not expose the HTTP
audio.cgi endpoint, causing play_media to fail with "Connection reset
by peer".  These cameras do support ONVIF RTSP backchannel audio
(advertised via the Require: www.onvif.org/ver20/backchannel header).

This commit:

- Adds async_post_audio_backchannel() which negotiates an RTSP session
  with the ONVIF backchannel header, sets up the sendonly audio track,
  and streams AAC frames as RTP packets over TCP-interleaved RTSP.
- Falls back to RTSP backchannel automatically when HTTP audio.cgi
  fails, so both firmware variants work without user configuration.
- Resolves media-source://media_source/local/... URIs to the /media
  filesystem path so local media files can be played directly.
- Sends the HTTP multipart body with Content-Length instead of chunked
  transfer encoding, which some cameras also reject.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Fix ruff lint errors: remove unused import and variable

Remove unused AsyncIterator import and unused loop variable
assignment that were left over from refactoring.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Fix ruff format for media_player.py

Align formatting with ruff 0.15.4 used in CI.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Pin ruff to 0.15.4 in CI and pre-commit

Aligns the ruff version between pre-commit (was 0.9.10) and CI
(was unpinned/latest) to prevent formatting drift.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: root <root@1016f397-claudecode.local.hass.io>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
* Add RTSP backchannel fallback and local media support for speaker audio

Cameras running Lorex or older Dahua firmware do not expose the HTTP
audio.cgi endpoint, causing play_media to fail with "Connection reset
by peer".  These cameras do support ONVIF RTSP backchannel audio
(advertised via the Require: www.onvif.org/ver20/backchannel header).

This commit:

- Adds async_post_audio_backchannel() which negotiates an RTSP session
  with the ONVIF backchannel header, sets up the sendonly audio track,
  and streams AAC frames as RTP packets over TCP-interleaved RTSP.
- Falls back to RTSP backchannel automatically when HTTP audio.cgi
  fails, so both firmware variants work without user configuration.
- Resolves media-source://media_source/local/... URIs to the /media
  filesystem path so local media files can be played directly.
- Sends the HTTP multipart body with Content-Length instead of chunked
  transfer encoding, which some cameras also reject.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Fix ruff lint errors: remove unused import and variable

Remove unused AsyncIterator import and unused loop variable
assignment that were left over from refactoring.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Fix ruff format for media_player.py

Align formatting with ruff 0.15.4 used in CI.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Pin ruff to 0.15.4 in CI and pre-commit

Aligns the ruff version between pre-commit (was 0.9.10) and CI
(was unpinned/latest) to prevent formatting drift.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Add audio.cgi capability detection to avoid unnecessary HTTP fallback

Probe audio.cgi at startup with a read-only GET and cache the result.
Use the flag in async_play_media to skip the HTTP attempt on cameras
that don't support it (Lorex/older firmware), eliminating per-play
latency and error logging. A one-time runtime fallback updates the
flag if HTTP fails unexpectedly.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: root <root@1016f397-claudecode.local.hass.io>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
* Added privacy mode

* Fix session expiry

* Fix linting errors: remove unused exception var, use inline icon

* Format code with ruff

---------

Co-authored-by: AdrianCzebiniak <adrian.czebiniak@gmail.com>
* adds Numeric Zoom & Focus Entities if supported and AutoFocus support.

* Fix syntax error: remove duplicate empty function definition

* Add number to manifest dependencies and format code

* Trigger CI

* Fix tests: add async_get_zoomfocus_v1 mock and _supports_zoom_focus flag

* Add media_player to manifest after_dependencies

* Fix import: use lowercase 'number' for NumberEntity import

---------

Co-authored-by: Ben Harr <ben.j.harr@gmail.com>
Cameras (especially Lorex/older Dahua firmwares) may ship with audio
encoding disabled, which silently prevents RTSP backchannel speaker
playback. This change:

- Detects disabled audio encoding at startup and logs a warning
- Adds an `enable_audio` service on media_player entities to enable it
- Fixes RTSP backchannel frame pacing: uses fixed 128ms interval
  (1024 samples / 8kHz) instead of deriving from ffmpeg duration,
  which is zero for piped input
- Adds manual_tests/ directory with scripts for audio debugging

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add detailed usage examples for all scripts and a step-by-step
troubleshooting guide for common speaker audio issues.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The number platform was using the old hass.data[DOMAIN][entry.entry_id]
pattern while all other platforms use entry.runtime_data, causing
KeyError: 'dahua' on every camera startup.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…e connection errors

- Change ~15 "Device supports X" INFO messages per camera to DEBUG level
- Catch ClientConnectorError separately to log a single warning line
  instead of a 60-line traceback for unreachable cameras
- Keep audio encoding disabled warning at WARNING level (actionable)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…cebacks

The DataUpdateCoordinator base class only handles UpdateFailed silently.
PlatformNotReady falls through to the generic except, causing full 60-line
tracebacks for every unreachable camera retry.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Adds release-please workflow that opens a release PR on each push to
main, and a daily cron (13:17 UTC) that merges the open release PR so
at most one release is cut per day. manifest.json version is kept in
lockstep with the tag via the jsonpath extra-files entry.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@brianegge brianegge closed this Apr 17, 2026
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.

2 participants