hass-dreo
Copilot instructions403 starsChanged 4 months agoMITView on GitHub
This document provides guidance for GitHub Copilot when working with the Dreo Smart Device Integration for Home Assistant. This is an unofficial Home Assistant custom integration for Dreo brand smart devices (fans, heaters, air conditioners, humidifiers, dehumidifiers, and cookers). The integration communicates with Dreo's cloud API and WebSocket service to control devices. The integration supports multiple device types, each mapped to Home Assistant platforms: - Fans → fan platform - Heaters → climate platform - Humidifiers/Dehumidifiers → humidifier platform -…
- Installs packages
We split this copilot-instructions.md into the rules it gives an agent
39 rules. About 0 are common, 25 are distinctive, and 14 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈25
Distinctive · estimate
This author's own choices. Worth a look.
14
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Very specific: line 29
Linting: Use Ruff with the provided ruff.toml configuration
- Distinctive: line 30
Imports: Follow Home Assistant conventions:
- Very specific: line 31
Use from .haimports import * for HA-specific imports
- Distinctive: line 32
Place third-party imports at the top
- Very specific: line 33
Use # noqa comments to suppress specific Ruff warnings when needed
- Distinctive: line 37
Use type hints where appropriate
- Distinctive: line 38
Add docstrings for public classes and methods
- Very specific: line 39
Follow Home Assistant's async patterns (use async def for async operations)
- Very specific: line 40
Use _LOGGER.debug(), _LOGGER.info(), _LOGGER.warning(), _LOGGER.error() for logging
- Distinctive: line 83
Unit tests: should mock external dependencies
- Very specific: line 84
Integration tests: use JSON files from e2e_test_data/ directory
- Distinctive: line 86
Follow existing test patterns in the repository
- Very specific: line 105
Check device model prefix (e.g., DR-HTF for tower fans)
- Distinctive: line 106
Add device type mapping in PyDreo library
- Very specific: line 107
Create or extend device class (e.g., PyDreoTowerFan)
- Very specific: line 108
Add Home Assistant entity wrapper (e.g., DreoFanHA)
- Very specific: line 109
Add test coverage with device JSON in e2e_test_data/
- Distinctive: line 110
Update README.md with supported model
- Very specific: line 134
Add device model mapping in the PyDreo library (check existing device files in custom_components/dreo/pydreo/ for the appropriate location)
- Distinctive: line 135
Create/update device class if needed
- Very specific: line 136
Add test JSON to custom_components/dreo/e2e_test_data/
- Very specific: line 137
Write integration test in tests/dreo/integrationtests/
- Distinctive: line 138
Update README.md with the new supported model
- Very specific: line 139
Update DEVICE_OWNERS.md with the GitHub username of the person who reported the device (from the GitHub issue), the issue number, and the …
- Distinctive: line 143
Add test that reproduces the bug
- Distinctive: line 146
Ensure all tests pass
- Distinctive: line 147
Update relevant documentation if needed
- Distinctive: line 154
Test after dependency updates
- Distinctive: line 169
Never commit credentials or API keys
- Distinctive: line 170
Use Home Assistant's config entry for sensitive data
- Distinctive: line 182
Use Home Assistant's coordinator pattern for state management
- Distinctive: line 187
Keep README.md updated with supported devices
- Distinctive: line 188
Add inline comments for complex logic
- Distinctive: line 189
Update RELEASE.md for version changes
- Distinctive: line 203
Follow existing patterns in the codebase
- Distinctive: line 205
Run tests after changes
- Distinctive: line 206
Update documentation when adding features
- Distinctive: line 207
Use existing device classes as templates for new devices
- Distinctive: line 208
Test with debug mode when possible before requesting user testing
≈ “Common” is an estimate: at least 1 in 5 of the 3,669 Copilot instructions files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
GitHub Copilot Instructions for hass-dreo
This document provides guidance for GitHub Copilot when working with the Dreo Smart Device Integration for Home Assistant.
Project Overview
This is an unofficial Home Assistant custom integration for Dreo brand smart devices (fans, heaters, air conditioners, humidifiers, dehumidifiers, and cookers). The integration communicates with Dreo's cloud API and WebSocket service to control devices.
Repository Structure
custom_components/dreo/- Main integration codepydreo/- Python library for Dreo API communication (embedded)- Device-specific files:
dreofan.py,dreoheater.py,dreohumidifier.py, etc. dreobasedevice.py- Base class for all Dreo devicesconfig_flow.py- Configuration flow for Home Assistanthaimports.py- Home Assistant imports (helps with IDE support)
tests/- Test suite with three levels:tests/pydreo/- Unit tests for the PyDreo librarytests/dreo/- Unit tests for HA integration (mock PyDreo)tests/dreo/integrationtests/- Integration tests (use real device JSON)
.github/workflows/- CI/CD workflows
Coding Standards
Python Style
- Python Version: Target Python 3.13 (as per CI configuration)
- Line Length: Maximum 150 characters (configured in
ruff.toml) - Linting: Use Ruff with the provided
ruff.tomlconfiguration - Imports: Follow Home Assistant conventions:
- Use
from .haimports import *for HA-specific imports - Place third-party imports at the top
- Use
# noqacomments to suppress specific Ruff warnings when needed
- Use
Code Conventions
- Use type hints where appropriate
- Add docstrings for public classes and methods
- Follow Home Assistant's async patterns (use
async deffor async operations) - Use
_LOGGER.debug(),_LOGGER.info(),_LOGGER.warning(),_LOGGER.error()for logging- Initialize logger with:
_LOGGER = logging.getLogger(__name__) - This follows the standard Python logging pattern and provides proper module hierarchy
- Initialize logger with:
- Device classes should inherit from
DreoBaseDevice
Naming Conventions
- Class names: PascalCase (e.g.,
DreoFanHA,PyDreoFan) - Method names: snake_case (e.g.,
async_setup_entry,handle_coordinator_update) - Constants: UPPER_SNAKE_CASE (e.g.,
DOMAIN,PYDREO_MANAGER) - Private methods: prefix with underscore (e.g.,
_update_state)
Testing
Running Tests
# Install test dependencies
pip install -r requirements.txt
pip install -r requirements.test.txt
# Run all tests
pytest
# Run specific test file
pytest tests/dreo/test_fan.py
# Run with coverage
pytest --cov=custom_components/dreoLinting
# Run Ruff (as in CI)
ruff check .
# Run Ruff with auto-fix
ruff check --fix .Test Structure
- Unit tests should mock external dependencies
- Integration tests use JSON files from
e2e_test_data/directory - New device support requires corresponding test coverage
- Follow existing test patterns in the repository
Home Assistant Integration Patterns
Device Types
The integration supports multiple device types, each mapped to Home Assistant platforms:
- Fans →
fanplatform - Heaters →
climateplatform - Humidifiers/Dehumidifiers →
humidifierplatform - Lights (device displays, main lights) →
lightplatformDreoLightHA- Standard lights with brightness and color temperature supportDreoRGBLightHA- RGB atmosphere lights for ceiling fans (RGB color control)
- Switches (device features) →
switchplatform - Sensors (temperature, humidity) →
sensorplatform - Numbers (adjustable values) →
numberplatform
Adding New Device Support
- Check device model prefix (e.g.,
DR-HTFfor tower fans) - Add device type mapping in PyDreo library
- Create or extend device class (e.g.,
PyDreoTowerFan) - Add Home Assistant entity wrapper (e.g.,
DreoFanHA) - Add test coverage with device JSON in
e2e_test_data/ - Update README.md with supported model
Configuration Flow
- Users configure via Home Assistant UI (Settings → Devices & Services)
- Credentials are stored in Home Assistant's config entry
- No
configuration.yamlentries required
Debug Test Mode
The integration includes a special debug mode for testing without live devices:
- Located in
debug_test_mode.pyandconst_debug_test_mode.py - DO NOT enable in production code (causes unit test failures)
- Uses JSON files from
custom_components/dreo/e2e_test_data/ - To enable: Uncomment
DEBUG_TEST_MODE = Trueincustom_components/dreo/const.py - See
contributing.mdfor detailed usage instructions and configuration
Common Tasks
Adding a New Device Model
- Obtain device JSON from user (via diagnostics or debug logs)
- Identify device type and capabilities
- Add device model mapping in the PyDreo library (check existing device files in
custom_components/dreo/pydreo/for the appropriate location) - Create/update device class if needed
- Add test JSON to
custom_components/dreo/e2e_test_data/ - Write integration test in
tests/dreo/integrationtests/ - Update README.md with the new supported model
- Update DEVICE_OWNERS.md with the GitHub username of the person who reported the device (from the GitHub issue), the issue number, and the device model, following the existing table format
Fixing a Bug
- Add test that reproduces the bug
- Fix the issue with minimal changes
- Run Ruff before committing:
ruff check . - Ensure all tests pass
- Update relevant documentation if needed
Updating Dependencies
requirements.txt- Runtime dependencies (minimal)requirements.test.txt- Test-only dependenciescustom_components/dreo/manifest.json- HA integration manifest- Test after dependency updates
CI/CD Workflows
- CI Validation (
ci.yaml) - Runs on PRs and pushes to main/beta- Executes pytest suite
- Runs Ruff linting
- HACS Validation (
hacs_validate.yaml) - Validates HACS compatibility - Hassfest (
hassfest.yaml) - Validates Home Assistant integration - Release (
release.yaml) - Automated release process
Important Notes
Security
- Never commit credentials or API keys
- Use Home Assistant's config entry for sensitive data
- Redact sensitive information in debug logs
WebSocket Connection
- Integration maintains a WebSocket connection to Dreo servers
- Auto-reconnect is configurable via integration options
- Handle connection failures gracefully
Device Updates
- Devices send state updates via WebSocket
- Use Home Assistant's coordinator pattern for state management
- Throttle frequent updates to avoid performance issues
Documentation
- Keep README.md updated with supported devices
- Add inline comments for complex logic
- Update RELEASE.md for version changes
Resources
- Home Assistant Developer Docs
- PyDreo Library (embedded in this repo)
- Contributing Guide
- GitHub Issues
Best Practices for Copilot
Always run Ruff before pushing:
ruff check .must report 0 errors before any commit is pushed.
- Focus on minimal, surgical changes
- Follow existing patterns in the codebase
- Run Ruff before pushing —
ruff check .must pass with 0 errors - Run tests after changes
- Update documentation when adding features
- Use existing device classes as templates for new devices
- Test with debug mode when possible before requesting user testing
Where files are headingNew Copilot instructions files have more rules about branches and pull requests, and fewer about code style.
Of the Copilot instructions files we read, the 2,297 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
Reviews can't be read right now.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

