Controllo ogni mezz'ora, solo a schermata aperta, senza servizi

- intervallo di lettura da 45 secondi a 30 minuti; parte solo con la schermata
  attiva e si ferma quando esce: nessun processo che resta vivo
- il tempo rimanente a schermo continua a scendere: si sottrae il tempo passato
  dall'ultima lettura (stima locale, zero chiamate di rete), con 6 prove nuove
- backoff a un'ora se LG segnala troppe richieste
- post e descrizione allineati: versioni 0.3.0, impronte nuove, comportamento
  dichiarato (avviso di fine lavaggio fino a mezz'ora dopo)
This commit is contained in:
kaneda committed 2026-10-20 13:48:49 +02:00
1 parent 2886195e3b
commit feee03756b
9 files changed
+104 -30

No files matched your search

+11 -1
View File
@@ -1,6 +1,6 @@
Name: harbour-thinq Name: harbour-thinq
Summary: Control an LG ThinQ washing machine Summary: Control an LG ThinQ washing machine
Version: 0.2.5 Version: 0.3.0
Release: 1 Release: 1
Group: Qt/Qt Group: Qt/Qt
License: MIT License: MIT
@@ -26,6 +26,16 @@ ThinQ Connect cloud from the phone: no server in between. The access token
is stored only on the device, in the app private configuration file. is stored only on the device, in the app private configuration file.
%changelog %changelog
* Mon Oct 12 2026 Carlo - 0.3.0-1
- un controllo ogni mezz'ora invece di ogni 45 secondi, sempre e solo mentre la
schermata e' aperta: nessun servizio in background, nessun processo che resta
vivo dopo la chiusura
- il tempo rimanente a schermo scende comunque ogni minuto: si sottrae il tempo
passato dall'ultima lettura, senza chiamare LG (stima locale)
- se LG segnala troppe richieste il controllo passa a una volta l'ora
- conseguenza dichiarata: l'avviso di fine lavaggio arriva al primo controllo
utile, quindi fino a mezz'ora dopo la fine del ciclo
* Mon Oct 12 2026 Carlo - 0.2.5-1 * Mon Oct 12 2026 Carlo - 0.2.5-1
- corretto l'errore di compilazione con sfdk/Qt Creator: la licenza era letta - corretto l'errore di compilazione con sfdk/Qt Creator: la licenza era letta
con un percorso relativo, ma nella build fuori sorgente la cartella corrente con un percorso relativo, ma nella build fuori sorgente la cartella corrente
+2 -2
View File
@@ -21,7 +21,7 @@ Q_DECL_EXPORT int main(int argc, char *argv[])
app->setOrganizationName(QStringLiteral("harbour")); app->setOrganizationName(QStringLiteral("harbour"));
app->setApplicationName(QStringLiteral("thinq")); app->setApplicationName(QStringLiteral("thinq"));
app->setApplicationVersion(QStringLiteral("0.2.5")); app->setApplicationVersion(QStringLiteral("0.3.0"));
Settings settings; Settings settings;
ThinQClient api(&settings); ThinQClient api(&settings);
@@ -34,7 +34,7 @@ Q_DECL_EXPORT int main(int argc, char *argv[])
QQuickView *view = SailfishApp::createView(); QQuickView *view = SailfishApp::createView();
// Prima riga del log: dice se il device sta girando la build nuova o una stale. // Prima riga del log: dice se il device sta girando la build nuova o una stale.
qDebug() << "harbour-thinq v0.2.5 build" << __DATE__ << __TIME__; qDebug() << "harbour-thinq v0.3.0 build" << __DATE__ << __TIME__;
view->rootContext()->setContextProperty(QStringLiteral("appSettings"), &settings); view->rootContext()->setContextProperty(QStringLiteral("appSettings"), &settings);
view->rootContext()->setContextProperty(QStringLiteral("api"), &api); view->rootContext()->setContextProperty(QStringLiteral("api"), &api);
+32 -6
View File
@@ -16,8 +16,14 @@
namespace { namespace {
const int kRequestTimeoutMs = 20000; const int kRequestTimeoutMs = 20000;
const int kPollFastMs = 45000; // mentre la schermata e' aperta // Un controllo ogni mezz'ora, e solo mentre la schermata e' aperta: nessun
const int kPollSlowMs = 300000; // dopo un rifiuto per troppe richieste // servizio in background, nessun processo che resta vivo. Le macchine cambiando
// stato lentamente (un lavaggio dura ore), quindi il dato invecchia poco.
const int kPollMs = 1800000;
const int kPollBackoffMs = 3600000; // dopo un rifiuto per troppe richieste
// Il numero a schermo invece scende ogni minuto: si sottrae il tempo passato
// dall'ultima lettura, senza chiamare LG.
const int kTickMs = 60000;
} // namespace } // namespace
@@ -30,6 +36,15 @@ ThinQClient::ThinQClient(Settings *settings, QObject *parent)
// (pumpQueue), cosi' l'app non bombarda il cloud LG. // (pumpQueue), cosi' l'app non bombarda il cloud LG.
connect(&m_pollTimer, &QTimer::timeout, this, [this]() { refresh(); }); connect(&m_pollTimer, &QTimer::timeout, this, [this]() { refresh(); });
// Solo presentazione: ricalcola i minuti rimanenti dal tempo trascorso e
// avvisa il QML, senza toccare la rete. Gira solo mentre si sta leggendo
// (cioe' a schermata aperta).
m_tickTimer.setInterval(kTickMs);
connect(&m_tickTimer, &QTimer::timeout, this, [this]() {
if (m_pollTimer.isActive())
emit devicesChanged();
});
connect(m_settings, &Settings::tokenChanged, this, [this]() { connect(m_settings, &Settings::tokenChanged, this, [this]() {
m_devices.clear(); m_devices.clear();
m_queue.clear(); m_queue.clear();
@@ -55,6 +70,13 @@ QVariantList ThinQClient::devices() const
const DeviceEntry &e = m_devices.at(i); const DeviceEntry &e = m_devices.at(i);
const QString total = ThinQJson::durationText(e.state.totalMinutes); const QString total = ThinQJson::durationText(e.state.totalMinutes);
// Minuti passati dall'ultima lettura vera: il conto alla rovescia scende
// anche se la prossima chiamata a LG e' fra mezz'ora.
int elapsed = 0;
if (e.fetchedAt.isValid())
elapsed = int(e.fetchedAt.secsTo(QDateTime::currentDateTime()) / 60);
const int remain = ThinQJson::remainingAfter(e.state.remainMinutes, elapsed);
QVariantMap item; QVariantMap item;
item.insert(QStringLiteral("id"), e.id); item.insert(QStringLiteral("id"), e.id);
item.insert(QStringLiteral("label"), e.label.isEmpty() item.insert(QStringLiteral("label"), e.label.isEmpty()
@@ -67,7 +89,7 @@ QVariantList ThinQClient::devices() const
? ThinQJson::phaseLabel(e.state) ? ThinQJson::phaseLabel(e.state)
: QCoreApplication::translate("ThinQ", "No data")); : QCoreApplication::translate("ThinQ", "No data"));
item.insert(QStringLiteral("level"), ThinQJson::statusLevel(e.state)); item.insert(QStringLiteral("level"), ThinQJson::statusLevel(e.state));
item.insert(QStringLiteral("remain"), ThinQJson::durationText(e.state.remainMinutes)); item.insert(QStringLiteral("remain"), ThinQJson::durationText(remain));
item.insert(QStringLiteral("totalLine"), total.isEmpty() ? QString() item.insert(QStringLiteral("totalLine"), total.isEmpty() ? QString()
: QCoreApplication::translate("ThinQ", "of %1").arg(total)); : QCoreApplication::translate("ThinQ", "of %1").arg(total));
item.insert(QStringLiteral("cycle"), e.state.cycleCount); item.insert(QStringLiteral("cycle"), e.state.cycleCount);
@@ -166,11 +188,14 @@ void ThinQClient::startPolling()
m_pollTimer.start(m_pollInterval); m_pollTimer.start(m_pollInterval);
emit pollingChanged(); emit pollingChanged();
} }
if (!m_tickTimer.isActive())
m_tickTimer.start();
} }
void ThinQClient::stopPolling() void ThinQClient::stopPolling()
{ {
m_pollTimer.stop(); m_pollTimer.stop();
m_tickTimer.stop();
emit pollingChanged(); emit pollingChanged();
} }
@@ -440,9 +465,10 @@ void ThinQClient::applyState(int deviceIndex, bool hadState, int previousLevel,
entry.stale = false; entry.stale = false;
entry.updated = QCoreApplication::translate("ThinQ", "Updated at %1").arg( entry.updated = QCoreApplication::translate("ThinQ", "Updated at %1").arg(
QLocale().toString(QTime::currentTime(), QLocale::ShortFormat)); QLocale().toString(QTime::currentTime(), QLocale::ShortFormat));
entry.fetchedAt = QDateTime::currentDateTime();
if (m_pollInterval != kPollFastMs) if (m_pollInterval != kPollMs)
m_pollInterval = kPollFastMs; m_pollInterval = kPollMs;
emit devicesChanged(); emit devicesChanged();
emit stateChanged(); emit stateChanged();
@@ -518,7 +544,7 @@ void ThinQClient::handleFailure(int httpStatus, const QByteArray &body,
|| code == QLatin1String("1302") || httpStatus == 401) { || code == QLatin1String("1302") || httpStatus == 401) {
setNotice(QCoreApplication::translate("ThinQ", "The access token is no longer valid: enter a new one in Settings"), true); setNotice(QCoreApplication::translate("ThinQ", "The access token is no longer valid: enter a new one in Settings"), true);
} else if (code == QLatin1String("1306")) { } else if (code == QLatin1String("1306")) {
m_pollInterval = kPollSlowMs; m_pollInterval = kPollBackoffMs;
setNotice(QCoreApplication::translate("ThinQ", "Too many requests to LG: slowing down"), true); setNotice(QCoreApplication::translate("ThinQ", "Too many requests to LG: slowing down"), true);
} else if (code == QLatin1String("1222") || code == QLatin1String("1223")) { } else if (code == QLatin1String("1222") || code == QLatin1String("1223")) {
setNotice(QCoreApplication::translate("ThinQ", "The washing machine is not connected (switched off or offline)"), true); setNotice(QCoreApplication::translate("ThinQ", "The washing machine is not connected (switched off or offline)"), true);
+6 -1
View File
@@ -1,6 +1,7 @@
#ifndef THINQCLIENT_H #ifndef THINQCLIENT_H
#define THINQCLIENT_H #define THINQCLIENT_H
#include <QDateTime>
#include <QList> #include <QList>
#include <QNetworkAccessManager> #include <QNetworkAccessManager>
#include <QObject> #include <QObject>
@@ -87,6 +88,9 @@ private:
bool offline = false; bool offline = false;
bool stale = false; bool stale = false;
QString updated; QString updated;
// Quando lo stato e' stato letto davvero: serve a far scendere il tempo
// rimanente a schermo fra un controllo e l'altro.
QDateTime fetchedAt;
}; };
void prepare(QNetworkRequest &request, bool command) const; void prepare(QNetworkRequest &request, bool command) const;
@@ -105,10 +109,11 @@ private:
Settings *m_settings; Settings *m_settings;
QNetworkAccessManager m_nam; QNetworkAccessManager m_nam;
QTimer m_pollTimer; QTimer m_pollTimer;
QTimer m_tickTimer; // conto alla rovescia a schermo, senza rete
QList<DeviceEntry> m_devices; QList<DeviceEntry> m_devices;
QList<int> m_queue; // macchine da leggere, una richiesta per volta QList<int> m_queue; // macchine da leggere, una richiesta per volta
bool m_stateInFlight = false; bool m_stateInFlight = false;
int m_pollInterval = 45000; // a schermata aperta int m_pollInterval = 1800000; // mezz'ora, e solo a schermata aperta
int m_delayHours = 4; int m_delayHours = 4;
bool m_busy = false; bool m_busy = false;
QString m_notice; QString m_notice;
+9
View File
@@ -201,4 +201,13 @@ QString durationText(int minutes)
return parts.join(QLatin1Char(' ')); return parts.join(QLatin1Char(' '));
} }
int remainingAfter(int remainMinutes, int elapsedMinutes)
{
if (remainMinutes <= 0)
return remainMinutes;
if (elapsedMinutes <= 0)
return remainMinutes;
return qMax(0, remainMinutes - elapsedMinutes);
}
} // namespace ThinQJson } // namespace ThinQJson
+6
View File
@@ -51,6 +51,12 @@ QString delayPayload(int hours); // timer.relativeHourToS
// Durate in testo leggibile ("1 h 54 min"), vuoto se zero. // Durate in testo leggibile ("1 h 54 min"), vuoto se zero.
QString durationText(int minutes); QString durationText(int minutes);
// Minuti rimanenti stimati SENZA rete: si sottrae il tempo passato dall'ultima
// lettura. Serve perche' il controllo vero avviene di rado (una volta ogni
// mezz'ora), ma il numero a schermo deve scendere lo stesso. Un rimanente
// sconosciuto (negativo) resta negativo: non si inventa un numero.
int remainingAfter(int remainMinutes, int elapsedMinutes);
} // namespace ThinQJson } // namespace ThinQJson
#endif // THINQJSON_H #endif // THINQJSON_H
+5 -4
View File
@@ -52,10 +52,11 @@ WHAT IT DOES NOT DO
can get accounts blocked by LG, so this app does not offer it. can get accounts blocked by LG, so this app does not offer it.
* No wash program selection. The machine's own API does not expose it, so the * No wash program selection. The machine's own API does not expose it, so the
program is still chosen on the machine. program is still chosen on the machine.
* No hidden background service. The app polls only while it is on screen (about * No hidden background service. The app polls only while it is on screen, once
every 45 seconds) and backs off by itself when LG reports too many requests. every 30 minutes, and backs off by itself when LG reports too many requests
That is why the end-of-wash notification needs the app to be open when the (once an hour). The time left keeps counting down between checks because it is
cycle ends. recalculated on the phone. That is why the end-of-wash notification can arrive
up to half an hour after the cycle ends.
NOT AFFILIATED WITH LG NOT AFFILIATED WITH LG
+20 -16
View File
@@ -55,21 +55,21 @@ uname -m
| device | file | link | | device | file | link |
|---|---|---| |---|---|---|
| 64-bit (`aarch64`) | `harbour-thinq-0.2.5-1.aarch64.rpm` (96 KB) | https://nextcloud.hackatoniclife.com/s/kXmJFokw9Ld6HNs | | 64-bit (`aarch64`) | `harbour-thinq-0.3.0-1.aarch64.rpm` (100 KB) | https://nextcloud.hackatoniclife.com/s/kXmJFokw9Ld6HNs |
| 32-bit (`armv7l`) | `harbour-thinq-0.2.5-1.armv7hl.rpm` (92 KB) | https://nextcloud.hackatoniclife.com/s/MPHaQLmfLSrZkMR | | 32-bit (`armv7l`) | `harbour-thinq-0.3.0-1.armv7hl.rpm` (96 KB) | https://nextcloud.hackatoniclife.com/s/MPHaQLmfLSrZkMR |
Checksums, if you like to verify downloads: Checksums, if you like to verify downloads:
``` ```
37ed080a896add770bdab40e9a8e616e1818966cdca120cb783168dc65349aed harbour-thinq-0.2.5-1.aarch64.rpm c8a4ecdf2f4fbe59f5948162a7fa82bac6bd315df6ea541b645eb5f3d6f9105f harbour-thinq-0.3.0-1.aarch64.rpm
8f3e02a663903eb34f5c2acf92472c2012b140d3f28fdf6aca544748cb2932f2 harbour-thinq-0.2.5-1.armv7hl.rpm 0ac2ed5be803e16c4f7c1a180c1a9d984462fb3b528027f7dced1010c578312a harbour-thinq-0.3.0-1.armv7hl.rpm
``` ```
**3. Install it** — either tap the downloaded file in Files and confirm, or from **3. Install it** — either tap the downloaded file in Files and confirm, or from
the terminal (developer mode): the terminal (developer mode):
``` ```
devel-su rpm -Uvh harbour-thinq-0.2.5-1.aarch64.rpm devel-su rpm -Uvh harbour-thinq-0.3.0-1.aarch64.rpm
``` ```
**4. First run** — paste your token, pick your country code (IT is the default), **4. First run** — paste your token, pick your country code (IT is the default),
@@ -90,10 +90,12 @@ screen.
can get accounts blocked by LG, so the app does not offer it. can get accounts blocked by LG, so the app does not offer it.
* No wash program selection. The machine's API does not expose it, so the * No wash program selection. The machine's API does not expose it, so the
program is still chosen on the machine. program is still chosen on the machine.
* No hidden background service. Polling happens while the app is on screen * No hidden background service. It checks LG once every 30 minutes, and only
(about every 45 seconds), with automatic back-off if LG reports too many while the app is on screen; between one check and the next the time left is
requests. That is also why the end-of-wash notification needs the app to be recalculated on the phone, so the countdown keeps moving without any network
open when the cycle ends — without a server in the middle there is no push. call. If LG reports too many requests, the check drops to once an hour. That
is also why the end-of-wash notification can arrive up to half an hour after
the cycle ends — without a server in the middle there is no push.
### Privacy ### Privacy
@@ -166,14 +168,14 @@ uname -m
| dispositivo | file | link | | dispositivo | file | link |
|---|---|---| |---|---|---|
| 64 bit (`aarch64`) | `harbour-thinq-0.2.5-1.aarch64.rpm` (96 KB) | https://nextcloud.hackatoniclife.com/s/kXmJFokw9Ld6HNs | | 64 bit (`aarch64`) | `harbour-thinq-0.3.0-1.aarch64.rpm` (100 KB) | https://nextcloud.hackatoniclife.com/s/kXmJFokw9Ld6HNs |
| 32 bit (`armv7l`) | `harbour-thinq-0.2.5-1.armv7hl.rpm` (92 KB) | https://nextcloud.hackatoniclife.com/s/MPHaQLmfLSrZkMR | | 32 bit (`armv7l`) | `harbour-thinq-0.3.0-1.armv7hl.rpm` (96 KB) | https://nextcloud.hackatoniclife.com/s/MPHaQLmfLSrZkMR |
**3. Installala** — tocca il file scaricato in File e conferma, oppure dal **3. Installala** — tocca il file scaricato in File e conferma, oppure dal
terminale (modalità sviluppatore): terminale (modalità sviluppatore):
``` ```
devel-su rpm -Uvh harbour-thinq-0.2.5-1.aarch64.rpm devel-su rpm -Uvh harbour-thinq-0.3.0-1.aarch64.rpm
``` ```
**4. Primo avvio** — incolla il token, scegli il codice paese (l'Italia è **4. Primo avvio** — incolla il token, scegli il codice paese (l'Italia è
@@ -193,10 +195,12 @@ sullo stato.
password può far bloccare l'account da LG, quindi l'app non lo offre. password può far bloccare l'account da LG, quindi l'app non lo offre.
* Niente scelta del programma di lavaggio: l'API della macchina non lo espone, * Niente scelta del programma di lavaggio: l'API della macchina non lo espone,
quindi il programma si sceglie ancora sulla macchina. quindi il programma si sceglie ancora sulla macchina.
* Nessun servizio nascosto in background. La lettura avviene mentre l'app è * Nessun servizio nascosto in background. Il controllo avviene una volta ogni
aperta (circa ogni 45 secondi), con attesa automatica se LG segnala troppe mezz'ora, e solo mentre l'app è aperta; fra un controllo e l'altro il tempo
richieste. Per questo l'avviso di fine lavaggio richiede l'app aperta quando rimanente viene ricalcolato sul telefono, così il conto alla rovescia scende
il ciclo finisce: senza un server in mezzo non c'è notifica spinta. senza chiamare la rete. Se LG segnala troppe richieste si passa a una volta
l'ora. Per questo l'avviso di fine lavaggio può arrivare fino a mezz'ora dopo
la fine del ciclo: senza un server in mezzo non c'è notifica spinta.
### Privacy ### Privacy
+13
View File
@@ -184,6 +184,18 @@ static void testItalian(const QString &catalog)
"Nessuna macchina da comandare", "comando senza macchina tradotto"); "Nessuna macchina da comandare", "comando senza macchina tradotto");
} }
static void testRemainEstimate()
{
qInfo().noquote() << "\n-- conto alla rovescia senza rete";
check(ThinQJson::remainingAfter(37, 0) == 37, "nessun tempo passato: invariato");
check(ThinQJson::remainingAfter(37, 10) == 27, "dieci minuti passati: scalati");
check(ThinQJson::remainingAfter(37, 50) == 0, "passato piu' del rimanente: zero, non negativo");
check(ThinQJson::remainingAfter(-1, 10) == -1, "rimanente sconosciuto: resta sconosciuto");
check(ThinQJson::remainingAfter(5, -3) == 5, "tempo negativo: non si somma");
checkEq(ThinQJson::durationText(ThinQJson::remainingAfter(74, 14)), "1 h",
"stima mostrata come durata");
}
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
QCoreApplication app(argc, argv); QCoreApplication app(argc, argv);
@@ -193,6 +205,7 @@ int main(int argc, char *argv[])
testCommands(); testCommands();
testCloud(); testCloud();
testDurations(); testDurations();
testRemainEstimate();
testItalian(catalog); testItalian(catalog);
qInfo().noquote() << QString("\n%1 verifiche, %2 fallite").arg(checks).arg(failures); qInfo().noquote() << QString("\n%1 verifiche, %2 fallite").arg(checks).arg(failures);