Prima versione di ThinQ: stato e comandi della lavasciuga via cloud LG

- elenco delle macchine e stato in lettura, fasi tradotte in italiano
- avvio, stop, spegnimento, ripresa e stop ritardato da 3 a 19 ore
- chiave di accesso custodita solo sul telefono, nel file privato dell'app
- 44 verifiche automatiche sul nucleo (scripts/test-core.sh)
- interfaccia italiana o inglese secondo la lingua del telefono
This commit is contained in:
kaneda committed 2026-10-12 12:03:23 +02:00
commit b5f6e79146
32 files changed
+2859

No files matched your search

+146
View File
@@ -0,0 +1,146 @@
#!/usr/bin/env python3
"""Riempie il catalogo italiano di harbour-thinq.
- aggiunge language="it_IT" all'intestazione (senza, lupdate non lo aggiorna piu');
- sostituisce il blocco <translation> INTERO per ogni voce (mai solo il tag di
apertura: un edit parziale rompe il parse di lrelease).
Uso: python3 scripts/fill_translations.py
"""
from __future__ import annotations
import re
import sys
import xml.etree.ElementTree as ET
from pathlib import Path
TS = Path(__file__).resolve().parent.parent / "translations" / "harbour-thinq-it.ts"
IT = {
"No data": "Nessun dato",
"Delayed stop": "Stop ritardato",
"Delayed stop…": "Stop ritardato…",
"Set": "Imposta",
"The machine will stop on its own after the chosen time, then resume its programme.":
"La macchina si ferma da sola allo scadere del tempo scelto, poi riprende il programma.",
"Refresh": "Aggiorna",
"Switch off": "Spegni",
"Wake the display up": "Risveglia il display",
"Settings": "Impostazioni",
"Not up to date": "Non aggiornato",
"Not configured": "Da configurare",
"Enter the LG access token in Settings and pick your machine.":
"Inserisci la chiave di accesso LG nelle Impostazioni e scegli la macchina.",
"of %1": "su %1",
"Cycle": "Ciclo",
"Remote start": "Avvio a distanza",
"on": "attivo",
"off": "spento",
"To send commands, switch remote start on from the machine panel.":
"Per inviare comandi, accendi l'avvio a distanza dal pannello della macchina.",
"LG account": "Account LG",
"The access token comes from connect-pat.lgthinq.com and stays on this phone only. "
"If LG starts refusing it, paste a new one here.":
"La chiave di accesso si crea su connect-pat.lgthinq.com e resta solo su questo "
"telefono. Se LG non la accetta piu', incollane una nuova qui.",
"Access token": "Chiave di accesso",
"paste the token": "incolla la chiave",
"Country code": "Paese",
"Save the token": "Salva la chiave",
"Machine": "Macchina",
"Find my machines": "Trova le macchine",
"Selected: %1": "Scelta: %1",
"Language": "Lingua",
"System": "Sistema",
"Version %1": "Versione %1",
"Washing machine": "Lavatrice",
"Start": "Avvia",
"Stop": "Ferma",
"Resume": "Riprendi",
"Enter the access token first": "Inserisci prima la chiave di accesso",
"Machine selected": "Macchina scelta",
"No data from the machine yet": "Ancora nessun dato dalla macchina",
"No washing machine found on this account": "Nessuna lavatrice trovata su questo account",
"Machines found: %1": "Macchine trovate: %1",
"Command sent": "Comando inviato",
"Set the access token and the machine first":
"Imposta prima la chiave di accesso e la macchina",
"Remote start is off on the machine: switch it on from its panel":
"L'avvio a distanza e' spento sulla macchina: accendilo dal pannello",
"Updated at %1": "Aggiornato alle %1",
"The access token is no longer valid: enter a new one in Settings":
"La chiave di accesso non e' piu' valida: inseriscine una nuova nelle Impostazioni",
"Too many requests to LG: slowing down": "Troppe richieste a LG: rallento gli aggiornamenti",
"The washing machine is not connected (switched off or offline)":
"La lavatrice non e' collegata (spenta o senza rete)",
"The machine does not accept this command": "La macchina non accetta questo comando",
"LG error %1: %2": "Errore LG %1: %2",
"No answer from the LG cloud: %1": "Nessuna risposta dal cloud LG: %1",
"The LG cloud refused the request (HTTP %1)":
"Il cloud LG ha rifiutato la richiesta (HTTP %1)",
"Washing": "In lavaggio",
"Rinsing": "In risciacquo",
"Spinning": "In centrifuga",
"Drying": "In asciugatura",
"Cooling down": "Raffreddamento",
"Refreshing": "Rinfrescando",
"Steam softening": "Ammorbidente a vapore",
"Detecting the load": "Rilevamento del carico",
"Delayed start": "Partenza ritardata",
"Rinse hold": "Ammollo",
"Paused": "In pausa",
"Finished": "Fine",
"Ready": "Pronta",
"Off": "Spenta",
"Standby": "In attesa",
"Error": "Errore",
}
def main() -> int:
text = TS.read_text(encoding="utf-8")
# language: senza, lupdate rifiuta di aggiornare il file in futuro.
if 'language="' not in text:
text = text.replace('<TS version="2.1">', '<TS version="2.1" language="it_IT">', 1)
else:
text = re.sub(r'language="[^"]*"', 'language="it_IT"', text, count=1)
missing: list[str] = []
def repl(match: re.Match) -> str:
block = match.group(0)
src = re.search(r"<source>(.*?)</source>", block, re.S)
if not src:
return block
source = src.group(1)
it = IT.get(source)
if it is None:
missing.append(source)
return block
# si sostituisce il blocco <translation> INTERO, non solo il tag
new_block = re.sub(r"<translation.*?</translation>",
f"<translation>{it}</translation>", block, flags=re.S)
if new_block == block:
new_block = block.replace("</message>",
f" <translation>{it}</translation>\n </message>")
return new_block
text = re.sub(r"<message>.*?</message>", repl, text, flags=re.S)
TS.write_text(text, encoding="utf-8")
# validazione XML: un edit a mano malformato ferma lrelease con messaggi oscuri
ET.parse(TS)
if missing:
print(f"ATTENZIONE: {len(missing)} voci senza traduzione:", file=sys.stderr)
for m in missing:
print(" -", m, file=sys.stderr)
return 1
print("catalogo italiano completo e XML valido")
return 0
if __name__ == "__main__":
raise SystemExit(main())
+65
View File
@@ -0,0 +1,65 @@
#!/bin/sh
# Pubblica l'RPM di harbour-thinq su Nextcloud a un percorso FISSO, cosi' il
# link pubblico resta lo stesso ad ogni versione (l'utente lo scarica dal
# telefono con un tocco solo).
#
# Uso: sh scripts/publish-rpm.sh [percorso-rpm]
set -e
APP=harbour-thinq
TOKEN=$(cat /home/kaneda/.hermes/profiles/carlo/skills/nextcloud-calendar/token.secret)
NC=https://nextcloud.hackatoniclife.com
DAV="$NC/remote.php/dav/files/carlo/ThinQ"
RPM_DIR=/home/kaneda/workspace/Carlo/AppSailfish/pacchetti/rpm-SailfishOS-5.1.0.11-aarch64
RPM=${1:-$(ls -t "$RPM_DIR"/$APP-*.aarch64.rpm 2>/dev/null | head -1)}
[ -f "$RPM" ] || { echo "RPM non trovato: $RPM" >&2; exit 1; }
LOCAL_SHA=$(sha256sum "$RPM" | cut -d' ' -f1)
echo "RPM locale: $RPM"
echo "sha256 : $LOCAL_SHA"
# cartella remota (MKCOL e' idempotente: 405 se esiste gia')
curl -s -o /dev/null -w "MKCOL %{http_code}\n" -u "carlo:$TOKEN" -X MKCOL "$DAV/"
# upload: PUT sullo stesso percorso mantiene lo share esistente
curl -s -o /dev/null -w "PUT %{http_code}\n" -u "carlo:$TOKEN" \
-T "$RPM" -H "Content-Type: application/x-rpm" "$DAV/$APP.rpm"
# share pubblico: lo si riusa se esiste, altrimenti lo si crea (shareType=3)
SHARE=$(curl -s -u "carlo:$TOKEN" -H "OCS-APIRequest: true" \
"$NC/ocs/v2.php/apps/files_sharing/api/v1/shares?path=/ThinQ/$APP.rpm&format=json")
TOK=$(printf '%s' "$SHARE" | python3 -c "
import json,sys
try:
d = json.load(sys.stdin)
items = d['ocs']['data']
print(items[0]['token'] if items else '')
except Exception:
print('')")
if [ -z "$TOK" ]; then
SHARE=$(curl -s -X POST "$NC/ocs/v2.php/apps/files_sharing/api/v1/shares" \
-u "carlo:$TOKEN" -H "OCS-APIRequest: true" \
-d "path=/ThinQ/$APP.rpm" -d "shareType=3" -d "permissions=1" -d "format=json")
TOK=$(printf '%s' "$SHARE" | python3 -c "
import json,sys
print(json.load(sys.stdin)['ocs']['data']['token'])")
echo "share creato"
else
echo "share riusato"
fi
echo "link: $NC/s/$TOK"
# verifica anonima: il download deve dare 200 e la STESSA impronta
curl -sL -o /tmp/$APP-check.rpm "$NC/s/$TOK/download"
curl -s -o /dev/null -w "pagina pubblica %{http_code}\n" "$NC/s/$TOK"
REMOTE_SHA=$(sha256sum /tmp/$APP-check.rpm | cut -d' ' -f1)
echo "sha256 scaricato: $REMOTE_SHA"
if [ "$LOCAL_SHA" = "$REMOTE_SHA" ]; then
echo "OK: il link serve la versione compilata"
else
echo "ATTENZIONE: impronte diverse" >&2
exit 1
fi
+23
View File
@@ -0,0 +1,23 @@
#!/bin/sh
# Banco di prova del nucleo, senza kit Sailfish: compila con il Qt 5.15 desktop
# e verifica parsing, comandi, indirizzi, durate e catalogo italiano.
set -e
cd "$(dirname "$0")/.."
QT_BIN="$HOME/Qt/5.15.2/gcc_64/bin"
if [ ! -x "$QT_BIN/qmake" ]; then
QT_BIN="$HOME/.hermes/profiles/carlo/home/Qt/5.15.2/gcc_64/bin"
fi
PATH="$QT_BIN:$PATH"
# Il catalogo: se non c'e' (o non e' aggiornato) lo si genera ora, cosi' il
# controllo delle traduzioni non e' mai un salto silenzioso.
lrelease translations/harbour-thinq-it.ts -qm /tmp/harbour-thinq_it.qm
rm -rf build-tests
mkdir -p build-tests
cd build-tests
qmake ../tests/core_test.pro >/dev/null
make -j4 >/dev/null
./core_test /tmp/harbour-thinq_it.qm