Contributing¶
Thank you for your interest in contributing to the Meraki Dashboard Home Assistant integration!
Getting Started¶
Prerequisites¶
- Python 3.12 or newer
- Home Assistant development environment
- Git for version control
- A Meraki Dashboard account for testing
Development Setup¶
-
Fork and Clone
-
Install Dependencies
-
Set Up Pre-commit Hooks
Development Workflow¶
Code Style¶
We use: - Black for code formatting - Ruff for linting - mypy for type checking - isort for import sorting
Run all checks:
Testing¶
Write tests for all new functionality:
# Run all tests
make test
# Run specific test file
make test-file FILE=tests/test_sensor.py
# Run with coverage
make coverage
Making Changes¶
- Create a feature branch
- Make your changes
- Add/update tests
- Update documentation
- Run linting and tests
- Submit a pull request
Architecture Guidelines¶
Adding New Device Support¶
- Create device module in
devices/
- Define sensor descriptions
- Update data transformer
- Add to entity factory
- Write comprehensive tests
Example structure:
# devices/mv.py
from dataclasses import dataclass
from homeassistant.components.sensor import SensorEntityDescription
@dataclass
class MVSensorDescriptions:
"""MV camera sensor descriptions."""
camera_status = SensorEntityDescription(
key="camera_status",
name="Camera Status",
icon="mdi:camera"
)
API Integration¶
Always use the hub pattern:
# ✅ Correct
result = await hub.async_get_device_data(serial)
# ❌ Wrong
result = await dashboard.devices.getDevice(serial)
Error Handling¶
Use decorators consistently:
@handle_api_errors
@with_standard_retries
async def async_get_data(self):
"""Get data with proper error handling."""
return await self._make_api_call()
Testing Guidelines¶
Test Structure¶
class TestMerakiSensor:
"""Test Meraki sensor functionality."""
async def test_sensor_creation(self, hass):
"""Test sensor is created correctly."""
# Arrange
device = DeviceBuilder().with_temperature(22.5).build()
# Act
sensor = await create_sensor(hass, device)
# Assert
assert sensor.state == 22.5
Mock Data¶
Use builders for consistency:
device = (MerakiDeviceBuilder()
.with_serial("Q2QN-9J8L-SLPD")
.with_type("MS")
.with_model("MS120-8")
.build())
Documentation¶
Code Documentation¶
- Add docstrings to all public methods
- Use Google style docstrings
- Include type hints
def process_data(self, data: dict[str, Any]) -> list[dict]:
"""Process raw API data.
Args:
data: Raw API response data
Returns:
List of processed device dictionaries
Raises:
DataError: If data format is invalid
"""
User Documentation¶
Update relevant docs when adding features: - device-support.md
for new devices - getting-started.md
for new configuration options - faq.md
for common issues
Pull Request Process¶
Before Submitting¶
- Tests pass (
make test
) - Linting passes (
make lint
) - Coverage maintained (
make coverage
) - Documentation updated
- CHANGELOG.md entry added
PR Template¶
## Description
Brief description of changes
## Type of Change
- [ ] Bug fix
- [ ] New feature
- [ ] Breaking change
- [ ] Documentation update
## Testing
- [ ] Unit tests pass
- [ ] Integration tests pass
- [ ] Manual testing completed
## Checklist
- [ ] Code follows style guidelines
- [ ] Self-review completed
- [ ] Documentation updated
- [ ] Tests added/updated
Release Process¶
- Update version in
manifest.json
- Update CHANGELOG.md
- Create release PR
- Tag release after merge
- GitHub Actions publishes release
Getting Help¶
- Open an issue for bugs
- Start a discussion for features
- Check existing issues first
- Join our Discord community
Code of Conduct¶
- Be respectful and inclusive
- Welcome newcomers
- Focus on constructive feedback
- Follow Home Assistant's CoC
Recognition¶
Contributors are recognized in: - Release notes - Documentation credits - GitHub contributors page
Thank you for contributing!