diff --git a/api/routes.py b/api/routes.py index acfa2a0..e2aa4eb 100644 --- a/api/routes.py +++ b/api/routes.py @@ -318,12 +318,12 @@ def register(app): @app.route("/api/v1/elm/profile/", methods=["PUT"]) def update_elm_profile(mac: str): - """Обновляет поля профиля (response_time_ms, elm_desc и т.д.).""" + """Обновляет поля профиля (response_time_ms и т.д.). Если профиля нет — создаёт.''' data = request.get_json(silent=True) or {} with Database() as db: p = db.get_device_profile(mac) if p is None: - return jsonify({"error": "not found"}), 404 + p = {"mac": mac, "level": 0, "supported": [], "unsupported": [], "errors": []} p.update(data) _save_profile(mac, p) return jsonify({"ok": True})