Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
c7e437e
feat: Add Slack webhook notifications for temperature alerts
fakebizprez Dec 31, 2025
8450b0c
refactor: Remove auto-generate token feature
fakebizprez Dec 31, 2025
aaec873
docs: Update documentation for webhook feature
fakebizprez Dec 31, 2025
f53e8c9
feat: Integrate Flask-RESTX for webhook management API
fakebizprez Jan 1, 2026
a424d75
fix: Update webhook configuration model and API security settings
fakebizprez Jan 1, 2026
ac95667
Update .claude/skills/flask-restx-webhooks/SKILL.md
fakebizprez Jan 1, 2026
197e569
Update temp_monitor.py
fakebizprez Jan 1, 2026
3d75232
test: Add integration tests for webhook API endpoints
fakebizprez Jan 1, 2026
dfe75a7
fix: Use webhooks_ns.abort() for proper error responses
fakebizprez Jan 1, 2026
09f3251
fix: Validate URL requirement for partial webhook config updates
fakebizprez Jan 1, 2026
23ec9f4
Merge pull request #25 from freightCognition/hotfix/restx
fakebizprez Jan 1, 2026
b1524a4
fix: Remove validate=True to preserve backward-compatible error format
fakebizprez Jan 1, 2026
2c240b8
Merge pull request #26 from freightCognition/hotfix/restx
fakebizprez Jan 1, 2026
f8d905e
Update .claude/skills/flask-restx-webhooks/examples/basic-webhook.py
fakebizprez Jan 1, 2026
9633ab6
Update .claude/skills/flask-restx-webhooks/examples/test_webhook.py
fakebizprez Jan 1, 2026
2b72780
Update .claude/skills/flask-restx-webhooks/examples/webhook-with-sign…
fakebizprez Jan 1, 2026
7975449
feat: Add server-side validation for webhook config integer fields
fakebizprez Jan 1, 2026
62132af
Remove CLAUDE.md, WEBHOOK_QUICKSTART.md, and WEBHOOKS.md files as par…
fakebizprez Jan 1, 2026
50ffd7d
feat: Introduce comprehensive documentation for the Temperature Monit…
fakebizprez Jan 1, 2026
d898f21
fix: Add error correlation IDs and prevent internal error detail leakage
fakebizprez Jan 1, 2026
5a78d15
feat: Implement webhook URL masking for enhanced security
fakebizprez Jan 1, 2026
f9c5bf8
Update temp_monitor.log and temp_monitor.py for improved error handli…
fakebizprez Jan 1, 2026
7ec2336
Update test_webhook.py
fakebizprez Jan 1, 2026
cd6c463
Update temp_monitor.py
fakebizprez Jan 1, 2026
b6b2cea
Update temp_monitor.py
fakebizprez Jan 1, 2026
76eaf46
fix: require BEARER_TOKEN at startup, exit if missing
fakebizprez Jan 1, 2026
8bddbca
Rewrite webhook tests with proper mocking and payload assertions
fakebizprez Jan 1, 2026
56845bd
Remove deprecated agent files and documentation for codebase analysis…
fakebizprez Jan 1, 2026
33394f0
gitignore
fakebizprez Jan 1, 2026
7e51804
feat: Add comprehensive AGENTS.md documentation for Temperature Monit…
fakebizprez Jan 1, 2026
5ec4fba
Update temp_monitor.py
fakebizprez Jan 1, 2026
c8a9525
chore: Update subproject reference in exception-details
fakebizprez Jan 1, 2026
fd71045
Merge hotfix/exception-details into refactor/webhooks-tokens
fakebizprez Jan 1, 2026
753e9c8
refactor: Revise README for clarity and completeness
fakebizprez Jan 1, 2026
1a571f4
chore: Update Docker commands in documentation for consistency
fakebizprez Jan 1, 2026
aafccd6
feat: Add Cloudflare Tunnel support and update documentation
fakebizprez Jan 3, 2026
ab22fe9
feat: Enable manual workflow deployment from any branch for testing
fakebizprez Jan 3, 2026
c28089d
chore: Update configuration and documentation for webhook features
fakebizprez Jan 3, 2026
71589af
chore: Enable status updates in CI workflow
fakebizprez Jan 3, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 51 additions & 4 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,9 +1,56 @@
# Bearer token for API authentication
# Leave this blank or commented out on first run - a secure token will be auto-generated
# and saved to .env. Only set this if you want to use a specific token.
# BEARER_TOKEN=
# Bearer token for API authentication (REQUIRED)
# Generate a secure token with: python3 -c "import secrets; print(secrets.token_hex(32))"
# Then paste it here:
BEARER_TOKEN=

# Log file path (defaults to temp_monitor.log in current directory)
# Can be absolute or relative path
LOG_FILE=temp_monitor.log

# ===== CLOUDFLARED TUNNEL =====
# Cloudflare Tunnel token from Zero Trust dashboard
# Used by docker-compose cloudflared service
CLOUDFLARED_TOKEN=

