Repository navigation
New landing page - #42
Merged
Merged
Conversation
- Moved inline HTML from `temp_monitor.py` to a new `index.html` file in the `templates` directory. - Updated the `index` function to use `render_template` instead of `render_template_string`. - Enhanced the styling and layout of the HTML for improved aesthetics and readability.
- Add /health, /metrics, and config endpoints with dedicated tests - Harden Bearer token auth and sensor data integrity checks - Improve webhook retry/backoff logic and add regression tests - Rename sense_hat.py -> mock_sense_hat.py and server.log -> logs/.gitkeep - Add .dockerignore and CI workflow updates for cleaner ARM builds - Add handoff skill for agent session handoffs
- Introduced new environment variables: `USE_MOCK_SENSOR`, `TEMP_CPU_FACTOR`, `TEMP_OFFSET_F`, and `HUMIDITY_OFFSET` for improved temperature and humidity calibration. - Updated `get_compensated_temperature()` to utilize these variables, allowing for dynamic calibration without code changes. - Enhanced logging to provide calibration details in the API response. - Added regression tests to ensure calibration parameters are correctly applied and adjustable by operators.
- Introduced centralized parsing functions for boolean and numeric environment variables to ensure consistent handling and error reporting. - Updated existing environment variable usages in `temp_monitor.py` to utilize the new parsing functions, improving reliability and maintainability. - Enhanced documentation in `CLAUDE.md` to clarify the expected formats for boolean variables. - Improved test suite by refactoring test classes to inherit from a base test class, streamlining setup processes.
The docker-build job boots the production image on an x86 GitHub runner, which has no Sense HAT. temp_monitor.py constructs SenseHat() at import time, so the real sense-hat package raised "Cannot detect RPi-Sense FB device" and waitress died before binding port 8080. Every one of the 30 health-check attempts then got connection refused. The job has never passed since it was added in 98852b8. Set USE_MOCK_SENSOR=1 and bind-mount mock_sense_hat.py from the checkout rather than adding it to the image. The mock is deliberately excluded from the image by both the Dockerfile COPY list and .dockerignore, and this keeps that guarantee intact: the image under test remains byte-for-byte what ships to the Pi, and the stub lives only as long as the CI container. Verified locally against a real build of the image: reproduced the original OSError, then confirmed the fixed invocation serves GET / and GET /health with 200 and renders the real dashboard template. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
- Introduced a new `.env.example` file to provide a template for required and optional environment variables, including `BEARER_TOKEN`, `LOG_FILE`, `CLOUDFLARED_TOKEN`, and webhook configurations. - Updated `AGENTS.MD`, `CLAUDE.md`, and `README.md` to reflect changes in alert cooldown settings and temperature calibration parameters. - Enhanced documentation for environment variable parsing and validation to improve clarity and consistency. - Added tests for environment variable parsing to ensure robustness against invalid configurations.
There was a problem hiding this comment.
Sorry @fakebizprez, your pull request is larger than the review limit of 150000 diff characters
Reviewer's GuideRefactors the temp monitor service to add a new templated landing page, harden environment parsing and authentication, improve health/ops behavior, strengthen webhook configuration/alerting robustness, and significantly expand test coverage and CI to catch regressions (including Docker image verification). Sequence diagram for PUT webhook config and service initializationsequenceDiagram
actor Client
participant Resource as WebhookConfigResource
participant Models as api_models
participant Service as WebhookService
participant WC as WebhookConfig
participant AT as AlertThresholds
Client->>Resource: PUT /api/webhook/config
Resource->>Resource: parse payload (webhooks_ns.payload)
Resource->>Models: validate_webhook_config(webhook)
Models-->>Resource: (is_valid, error_msg)
alt invalid webhook
Resource->>Resource: webhooks_ns.abort(400,...)
end
Resource->>Models: validate_thresholds(thresholds,current_thresholds)
Models-->>Resource: (is_valid, error_msg)
alt invalid thresholds
Resource->>Resource: webhooks_ns.abort(400,...)
end
Resource->>Resource: service_created_by_this_request = (webhook_service is None)
alt webhook config provided
opt no existing service
Resource->>Service: new WebhookService(alert_cooldown)
end
Resource->>WC: new WebhookConfig(merged fields)
WC-->>Resource: may raise ConfigValidationError
Resource->>Service: set_webhook_config(config)
end
alt thresholds provided
opt no existing service
Resource->>Service: new WebhookService(alert_thresholds,alert_cooldown)
end
Resource->>AT: new AlertThresholds(merged fields)
AT-->>Resource: may raise ConfigValidationError
Resource->>Service: set_alert_thresholds(thresholds)
end
alt ConfigValidationError
Resource->>Resource: webhooks_ns.abort(400,str(e))
end
alt service_created_by_this_request and status_update_enabled
Resource->>Resource: last_status_update = time.time()
end
Resource-->>Client: 200 SuccessResponse
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Member
Author
|
@coderabbitai review |
Member
Author
|
@greptileai review |
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
Test plan
for f in test_*.py; do [ "$f" = "test_support.py" ] && continue; python "$f" || break; donepython -m unittest discover -v -p 'test_*.py'🤖 Generated with Claude Code
Summary by Sourcery
Introduce a templated landing dashboard, harden configuration/auth/webhook behavior, and expand tests/CI to cover production-like behavior and deployment artifacts.
New Features:
Bug Fixes:
Enhancements:
Build:
CI:
Documentation:
Tests:
Greptile Summary
The PR introduces a standalone landing dashboard and substantially hardens sensor configuration, authenticated APIs, webhook behavior, health reporting, tests, and container deployment.
Confidence Score: 4/5
The PR is not yet safe to merge because threshold-only webhook configuration remains hidden by the configuration GET endpoint.
A threshold-only update stores active alert thresholds in WebhookService without creating webhook_config, while GET /api/webhook/config still treats the missing webhook_config as equivalent to a missing service and returns null thresholds.
Files Needing Attention: temp_monitor.py
Important Files Changed
Reviews (2): Last reviewed commit: "Add .env.example file and update documen..." | Re-trigger Greptile