0.7.5: la Home manda le sue misure al bridge
Dopo tre diagnosi dedotte e tre volte sbagliate, le coordinate arrivano dal telefono: il timer 'misura' le manda a /layout, il bridge le scrive nel suo registro. Nel QML arrivano versione, schermo, contenuto e y/h/testo di ogni riga.
This commit is contained in:
+12
-1
@@ -763,7 +763,18 @@ class Handler(BaseHTTPRequestHandler):
|
|||||||
def do_POST(self):
|
def do_POST(self):
|
||||||
if not self._auth_ok():
|
if not self._auth_ok():
|
||||||
return self._send(401, {"ok": False, "error": "token mancante o errato"})
|
return self._send(401, {"ok": False, "error": "token mancante o errato"})
|
||||||
if self.path.split("?")[0] != "/command":
|
path = self.path.split("?")[0]
|
||||||
|
# Le misure della Home che l'app manda da sola appena si apre: servono a
|
||||||
|
# correggere la disposizione senza dipendere da uno screenshot letto a
|
||||||
|
# occhio. Finiscono nel registro del bridge come "[bridge] layout {...}".
|
||||||
|
if path == "/layout":
|
||||||
|
try:
|
||||||
|
body = self._body()
|
||||||
|
except Exception as exc:
|
||||||
|
return self._send(400, {"ok": False, "error": f"richiesta non valida: {exc}"})
|
||||||
|
print("[bridge] layout " + json.dumps(body, default=str), file=sys.stderr)
|
||||||
|
return self._send(200, {"ok": True})
|
||||||
|
if path != "/command":
|
||||||
return self._send(404, {"ok": False, "error": "rotta sconosciuta"})
|
return self._send(404, {"ok": False, "error": "rotta sconosciuta"})
|
||||||
try:
|
try:
|
||||||
body = self._body()
|
body = self._body()
|
||||||
|
|||||||
+22
-1
@@ -500,7 +500,28 @@ riga di contorno cade a y=240, che sta dentro i tasti (176..286): passava sopra,
|
|||||||
come diceva Carlo. Con la scatola a 152 px cade a y=336, sotto: nessuna
|
come diceva Carlo. Con la scatola a 152 px cade a y=336, sotto: nessuna
|
||||||
sovrapposizione. La correzione era giusta; mancava l'app aggiornata.
|
sovrapposizione. La correzione era giusta; mancava l'app aggiornata.
|
||||||
|
|
||||||
## 16. Conseguenze dell'uso reale (0.7.0)
|
## 16. Le misure della Home al bridge — v0.7.5
|
||||||
|
|
||||||
|
Carlo: *"È la 0.7.4 ma il problema rimane"*. Fino a qui avevo **dedotto** la
|
||||||
|
disposizione: dal vero `Button.qml`, da uno screenshot letto a occhio, da una
|
||||||
|
replica della colonna che mi ero costruito io. Tutte e tre le volte la deduzione
|
||||||
|
ha retto in teoria e ha sbagliato sui fatti, e ogni giro costava un RPM, una
|
||||||
|
copia sul telefono e una delusione.
|
||||||
|
|
||||||
|
- `MainPage.qml`: il timer `misura` (gia' presente dalla 0.7.1) non si limita piu'
|
||||||
|
a scrivere nel registro del telefono — che nessuno puo' leggere — ma manda le
|
||||||
|
stesse misure al bridge con `api.reportLayout()`: versione, altezza dello
|
||||||
|
schermo, altezza del contenuto e `y`/`h`/testo di **ogni** riga della Home;
|
||||||
|
- `ApiClient::reportLayout()`: un POST a `/layout`, senza attendere risposta;
|
||||||
|
- `aira_bridge.py`: la rotta `/layout` (protetta da token come le altre) scrive
|
||||||
|
il corpo nel proprio registro: `[bridge] layout {...}`.
|
||||||
|
|
||||||
|
Così la diagnosi smette di passare da un essere umano: Carlo apre l'app, le
|
||||||
|
coordinate arrivano nel registro del bridge, e l'agente le legge. Verificato
|
||||||
|
prima di consegnarlo: POST con token → 200 e riga nel registro, senza token →
|
||||||
|
401.
|
||||||
|
|
||||||
|
## 17. Conseguenze dell'uso reale (0.7.0)
|
||||||
|
|
||||||
Deciso con l'uso, non in anticipo:
|
Deciso con l'uso, non in anticipo:
|
||||||
|
|
||||||
|
|||||||
@@ -388,6 +388,7 @@ Page {
|
|||||||
// Ogni riga della Home con la sua posizione: se una riga finisce
|
// Ogni riga della Home con la sua posizione: se una riga finisce
|
||||||
// addosso a un'altra, qui si legge quale e di quanto. E' la riga da
|
// addosso a un'altra, qui si legge quale e di quanto. E' la riga da
|
||||||
// mandare al primo avvio se la disposizione non torna.
|
// mandare al primo avvio se la disposizione non torna.
|
||||||
|
var righe = []
|
||||||
for (var i = 0; i < col.children.length; ++i) {
|
for (var i = 0; i < col.children.length; ++i) {
|
||||||
var r = col.children[i]
|
var r = col.children[i]
|
||||||
if (r.height === undefined)
|
if (r.height === undefined)
|
||||||
@@ -395,7 +396,23 @@ Page {
|
|||||||
console.log("harbour-aira riga", i, "y", Math.round(r.y),
|
console.log("harbour-aira riga", i, "y", Math.round(r.y),
|
||||||
"h", Math.round(r.height),
|
"h", Math.round(r.height),
|
||||||
r.text !== undefined ? JSON.stringify(r.text) : "")
|
r.text !== undefined ? JSON.stringify(r.text) : "")
|
||||||
|
righe.push({
|
||||||
|
"i": i,
|
||||||
|
"y": Math.round(r.y),
|
||||||
|
"h": Math.round(r.height),
|
||||||
|
"t": r.text !== undefined ? String(r.text) : ""
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
// Le stesse misure vanno anche al bridge, che le scrive nel
|
||||||
|
// registro: cosi' l'agente le legge da li' invece di chiedere il
|
||||||
|
// terminale o di decifrare uno screenshot.
|
||||||
|
if (api.configured)
|
||||||
|
api.reportLayout({
|
||||||
|
"versione": appVersion,
|
||||||
|
"schermo": Math.round(height),
|
||||||
|
"contenuto": Math.round(flick.contentHeight),
|
||||||
|
"righe": righe
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
Name: harbour-aira
|
Name: harbour-aira
|
||||||
Summary: Control your Aira heat pump through a local bridge
|
Summary: Control your Aira heat pump through a local bridge
|
||||||
Version: 0.7.4
|
Version: 0.7.5
|
||||||
Release: 1
|
Release: 1
|
||||||
Group: Qt/Qt
|
Group: Qt/Qt
|
||||||
License: MIT
|
License: MIT
|
||||||
@@ -37,6 +37,9 @@ Address and token of the bridge live in the app settings (AppConfigLocation);
|
|||||||
no personal data is stored in the binary.
|
no personal data is stored in the binary.
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Sun Oct 11 2026 Carlo <carlo@carlobaratto.it> - 0.7.5-1
|
||||||
|
- La Home manda le sue misure al bridge (rotta /layout): cosi' la disposizione
|
||||||
|
si corregge guardando i numeri veri del telefono, non deducendoli.
|
||||||
* Sun Oct 11 2026 Carlo <carlo@carlobaratto.it> - 0.7.4-1
|
* Sun Oct 11 2026 Carlo <carlo@carlobaratto.it> - 0.7.4-1
|
||||||
- Impostazioni: la versione dell'app scritta a schermo. Servita subito: un
|
- Impostazioni: la versione dell'app scritta a schermo. Servita subito: un
|
||||||
difetto della disposizione era l'app vecchia installata, non un bug.
|
difetto della disposizione era l'app vecchia installata, non un bug.
|
||||||
|
|||||||
@@ -304,6 +304,17 @@ void ApiClient::refreshStats()
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Le misure della Home vanno al bridge, che le scrive nel suo registro: cosi'
|
||||||
|
// per correggere la disposizione non servono ne' terminale sul telefono ne'
|
||||||
|
// screenshot da interpretare a occhio.
|
||||||
|
void ApiClient::reportLayout(const QVariantMap &info)
|
||||||
|
{
|
||||||
|
QNetworkReply *reply = send("POST", QStringLiteral("/layout"), info, 5);
|
||||||
|
if (!reply)
|
||||||
|
return;
|
||||||
|
connect(reply, &QNetworkReply::finished, reply, &QObject::deleteLater);
|
||||||
|
}
|
||||||
|
|
||||||
void ApiClient::sendCommand(const QString &id, const QVariant &value, const QVariantMap &extra)
|
void ApiClient::sendCommand(const QString &id, const QVariant &value, const QVariantMap &extra)
|
||||||
{
|
{
|
||||||
if (!configured()) {
|
if (!configured()) {
|
||||||
|
|||||||
@@ -82,6 +82,7 @@ public:
|
|||||||
|
|
||||||
// Formattazione per la UI: unica fonte di verita' in C++ (testata in
|
// Formattazione per la UI: unica fonte di verita' in C++ (testata in
|
||||||
// tests/core_test.cpp), niente duplicazione di logica nel QML.
|
// tests/core_test.cpp), niente duplicazione di logica nel QML.
|
||||||
|
Q_INVOKABLE void reportLayout(const QVariantMap &info);
|
||||||
Q_INVOKABLE QString modeLabel(const QString &operatingStatus) const;
|
Q_INVOKABLE QString modeLabel(const QString &operatingStatus) const;
|
||||||
Q_INVOKABLE QString formatValue(const QVariant &value) const;
|
Q_INVOKABLE QString formatValue(const QVariant &value) const;
|
||||||
Q_INVOKABLE QString formatNumber(const QVariant &value, int decimals) const;
|
Q_INVOKABLE QString formatNumber(const QVariant &value, int decimals) const;
|
||||||
|
|||||||
+2
-2
@@ -21,7 +21,7 @@ Q_DECL_EXPORT int main(int argc, char *argv[])
|
|||||||
|
|
||||||
app->setOrganizationName(QStringLiteral("harbour"));
|
app->setOrganizationName(QStringLiteral("harbour"));
|
||||||
app->setApplicationName(QStringLiteral("aira"));
|
app->setApplicationName(QStringLiteral("aira"));
|
||||||
app->setApplicationVersion(QStringLiteral("0.7.4"));
|
app->setApplicationVersion(QStringLiteral("0.7.5"));
|
||||||
|
|
||||||
Settings settings;
|
Settings settings;
|
||||||
ApiClient api(&settings);
|
ApiClient api(&settings);
|
||||||
@@ -36,7 +36,7 @@ Q_DECL_EXPORT int main(int argc, char *argv[])
|
|||||||
|
|
||||||
// Prima riga del log: dice subito se il device sta girando la build nuova
|
// Prima riga del log: dice subito se il device sta girando la build nuova
|
||||||
// o una stale (trappola nota del build engine).
|
// o una stale (trappola nota del build engine).
|
||||||
qDebug() << "harbour-aira v0.7.4 build" << __DATE__ << __TIME__;
|
qDebug() << "harbour-aira v0.7.5 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);
|
||||||
|
|||||||
@@ -1038,5 +1038,10 @@
|
|||||||
<source>Save and test</source>
|
<source>Save and test</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../qml/pages/SettingsPage.qml" line="156"/>
|
||||||
|
<source>Version %1</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
</TS>
|
</TS>
|
||||||
|
|||||||
Reference in New Issue
Block a user