Thank you for your interest in contributing to APS2MQTT! 🎉
- Code of Conduct
- How Can I Contribute?
- Development Setup
- Architecture Overview
- Testing
- Submitting Changes
This project follows a simple code of conduct:
- Be respectful and inclusive
- Focus on constructive feedback
- Help others when you can
Before creating bug reports, please check existing issues. When creating a bug report, include:
- Clear title and description
- Steps to reproduce the behavior
- Expected vs actual behavior
- Environment details (OS, Docker version, ECU model)
- Logs (with DEBUG=True if possible)
Enhancement suggestions are welcome! Please include:
- Clear use case - Why is this needed?
- Proposed solution - How would it work?
- Alternatives considered
- Impact - Who benefits?
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Run tests (
python3 test_refactoring.py) - Commit with clear messages
- Push to your branch
- Open a Pull Request
- Python 3.8+
- Docker (optional, for testing)
- APSystems ECU for real testing (or use mock data)
# Clone repository
git clone https://github.com/fligneul/aps2mqtt.git
cd aps2mqtt
# Create virtual environment
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Install in development mode
pip install -e .Create a config.yaml or .env file:
ecu:
APS_ECU_IP: '192.168.1.42'
APS_ECU_TIMEZONE: 'Europe/Paris'
mqtt:
MQTT_BROKER_HOST: 'localhost'
MQTT_BROKER_PORT: 1883# With config file
python3 -m aps2mqtt -c config.yaml
# With environment variables
export APS_ECU_IP=192.168.1.42
export MQTT_BROKER_HOST=localhost
python3 -m aps2mqttThe project follows a modular architecture:
aps2mqtt/
├── models.py # Data models (ECUData, InverterData)
├── constants.py # Configuration constants
├── parser.py # Data parsing logic
├── ha_discovery.py # Home Assistant Discovery generation
├── mqtt_handler.py # MQTT interface
├── config.py # Configuration management
├── main.py # Main application loop
└── apsystems/
├── ECU.py # ECU communication
└── APSystemsSocket.py # Socket protocol
Models (models.py):
InverterData: Represents inverter data with type hintsECUData: Represents ECU data with aggregated inverter infoHAEntity: Home Assistant entity configuration
Parser (parser.py):
DataParser: Converts ECUData to MQTT topics- Handles online/offline states
- Calculates aggregate statistics
HA Discovery (ha_discovery.py):
HADiscoveryGenerator: Creates HA MQTT Discovery configs- Reads entity definitions from
models.csv - Generates proper device classes and units
MQTT Handler (mqtt_handler.py):
MQTTHandler: Manages MQTT connection and publishing- Handles reconnection logic
- Publishes both data and discovery topics
ECU Device
↓
APSystemsSocket (raw data)
↓
ECU.update() → ECUData object
↓
DataParser → MQTT topics dict
↓
MQTTHandler → Publish to broker
↓
Home Assistant (auto-discovery)
# Run refactoring tests
python3 test_refactoring.py
# Run multi-inverter tests
python3 test_multiple_inverters.py# Enable debug mode
export DEBUG=True
python3 -m aps2mqtt -c config.yaml
# Monitor MQTT topics
mosquitto_sub -h localhost -t 'aps/#' -v# Build image
docker build -t aps2mqtt:test .
# Run with test config
docker run --rm \
-e APS_ECU_IP=192.168.1.42 \
-e MQTT_BROKER_HOST=192.168.1.50 \
-e DEBUG=True \
aps2mqtt:testFollow conventional commits format:
type(scope): subject
body (optional)
footer (optional)
Types:
feat: New featurefix: Bug fixdocs: Documentation changesrefactor: Code refactoringtest: Adding testschore: Maintenance tasks
Examples:
feat(parser): add support for QS1A inverters
fix(mqtt): handle connection timeout gracefully
docs(readme): update installation instructions
refactor(models): improve type hints coverage
- Follow PEP 8 style guide
- Use type hints where possible
- Add docstrings for public methods
- Keep functions focused and small
- Add comments for complex logic
When adding features, update:
- README.md (if user-facing)
- INSTALL.md (if changes configuration)
- ENTITIES.md (if new entities)
- Code docstrings
- Type hints
Pull requests are reviewed for:
- Functionality - Does it work as intended?
- Code Quality - Is it maintainable?
- Tests - Are changes tested?
- Documentation - Is it documented?
- Compatibility - Does it break existing setups?
- Documentation: REFACTORING.md
- Entity Reference: ENTITIES.md
- Installation: INSTALL.md
- Original Project: homeassistant-apsystems_ecur
- Issues: GitHub Issues
- Discussions: GitHub Discussions
By contributing, you agree that your contributions will be licensed under the MIT License.
Thank you for contributing to APS2MQTT! 🌟