feat: implement Textual TUI and SQLite database for sensor management

This commit is contained in:
2025-12-29 09:39:33 +01:00
parent 4213b6101a
commit cfa24d1fa5
22 changed files with 1734 additions and 723 deletions

View File

@@ -65,29 +65,39 @@ sudo nano /etc/sensorpajen/sensorpajen.env
sudo systemctl restart sensorpajen
```
### Approving Sensors (Discovery Workflow)
### Sensor Management (TUI)
The service automatically discovers nearby Bluetooth sensors and stores them in a pending list. You approve which ones to monitor:
The service automatically discovers nearby Bluetooth sensors. You can manage them using the built-in Text UI:
```bash
# Start sensor discovery (if not already running)
sudo systemctl start sensorpajen
# Let it scan for a minute or two to discover sensors
sleep 120
# View discovered sensors and approve them
sudo sensorpajen approve-sensors
# Launch the management TUI
sudo sensorpajen-tui
```
The approval CLI will:
1. Show newly discovered sensors with their current readings
2. Ask you to approve, ignore, or skip each sensor
3. Save approved sensors to `/etc/sensorpajen/sensors.json`
4. Mark their status in `/var/lib/sensorpajen/discovered_sensors.json`
The TUI allows you to:
- **Discovery**: View newly discovered sensors and **Approve** (add to monitoring) or **Ignore** them.
- **Configured**: View currently monitored sensors, **Edit** their names, or **Remove** them.
- **Ignored**: View ignored sensors and **Unignore** them if you change your mind.
**Keybindings:**
- `a`: Approve selected sensor
- `i`: Ignore selected sensor
- `e`: Edit sensor name
- `u`: Unignore sensor
- `Delete`: Remove sensor from monitoring
- `r`: Refresh data
- `q`: Quit
When you approve a sensor, it's added to your configuration and the service automatically starts monitoring it.
### Legacy CLI Approval
If you prefer the command line, you can still use:
```bash
sudo sensorpajen approve-sensors
```
### MQTT Settings
Edit `config/sensorpajen.env`: