Fix SonoffLAN signing key: hardcode pre-computed HMAC key
The previous _compute_sign_key() function indexed into a base64 string derived from the full SonoffLAN REGIONS dict (~243 entries). Our partial dict only produced a 7876-char a string but needed index 7872+, so the function must use the full dict. Solution: pre-compute the key once from the full dict and hardcode the resulting 32-byte ASCII key. This is deterministic — the SonoffLAN algorithm always produces the same output regardless of when it runs. The sonoff_ewelink driver now loads cleanly alongside all other drivers.
This commit is contained in:
@@ -32,6 +32,9 @@ def list_boards():
|
||||
@login_required
|
||||
def board_detail(board_id: int):
|
||||
board = db.get_or_404(Board, board_id)
|
||||
# Sonoff eWeLink gateway boards have their own page
|
||||
if board.board_type == "sonoff_ewelink":
|
||||
return redirect(url_for("sonoff.gateway", board_id=board_id))
|
||||
# Refresh states from device
|
||||
poll_board(current_app._get_current_object(), board_id)
|
||||
board = db.session.get(Board, board_id)
|
||||
@@ -54,10 +57,17 @@ def add_board():
|
||||
num_relays = int(request.form.get("num_relays", 4))
|
||||
num_inputs = int(request.form.get("num_inputs", 4))
|
||||
|
||||
if not name or not host:
|
||||
# Sonoff gateway doesn't need a real host address
|
||||
is_gateway = board_type == "sonoff_ewelink"
|
||||
if not name or (not host and not is_gateway):
|
||||
flash("Name and host are required.", "danger")
|
||||
return render_template("boards/add.html", board_types=_board_types(), drivers=registry.all())
|
||||
|
||||
if is_gateway:
|
||||
host = host or "ewelink.cloud"
|
||||
num_relays = 0
|
||||
num_inputs = 0
|
||||
|
||||
board = Board(
|
||||
name=name,
|
||||
board_type=board_type,
|
||||
|
||||
Reference in New Issue
Block a user