Skip to content

Address silver tier quality scale items - #548

Closed
brianegge wants to merge 14 commits into
rroller:mainfrom
brianegge:silver-tier-quality
Closed

Address silver tier quality scale items#548
brianegge wants to merge 14 commits into
rroller:mainfrom
brianegge:silver-tier-quality

Conversation

@brianegge

Copy link
Copy Markdown
Contributor

Summary

  • Add dahua_command decorator in entity.py that wraps all action methods with proper HomeAssistantError handling for aiohttp.ClientError, socket.gaierror, asyncio.TimeoutError, and unexpected exceptions
  • Apply @dahua_command to all ~44 action methods across camera.py, light.py, switch.py, and select.py
  • Set PARALLEL_UPDATES on all platform files (1 for command-sending platforms, 0 for read-only binary_sensor)
  • Fix ValueError in DahuaCameraPresetPositionSelect when "Manual" is selected (was calling int("Manual"))
  • Document the Channel setup parameter and Configuration Options in README

Test plan

  • All existing tests pass (pytest tests/ — 5/5 passed)
  • Black formatting passes on all modified files
  • CI passes (style, tests, HACS/hassfest validation)

🤖 Generated with Claude Code

brianegge and others added 14 commits February 28, 2026 06:09
Copy Dahua brand icons and logos from the home-assistant/brands
repository into custom_components/dahua/brand/ so HACS validation
no longer needs to fall back to the brands repository.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add brand assets for HACS validation
… reauth (#22)

- Fix session leak in config_flow._test_credentials() by adding finally clause
- Fix session leak on unload by calling coordinator.async_stop() which closes session
- Fix != None to is not None in _close_session()
- Replace DahuaEventThread/DahuaVtoEventThread with native async tasks
- Replace threading.Timer in VTO client with loop.call_later()
- Replace loop.stop() in VTO with disconnected future for clean reconnect
- Fix swallowed exceptions in client.stream_events() (re-raise CancelledError)
- Add reauthentication flow triggered on HTTP 401 during initialization
- Delete thread.py (no longer needed)

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Add Dahua HDW2431TP-AS, T5442TM-AS, B5442E-Z4E, B54IR-ASE and
Amcrest IP5M-T1179E, IPC-Color4K-T to the supported cameras list.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
* Use go2rtc native streaming instead of ffmpeg

Set frontend_stream_type to WEB_RTC so Home Assistant uses go2rtc
for camera streams instead of transcoding via ffmpeg. This reduces
CPU usage and latency.

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

* Fix session leaks, replace blocking threads with async tasks, and add reauth

- Fix session leak in config_flow._test_credentials() by adding finally clause
- Fix session leak on unload by calling coordinator.async_stop() which closes session
- Fix != None to is not None in _close_session()
- Replace DahuaEventThread/DahuaVtoEventThread with native async tasks
- Replace threading.Timer in VTO client with loop.call_later()
- Replace loop.stop() in VTO with disconnected future for clean reconnect
- Fix swallowed exceptions in client.stream_events() (re-raise CancelledError)
- Add reauthentication flow triggered on HTTP 401 during initialization
- Delete thread.py (no longer needed)

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

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.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>
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

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>
@brianegge brianegge closed this Feb 28, 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.

1 participant