Raspberry Pi
Statut connexion
Hors ligne
Dernier ping
08/05 21:45:17
Il y a 40422min
Firmware
audit-test
En attente
0 action
En cours
2 actions
Dernière action : post_listing 23/04 09:15
πŸ”‘ Authentification RPi
Le RPi doit envoyer ce secret dans le header : X-RPi-Secret: <secret>
βš™οΈ Changer le secret
πŸ“‹ Logs Raspberry Pi
#NiveauMessageAction IDDate
1 info Audit test log β€” 23/04 09:17:33
πŸ“š Documentation API pour le Raspberry Pi

ImplΓ©mentez ces appels API dans votre code Python sur le Raspberry Pi (src/orchestrator.py).

POST https://plzbot.fr/api.php?action=rpi_ping
Heartbeat β€” Γ€ appeler toutes les 60s pour signaler que le RPi est actif.
Body / Params
{"firmware": "1.0.0", "slots_active": ["slot_1", "slot_2"]}
RΓ©ponse
{"success": true, "data": {"server_time": "2026-04-23T12:00:00", "pending_actions": 3}}
GET https://plzbot.fr/api.php?action=rpi_pull_action
Pull — Récupère la prochaine action à exécuter. Retourne null si file vide.
Body / Params
Header: X-RPi-Secret: <votre_secret>  (optionnel: &slot_id=slot_1)
RΓ©ponse
{"success": true, "data": {"action": {"id": 42, "action_type": "post_listing", "slot_id": "slot_1", "target_id": "SKU001", "payload": {"sku": "SKU001"}}}}
POST https://plzbot.fr/api.php?action=rpi_complete_action
Complete β€” Signale qu'une action est terminΓ©e.
Body / Params
{"action_id": 42, "success": true, "result": {"vinted_id": "123456"}, "duration_ms": 3200}
RΓ©ponse
{"success": true}
POST https://plzbot.fr/api.php?action=rpi_log
Log β€” Envoie un message de log au dashboard.
Body / Params
{"action_id": 42, "message": "Screenshot pris", "level": "info", "context": {"duration_ms": 450}}
RΓ©ponse
{"success": true, "data": {"log_id": 101}}
Exemple Python (boucle principale RPi)
import requests, time

API = "https://plzbot.fr/api.php"
SECRET = "ccd8d15c85cc019a"
HEADERS = {"X-RPi-Secret": SECRET}

def ping():
    requests.post(f"{API}?action=rpi_ping", json={"firmware": "1.0.0"}, headers=HEADERS, timeout=10)

def pull_and_execute():
    r = requests.get(f"{API}?action=rpi_pull_action", headers=HEADERS, timeout=10).json()
    action = r.get("data", {}).get("action")
    if not action:
        return
    try:
        result = execute_action(action)  # votre logique ici
        requests.post(f"{API}?action=rpi_complete_action",
            json={"action_id": action["id"], "success": True, "result": result},
            headers=HEADERS, timeout=10)
    except Exception as e:
        requests.post(f"{API}?action=rpi_complete_action",
            json={"action_id": action["id"], "success": False},
            headers=HEADERS, timeout=10)

while True:
    ping()
    for _ in range(6):  # Pull toutes les 10s, ping toutes les 60s
        pull_and_execute()
        time.sleep(10)