# ===== WEBHOOK CONFIGURATION =====
# Slack incoming webhook URL for alerts and notifications (optional - required for webhook features)
# Get this from: https://api.slack.com/messaging/webhooks
SLACK_WEBHOOK_URL=

# Enable or disable webhook notifications (default: true)
WEBHOOK_ENABLED=true

# Webhook retry configuration
WEBHOOK_RETRY_COUNT=3
WEBHOOK_RETRY_DELAY=5
WEBHOOK_TIMEOUT=10

# ===== ALERT THRESHOLDS =====
# Temperature thresholds in Celsius (set to empty to disable)
# Default: 15°C (59°F) min, 27°C (80.6°F) max
ALERT_TEMP_MIN_C=15.0
ALERT_TEMP_MAX_C=27.0

# Humidity thresholds in percentage (set to empty to disable)
# Default: 30% min, 70% max
ALERT_HUMIDITY_MIN=30.0
ALERT_HUMIDITY_MAX=70.0

# ===== PERIODIC STATUS UPDATES =====
# Enable periodic status updates via webhook (default: false)
# Set to 'true' to receive regular status reports at specified intervals
STATUS_UPDATE_ENABLED=false

# Interval for status updates in seconds (default: 3600 = 1 hour)
# Common values:
# - 1800 = 30 minutes
# - 3600 = 1 hour (recommended)
# - 7200 = 2 hours
# - 14400 = 4 hours
# - 86400 = 24 hours (daily)
# Note: Cannot be less than 60 seconds (sampling interval)
STATUS_UPDATE_INTERVAL=3600

# Send status update immediately on startup (default: false)
# Useful for confirming service is running after deployment
STATUS_UPDATE_ON_STARTUP=false
133 changes: 133 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
name: CI

on:
workflow_dispatch:
inputs:
deploy_ref:
description: "Branch, tag, or SHA to deploy"
required: false
default: ""
environment:
description: "Deployment environment (for testing from feature branches)"
required: false
type: choice
options:
- production
- testing
default: "testing"
push:
branches: ["main", "master"]
pull_request:
branches: ["main", "master"]
release:
types: [published]

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
tests:
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
matrix:
python-version: ["3.9"]
env:
BEARER_TOKEN: test_token_ci
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.deploy_ref || github.ref }}

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: pip
cache-dependency-path: requirements.txt

- name: Install dependencies (exclude Sense HAT)
run: |
python -m pip install --upgrade pip
grep -v '^sense-hat' requirements.txt | grep -v '^#' | grep -v '^$' | xargs pip install

- name: Run tests
run: |
python test_webhook_api.py
python test_webhook.py
python test_periodic_updates.py
python test_api_models.py

deploy:
runs-on: self-hosted
needs: tests
timeout-minutes: 20
# SECURITY: Only deploy from trusted sources (requires write access to repo)
# - Manual trigger (workflow_dispatch) - requires write access
# - Release published - requires write access
# - Push to main/master - requires write access
# NEVER runs on pull_request events (untrusted forks could execute malicious code)
if: |
github.event_name == 'workflow_dispatch' ||
github.event_name == 'release' ||
(github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master'))
environment:
name: production
url: http://raspberrypi.local:8080
steps:
- name: Display deployment info
run: |
echo "Event: ${{ github.event_name }}"
echo "Ref: ${{ github.ref }}"
echo "Deploy ref: ${{ github.event.inputs.deploy_ref || github.ref }}"
echo "Environment: ${{ github.event.inputs.environment || 'production' }}"

- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.deploy_ref || github.ref }}

- name: Create .env from GitHub Secrets
run: |
# Validate required secrets
missing=""
for var in BEARER_TOKEN SLACK_WEBHOOK_URL; do
if [ -z "${!var}" ]; then
missing="$missing $var"
fi
done
if [ -n "$missing" ]; then
echo "Missing required secrets:$missing"
exit 1
fi

# Create .env file with all configuration
cat > .env <<EOF
BEARER_TOKEN=${BEARER_TOKEN}
CLOUDFLARED_TOKEN=${CLOUDFLARED_TOKEN}
SLACK_WEBHOOK_URL=${SLACK_WEBHOOK_URL}
WEBHOOK_ENABLED=true
ALERT_TEMP_MIN_C=15.0
ALERT_TEMP_MAX_C=27.0
ALERT_HUMIDITY_MIN=30.0
ALERT_HUMIDITY_MAX=70.0
STATUS_UPDATE_ENABLED=true
STATUS_UPDATE_INTERVAL=3600
STATUS_UPDATE_ON_STARTUP=true
EOF
chmod 600 .env
env:
BEARER_TOKEN: ${{ secrets.BEARER_TOKEN }}
CLOUDFLARED_TOKEN: ${{ secrets.CLOUDFLARED_TOKEN }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

- name: Ensure logs directory
run: mkdir -p logs

- name: Deploy with Docker Compose
run: docker compose -p temp-monitor up -d --build --remove-orphans
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ __pycache__/
*.py[cod]
*$py.class

.DS_Store
.DS_Store

.claude/
Loading