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:
1 parent
2886195e3b
commit
feee03756b
9 files changed
+104
-30
No files matched your search
+11
-1
@@ -1,6 +1,6 @@
|
||||
Name: harbour-thinq
|
||||
Summary: Control an LG ThinQ washing machine
|
||||
Version: 0.2.5
|
||||
Version: 0.3.0
|
||||
Release: 1
|
||||
Group: Qt/Qt
|
||||
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.
|
||||
|
||||
%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
|
||||
- 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
|
||||
|
||||
+2
-2
@@ -21,7 +21,7 @@ Q_DECL_EXPORT int main(int argc, char *argv[])
|
||||
|
||||
app->setOrganizationName(QStringLiteral("harbour"));
|
||||
app->setApplicationName(QStringLiteral("thinq"));
|
||||
app->setApplicationVersion(QStringLiteral("0.2.5"));
|
||||
app->setApplicationVersion(QStringLiteral("0.3.0"));
|
||||
|
||||
Settings settings;
|
||||
ThinQClient api(&settings);
|
||||
@@ -34,7 +34,7 @@ Q_DECL_EXPORT int main(int argc, char *argv[])
|
||||
QQuickView *view = SailfishApp::createView();
|
||||
|
||||
// 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("api"), &api);
|
||||
|
||||
+32
-6
@@ -16,8 +16,14 @@
|
||||
namespace {
|
||||
|
||||
const int kRequestTimeoutMs = 20000;
|
||||
const int kPollFastMs = 45000; // mentre la schermata e' aperta
|
||||
const int kPollSlowMs = 300000; // dopo un rifiuto per troppe richieste
|
||||
// Un controllo ogni mezz'ora, e solo mentre la schermata e' aperta: nessun
|
||||
// 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
|
||||
|
||||
@@ -30,6 +36,15 @@ ThinQClient::ThinQClient(Settings *settings, QObject *parent)
|
||||
// (pumpQueue), cosi' l'app non bombarda il cloud LG.
|
||||
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]() {
|
||||
m_devices.clear();
|
||||
m_queue.clear();
|
||||
@@ -55,6 +70,13 @@ QVariantList ThinQClient::devices() const
|
||||
const DeviceEntry &e = m_devices.at(i);
|
||||
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;
|
||||
item.insert(QStringLiteral("id"), e.id);
|
||||
item.insert(QStringLiteral("label"), e.label.isEmpty()
|
||||
@@ -67,7 +89,7 @@ QVariantList ThinQClient::devices() const
|
||||
? ThinQJson::phaseLabel(e.state)
|
||||
: QCoreApplication::translate("ThinQ", "No data"));
|
||||
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()
|
||||
: QCoreApplication::translate("ThinQ", "of %1").arg(total));
|
||||
item.insert(QStringLiteral("cycle"), e.state.cycleCount);
|
||||
@@ -166,11 +188,14 @@ void ThinQClient::startPolling()
|
||||
m_pollTimer.start(m_pollInterval);
|
||||
emit pollingChanged();
|
||||
}
|
||||
if (!m_tickTimer.isActive())
|
||||
m_tickTimer.start();
|
||||
}
|
||||
|
||||
void ThinQClient::stopPolling()
|
||||
{
|
||||
m_pollTimer.stop();
|
||||
m_tickTimer.stop();
|
||||
emit pollingChanged();
|
||||
}
|
||||
|
||||
@@ -440,9 +465,10 @@ void ThinQClient::applyState(int deviceIndex, bool hadState, int previousLevel,
|
||||
entry.stale = false;
|
||||
entry.updated = QCoreApplication::translate("ThinQ", "Updated at %1").arg(
|
||||
QLocale().toString(QTime::currentTime(), QLocale::ShortFormat));
|
||||
entry.fetchedAt = QDateTime::currentDateTime();
|
||||
|
||||
if (m_pollInterval != kPollFastMs)
|
||||
m_pollInterval = kPollFastMs;
|
||||
if (m_pollInterval != kPollMs)
|
||||
m_pollInterval = kPollMs;
|
||||
|
||||
emit devicesChanged();
|
||||
emit stateChanged();
|
||||
@@ -518,7 +544,7 @@ void ThinQClient::handleFailure(int httpStatus, const QByteArray &body,
|
||||
|| code == QLatin1String("1302") || httpStatus == 401) {
|
||||
setNotice(QCoreApplication::translate("ThinQ", "The access token is no longer valid: enter a new one in Settings"), true);
|
||||
} else if (code == QLatin1String("1306")) {
|
||||
m_pollInterval = kPollSlowMs;
|
||||
m_pollInterval = kPollBackoffMs;
|
||||
setNotice(QCoreApplication::translate("ThinQ", "Too many requests to LG: slowing down"), true);
|
||||
} else if (code == QLatin1String("1222") || code == QLatin1String("1223")) {
|
||||
setNotice(QCoreApplication::translate("ThinQ", "The washing machine is not connected (switched off or offline)"), true);
|
||||
|
||||
+6
-1
@@ -1,6 +1,7 @@
|
||||
#ifndef THINQCLIENT_H
|
||||
#define THINQCLIENT_H
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QList>
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QObject>
|
||||
@@ -87,6 +88,9 @@ private:
|
||||
bool offline = false;
|
||||
bool stale = false;
|
||||
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;
|
||||
@@ -105,10 +109,11 @@ private:
|
||||
Settings *m_settings;
|
||||
QNetworkAccessManager m_nam;
|
||||
QTimer m_pollTimer;
|
||||
QTimer m_tickTimer; // conto alla rovescia a schermo, senza rete
|
||||
QList<DeviceEntry> m_devices;
|
||||
QList<int> m_queue; // macchine da leggere, una richiesta per volta
|
||||
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;
|
||||
bool m_busy = false;
|
||||
QString m_notice;
|
||||
|
||||
@@ -201,4 +201,13 @@ QString durationText(int minutes)
|
||||
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
|
||||
@@ -51,6 +51,12 @@ QString delayPayload(int hours); // timer.relativeHourToS
|
||||
// Durate in testo leggibile ("1 h 54 min"), vuoto se zero.
|
||||
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
|
||||
|
||||
#endif // THINQJSON_H
|
||||
@@ -52,10 +52,11 @@ WHAT IT DOES NOT DO
|
||||
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
|
||||
program is still chosen on the machine.
|
||||
* No hidden background service. The app polls only while it is on screen (about
|
||||
every 45 seconds) 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
|
||||
cycle ends.
|
||||
* No hidden background service. The app polls only while it is on screen, once
|
||||
every 30 minutes, and backs off by itself when LG reports too many requests
|
||||
(once an hour). The time left keeps counting down between checks because it is
|
||||
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
|
||||
|
||||
|
||||
+20
-16
@@ -55,21 +55,21 @@ uname -m
|
||||
|
||||
| device | file | link |
|
||||
|---|---|---|
|
||||
| 64-bit (`aarch64`) | `harbour-thinq-0.2.5-1.aarch64.rpm` (96 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 |
|
||||
| 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.3.0-1.armv7hl.rpm` (96 KB) | https://nextcloud.hackatoniclife.com/s/MPHaQLmfLSrZkMR |
|
||||
|
||||
Checksums, if you like to verify downloads:
|
||||
|
||||
```
|
||||
37ed080a896add770bdab40e9a8e616e1818966cdca120cb783168dc65349aed harbour-thinq-0.2.5-1.aarch64.rpm
|
||||
8f3e02a663903eb34f5c2acf92472c2012b140d3f28fdf6aca544748cb2932f2 harbour-thinq-0.2.5-1.armv7hl.rpm
|
||||
c8a4ecdf2f4fbe59f5948162a7fa82bac6bd315df6ea541b645eb5f3d6f9105f harbour-thinq-0.3.0-1.aarch64.rpm
|
||||
0ac2ed5be803e16c4f7c1a180c1a9d984462fb3b528027f7dced1010c578312a harbour-thinq-0.3.0-1.armv7hl.rpm
|
||||
```
|
||||
|
||||
**3. Install it** — either tap the downloaded file in Files and confirm, or from
|
||||
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),
|
||||
@@ -90,10 +90,12 @@ screen.
|
||||
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
|
||||
program is still chosen on the machine.
|
||||
* No hidden background service. Polling happens while the app is on screen
|
||||
(about every 45 seconds), with automatic back-off if LG reports too many
|
||||
requests. That is also why the end-of-wash notification needs the app to be
|
||||
open when the cycle ends — without a server in the middle there is no push.
|
||||
* No hidden background service. It checks LG once every 30 minutes, and only
|
||||
while the app is on screen; between one check and the next the time left is
|
||||
recalculated on the phone, so the countdown keeps moving without any network
|
||||
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
|
||||
|
||||
@@ -166,14 +168,14 @@ uname -m
|
||||
|
||||
| dispositivo | file | link |
|
||||
|---|---|---|
|
||||
| 64 bit (`aarch64`) | `harbour-thinq-0.2.5-1.aarch64.rpm` (96 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 |
|
||||
| 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.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
|
||||
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 è
|
||||
@@ -193,10 +195,12 @@ sullo stato.
|
||||
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,
|
||||
quindi il programma si sceglie ancora sulla macchina.
|
||||
* Nessun servizio nascosto in background. La lettura avviene mentre l'app è
|
||||
aperta (circa ogni 45 secondi), con attesa automatica se LG segnala troppe
|
||||
richieste. Per questo l'avviso di fine lavaggio richiede l'app aperta quando
|
||||
il ciclo finisce: senza un server in mezzo non c'è notifica spinta.
|
||||
* Nessun servizio nascosto in background. Il controllo avviene una volta ogni
|
||||
mezz'ora, e solo mentre l'app è aperta; fra un controllo e l'altro il tempo
|
||||
rimanente viene ricalcolato sul telefono, così il conto alla rovescia scende
|
||||
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
|
||||
|
||||
|
||||
@@ -184,6 +184,18 @@ static void testItalian(const QString &catalog)
|
||||
"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[])
|
||||
{
|
||||
QCoreApplication app(argc, argv);
|
||||
@@ -193,6 +205,7 @@ int main(int argc, char *argv[])
|
||||
testCommands();
|
||||
testCloud();
|
||||
testDurations();
|
||||
testRemainEstimate();
|
||||
testItalian(catalog);
|
||||
|
||||
qInfo().noquote() << QString("\n%1 verifiche, %2 fallite").arg(checks).arg(failures);
|
||||
|
||||
Reference in new issue
Block a user