release: merge develop into master#18
Merged
Merged
Conversation
Ignore *.pyc, __pycache__/, .env and .pytest_cache/. Remove bme280.pyc which was mistakenly committed. Co-authored-by: agilicode <agilicode@gmail.com>
chore: add .gitignore and untrack compiled bytecode
Replace smbus with smbus2, rewrite print statements as f-strings, add type hints on all public functions. Move SMBus instantiation inside each function via context manager for testability. Add requirements.txt with pinned runtime dependencies. Co-authored-by: agilicode <agilicode@gmail.com>
feat: migrate driver to Python 3 with smbus2 and type hints
Replace sensor-api.py with sensor_api.py (valid Python module name). Move MQTT credentials and broker config to environment variables via python-dotenv. Add .env.example as reference template. Add HTTP 503 on sensor failure and 502 on MQTT failure. Set Flask debug=False by default, driven by FLASK_DEBUG env var. Co-authored-by: agilicode <agilicode@gmail.com>
feat(api): externalize config and add error handling
Add pytest suite with 19 tests covering: - Pure helper functions (_get_short, _get_ushort, _get_char, _get_uchar) - read_id and sensor() with smbus2 mocked via unittest.mock - All Flask routes including 503/502 error cases Add pytest.ini (testpaths, pythonpath) and requirements-dev.txt. Co-authored-by: agilicode <agilicode@gmail.com>
test: add unit tests for driver and API
Add multi-stage Dockerfile with a test target (pytest) and an app target (Flask on port 5000). Add docker-compose.yml with a test service and an app service ready for Raspberry Pi deployment (I2C device passthrough commented out). Co-authored-by: agilicode <agilicode@gmail.com>
feat: add multi-stage Dockerfile and docker-compose
AUDIT.md documents all findings (security, Python 2, error handling) with severity levels, a modernisation roadmap, usage examples and a CI pipeline proposal. CLAUDE.md provides project context for future Claude Code sessions: architecture, hardware constraints, algorithm notes, env var reference and testing approach. Co-authored-by: agilicode <agilicode@gmail.com>
docs: add AUDIT.md and CLAUDE.md
Add two jobs triggered on push and PR to develop/master: - test: builds the Docker test image with layer caching (GHA cache) and runs the full pytest suite inside the container - security: runs pip-audit against requirements.txt to catch CVEs in runtime dependencies Co-authored-by: agilicode <agilicode@gmail.com>
ci: add GitHub Actions pipeline
Remove both files from git history and add them to .gitignore. They remain on disk for local use but will never be committed. Co-authored-by: agilicode <agilicode@gmail.com>
chore: untrack AUDIT.md and CLAUDE.md, keep local only
Complete rewrite covering: hardware wiring, architecture diagram, installation, all env vars, CLI/API/Docker usage with examples, full API reference with request/response samples, Home Assistant MQTT integration, development setup, test output, project structure and sensor specifications table. Add CI badge. Co-authored-by: agilicode <agilicode@gmail.com>
docs(readme): rewrite with full reference, examples and badges
Add a lint job to the CI pipeline running flake8 (max-line-length=120) and mypy (--ignore-missing-imports) on bme280.py and sensor_api.py. Fix the one pre-existing E501 violation in bme280.py (line 127). Add flake8 and mypy to requirements-dev.txt. Co-authored-by: agilicode <agilicode@gmail.com>
ci: add flake8 and mypy lint jobs
Per Bosch BME280 SensorAPI spec (section 4.2), perform a soft reset (0xB6 → 0xE0) before each measurement to ensure a known state, then poll the status register (0xF3 bit 0) until the NVM copy completes. Raises OSError if NVM copy does not finish within 5 attempts. Add test covering the NVM timeout path. Co-authored-by: agilicode <agilicode@gmail.com>
fix: add soft reset and NVM copy wait on sensor init
After the Appendix B minimum wait, poll 0xF3 bit 3 (measuring) until the sensor confirms measurement completion, with up to 20 retries at 1ms intervals. Add test verifying the poll loop is exercised when the measuring bit is initially active. Co-authored-by: agilicode <agilicode@gmail.com>
…ling fix: poll measuring status register instead of fixed sleep only
Write config register 0xF5 (bits [4:2]) before each measurement. Defaults to 0 (filter off) to preserve existing behavior. Recommended value for indoor use is 2 (4x coefficient). Document the new variable in .env.example and README. Co-authored-by: agilicode <agilicode@gmail.com>
feat: add IIR filter configuration via BME280_IIR_FILTER env var
The official Bosch SensorAPI reads only 1 byte from register 0xD0. Register 0xD1 is undocumented — reading it was a leftover from the original Matt Hawkins driver. Return (chip_id, 0) to preserve the existing tuple API without breaking callers. Update tests to assert read_byte_data is used and called with 0xD0. Co-authored-by: agilicode <agilicode@gmail.com>
fix: read chip ID with single byte read from 0xD0
Add end-to-end flow diagram (sensor → driver → API → broker → HA), prerequisites (Mosquitto add-on, user creation, MQTT integration setup), MQTT auto-discovery commands (Option A) as the recommended approach alongside the existing manual configuration.yaml config (Option B), and a troubleshooting table. Add ha-mqtt-discovery reference link. Co-authored-by: agilicode <agilicode@gmail.com>
docs: expand Home Assistant MQTT integration section
Move each major section (Hardware, Architecture, Installation, Configuration, Usage, API Reference, Home Assistant, Development, Project Structure) into its own markdown file under docs/. README.md is now a lightweight entry point: badges, quick start, and a navigation table linking to all docs/ files. Co-authored-by: agilicode <agilicode@gmail.com>
docs: split README into individual files under docs/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Full modernization of the BME280 project since last release: