implement: Phase 25.5 device config from JSON file

- Create config/device.json with owner_name, car_model, device_name, avatar_path
- Update app_account.py to load owner_name and avatar_path from config
- Update app_car.py to load car_model and device_name from config
- Update base.html template to use avatar_path from config instead of hardcoded
- Add graceful fallback to hardcoded defaults if config file missing
- Document in deploy/readme.md and readme.md how to customize device identity
- Update PLAN.md Phase 25.5 to reflect current implementation and future server sync

Benefits:
- No code edits needed to customize Pi (edit JSON file only)
- Offline-first: all values loaded from local file at startup
- Connection-driven sync planned for Phase 25.5a (sync when internet available, not on timer)
- Server becomes source of truth after Phase 25.5a implementation

All 63 tests passing. Database filename still based on owner_name, with migration warning in docs.

Co-authored-by: Copilot <[email protected]>
This commit is contained in:
Mathieu Moran
2026-08-10 16:31:59 -04:00
co-authored by Copilot
parent 69beb07430
commit c65a635906
7 changed files with 164 additions and 53 deletions
+53 -16
View File
@@ -114,33 +114,70 @@ in [deploy/](./deploy). For a clean-install walkthrough on a fresh Pi, use
For the remote server (receives trip logs + dashcam uploads), see [server/README.md](./server/README.md).
## Customizing username and profile picture
## Customizing device identity
The top-right username and avatar in the local app are currently code-configured.
The Pi displays a username, car model, and avatar image. All customizable values are stored in `config/device.json` (no code edits needed).
### Change username
### Edit device configuration
Edit [modules/app_account.py](./modules/app_account.py):
Edit [config/device.json](./config/device.json):
```python
self.name = "quoije"
```json
{
"owner_name": "quoije",
"car_model": "Yaris 2013",
"device_name": "Yaris OBD",
"avatar_path": "img/yaris.png"
}
```
Set it to your preferred name, then restart the app/service.
| Field | Location | Purpose |
|-------|----------|---------|
| `owner_name` | Top-right of app topbar | Your name/username |
| `car_model` | Left sidebar (next to car icon) | Vehicle model/year |
| `device_name` | (Reserved) | Future server-side use in Phase 25.5 |
| `avatar_path` | Top-right avatar circle | Profile picture (relative to `static/`) |
> Important: `account.name` is also used in the local SQLite filename (`db/sql/<name>_<car>.db` via [modules/app_sql.py](./modules/app_sql.py)).
> If you already have trip data and change the name, the app will create a new DB file unless you rename/migrate the existing one.
After editing, restart the app:
### Change profile picture
```bash
# If running as a systemd service:
sudo systemctl restart yaris-obd.service
Current avatar is hardcoded in [templates/base.html](./templates/base.html) to:
```html
src="{{ url_for('static', filename='img/yaris.png') }}"
# If running manually:
# Ctrl+C and python3 app.py
```
Simplest option: replace [static/img/yaris.png](./static/img/yaris.png) with your image (same filename/path).
Alternative: edit the `filename='img/yaris.png'` value in [templates/base.html](./templates/base.html).
### Changing the profile picture
Option 1: Replace the default image file:
```bash
cp /path/to/your/image.png static/img/yaris.png
```
Option 2: Add your image to `static/img/` and update `avatar_path`:
```json
{
"avatar_path": "img/my-avatar.png"
}
```
### Important: Username and database filename
The local SQLite database filename is based on `owner_name`: `db/sql/<owner_name>_<car_model>.db` (via [modules/app_sql.py](./modules/app_sql.py)).
If you **change `owner_name`** and already have trip data:
- The app will create a **new database** with the new name
- Your old database remains at `db/sql/quoije_Yaris2013.db` (orphaned)
To preserve your data:
```bash
# Option 1: Rename the database file
mv db/sql/quoije_Yaris2013.db "db/sql/YourName_YourCar.db"
# Option 2: Start fresh
rm db/sql/quoije_Yaris2013.db
```
## Project status