homelab-brain/edelmetall/STATE.md
2026-02-26 22:12:27 +07:00

109 lines
3.5 KiB
Markdown

# Edelmetall Dashboard — Live State
> Zuletzt aktualisiert: 24.02.2026
## Services
| Service | Container | URL | Status |
|---|---|---|---|
| **Dashboard V3** | CT 136, pve1 (Kambodscha) | https://blei.orbitalo.info | ✅ Aktiv |
| Dashboard V3 Tailscale | CT 136, pve1 | http://100.72.230.87:8501 | ✅ Aktiv |
| **Telegram Bot** | CT 136, pve1 | — | ✅ Aktiv |
| CT 135 (V2) | pve1 | — | ⛔ Gestoppt 2026-02-23 |
## Zugang
```bash
ssh root@100.122.56.60 # pve1 Kambodscha (Tailscale)
pct exec 136 -- bash
systemctl status edelmetall-dashboard # Streamlit
systemctl status edelmetall-telegram # Telegram Bot
systemctl status cloudflared # Tunnel
# Logs
pct exec 136 -- tail -f /opt/edelmetall/logs/scraper.log
pct exec 136 -- journalctl -u edelmetall-telegram -f
# Scraper manuell
pct exec 136 -- bash -c "source /opt/edelmetall/venv/bin/activate && python3 /opt/edelmetall/scrape.py"
```
## Code-Struktur (CT 136: /opt/edelmetall/)
```
core/
db.py DB-Verbindung + Schema
prices.py Spot + Händler, COALESCE(buy_price, sell_price)
portfolio.py Portfolio-Berechnung (Krügerrand-Ankaufspreis)
scrapers/
proaurum.py Selenium — CSS Modules [class*='product-root'] (gefixt 2026-02-24)
degussa.py requests Fallback
dashboard/
app.py, tab_*.py Streamlit Dashboard
bot.py Telegram Bot V3
scrape.py Haupt-Scraper (PA → Degussa Fallback bei 0 Ergebnissen)
fetch_spot.py Spot-Preis alle 30min
data/edelmetall.db SQLite
```
## Cron-Jobs (CT 136)
```
*/30 * * * * python3 /opt/edelmetall/fetch_spot.py
0 7 * * * python3 /opt/edelmetall/scrape.py
0 13 * * * python3 /opt/edelmetall/scrape.py
0 21 * * * python3 /opt/edelmetall/scrape.py
```
## Telegram Bot
| Info | Wert |
|---|---|
| Token | 8262992299:AAEf8YHPsz42ZdP85DV7JqC4822Ts75GqF4 |
| Service | edelmetall-telegram.service |
| Befehle | /start /portfolio /preise /ratio /status |
## Portfolio-Konfiguration
| Parameter | Wert |
|---|---|
| Gold | 33 oz Krügerrand |
| Silber | 500 oz Silbermünzen |
| Startdatum | 2025-12-28 |
| Einkauf Gold | 3.774 EUR/oz |
| Einkauf Silber | 66,80 EUR/oz |
## Datenbank (Stand 24.02.2026)
| Tabelle | Einträge | Zeitraum |
|---|---|---|
| spot_prices | 2.031 | 2025-12-18 bis heute |
| gold_prices | 16.776 | 2025-12-18 bis heute |
| silver_prices | 14.033 | 2025-12-18 bis heute |
## Scraper-Logik
1. **Pro Aurum** (Selenium) — primär
- Selektor: `[class*='product-root']` (CSS Modules, Stand 2026-02-24)
- Preise: `[class*='buySellSection-price']` — Index 0 = Kaufpreis, Index 1 = Ankaufspreis
- Fallback bei 0 Ergebnissen → Degussa (nicht nur bei Exception!)
2. **Degussa** (requests) — Fallback
3. Portfolio nutzt **Ankaufspreis** (buy_price) für Bewertung
4. COALESCE(buy_price, sell_price) in SQL falls Ankaufspreis fehlt
## Fixes 24.02.2026
| Problem | Ursache | Fix |
|---|---|---|
| Scraper: 0 Produkte | Pro Aurum CSS Modules → alter Selektor | `[class*='product-root']` |
| Fallback nie aktiv | Exception nur bei Fehler, nicht bei leer | `raise ValueError` bei 0 Ergebnissen |
| Bot: "Keine Preise" | SQLite `'localtime'` → +7h Versatz | `'localtime'` entfernt |
| Portfolio zu hoch | buy/sell Preise vertauscht (10% Fehler) | `buySellSection-price` Index-Reihenfolge |
| buy_price NULL | Neuer Selektor fand Ankauf nicht | `COALESCE(buy_price, sell_price)` |
## Konnektivität CT 136
| Typ | Wert |
|---|---|
| Cloudflare Tunnel | c94b28f3-f473-475a-87da-b87c1806ecd8 |
| Tailscale | 100.72.230.87 |