A switch monitoring system that detects circuit state changes via GPIO and sends webhook notifications to configured endpoints.
This is build by Jet Pham to be used at Noisebridge to replace their old discord status bot
cross command)| 1 | git clone https://github.com/yourusername/noisebell.git |
| 2 | cd noisebell |
| 1 | cargo build --release |
The default GPIO pin is set to 17. You can modify this in src/main.rs.
Webhook endpoints are stored in endpoints.json. The file should follow this format:
| 1 | { |
| 2 | "endpoints": [ |
| 3 | { |
| 4 | "url": "https://your-webhook-url.com", |
| 5 | "description": "Description of this endpoint" |
| 6 | } |
| 7 | ] |
| 8 | } |
| 1 | ./target/release/noisebell |
The server will:
127.0.0.1:8080| 1 | curl -X POST http://localhost:8080/endpoints \ |
| 2 | -H "Content-Type: application/json" \ |
| 3 | -d '{ |
| 4 | "url": "https://your-webhook-url.com", |
| 5 | "description": "My webhook" |
| 6 | }' |
When a circuit state change is detected, the following JSON payload is sent to all configured endpoints:
| 1 | { |
| 2 | "event_type": "circuit_state_change", |
| 3 | "timestamp": "2024-03-21T12:34:56Z", |
| 4 | "new_state": "open" // or "closed" |
| 5 | } |
The project includes a deployment script for Raspberry Pi. To deploy:
| 1 | cargo install cross |
| 1 | ./deploy.sh |
This will:
Logs are stored in the logs directory with daily rotation for the past 7 days