Files
harbour-aira/qml/pages/CommandsPage.qml
T
kaneda 85702880d5 0.6.0 blocco 2: Comandi impianto con interruttori, diagnostica in Impianto
- CommandsPage: 4 interruttori (TextSwitch) al posto di 8 pulsanti in coppie
  accendi/spegni, piu' 3 pulsanti per le azioni senza stato. Gli interruttori
  seguono il dato vero (automaticCheck: false), non anticipano l'impianto, e
  la sezione 'Stato attuale' non serve piu'.
- La pagina si chiama 'Comandi impianto'.
- PlantPage: frase estesa dello stato, diagnostica (verifica impianto) e le
  letture che non avevano posto (pompa, modi consentiti, manuale, sbrinamento,
  luci di firma).
- SettingsPage: 'Salva' e 'Prova connessione' diventano 'Salva e prova'.
- ApiClient: dopo un comando riuscito lo stato si rilegge da solo (prima non
  si aggiornava nulla: l'aggiornamento automatico non esisteva).
- NoticeBar anche su Dati, Impianto e Comandi; via i messaggi dentro il
  contenuto che scorre.
2026-10-10 09:48:41 +02:00

172 lines
6.1 KiB
QML

import QtQuick 2.2
import Sailfish.Silica 1.0
import "../components"
// Comandi impianto: i comandi che non stanno nella Home.
//
// Prima erano 12 pulsanti in quattro sezioni, otto dei quali in coppie
// accendi/spegni, con lo stato da leggere in sei righe piu' in alto. Ora ogni
// cosa che ha uno stato e' un interruttore: lo stato si vede e si cambia in un
// tocco solo (docs/UX-STUDIO.md).
//
// Gli interruttori NON anticipano l'impianto: `checked` segue l'ultimo dato
// vero (automaticCheck: false) e al tocco parte il comando. Se il comando non
// riesce, l'interruttore non si muove; se riesce, lo stato arriva da solo
// (ApiClient rilegge il riassunto due secondi dopo).
Page {
id: page
allowedOrientations: Orientation.All
function raw(key) {
return api.summary[key]
}
// La funzione riscaldamento e' abilitata quando i modi configurati della
// pompa la comprendono ("PUMP_MODE_STATE_HEATING").
function heatingEnabled() {
return String(page.raw("configured_modes") || "").indexOf("HEATING") >= 0
}
Component.onCompleted: {
if (api.configured)
api.refresh()
}
// Fuori dai pulsanti/interruttori: dentro finirebbero nel loro contentItem.
RemorseItem { id: remorse }
SilicaFlickable {
anchors.fill: parent
contentHeight: col.height + Theme.paddingLarge
PullDownMenu {
MenuItem {
text: qsTr("Refresh")
onClicked: api.refresh()
}
MenuItem {
text: qsTr("Data")
onClicked: pageStack.push(Qt.resolvedUrl("DataPage.qml"))
}
MenuItem {
text: qsTr("Plant")
onClicked: pageStack.push(Qt.resolvedUrl("PlantPage.qml"))
}
MenuItem {
text: qsTr("Settings")
onClicked: pageStack.push(Qt.resolvedUrl("SettingsPage.qml"))
}
}
Column {
id: col
width: parent.width
spacing: Theme.paddingSmall
PageHeader { title: qsTr("Plant commands") }
// ---- modalita' -------------------------------------------------- //
SectionHeader { text: qsTr("Modes") }
TextSwitch {
id: awaySwitch
text: qsTr("Away mode")
description: qsTr("Lowers the house and stops the hot water")
automaticCheck: false
checked: page.raw("away_mode") === true
onClicked: {
if (checked)
api.sendCommand("away_mode_off")
else
api.sendCommand("away_mode_on")
}
}
TextSwitch {
text: qsTr("Forced heating")
description: qsTr("Heats at full power until you stop it")
automaticCheck: false
checked: page.raw("force_heating") === true
onClicked: {
if (checked)
api.sendCommand("force_heating_off")
else
api.sendCommand("force_heating_on")
}
}
TextSwitch {
id: heatingSwitch
text: qsTr("Heating")
description: qsTr("The heating can turn on")
automaticCheck: false
checked: page.heatingEnabled()
onClicked: {
// Spegnere il riscaldamento ha conseguenze: si conferma.
if (checked)
remorse.execute(heatingSwitch, qsTr("Heating will be disabled"),
function() { api.sendCommand("heating_off") })
else
api.sendCommand("heating_on")
}
}
// ---- acqua calda ------------------------------------------------ //
SectionHeader { text: qsTr("Domestic hot water") }
TextSwitch {
id: waterSwitch
text: qsTr("Hot water active")
description: qsTr("The heat pump keeps the water in temperature")
automaticCheck: false
checked: page.raw("hot_water_heating") === true
onClicked: {
if (checked)
remorse.execute(waterSwitch,
qsTr("Domestic hot water will stop being heated"),
function() { api.sendCommand("hot_water_heating_off") })
else
api.sendCommand("hot_water_heating_on")
}
}
ActionButton {
text: qsTr("Legionella cycle")
confirmText: qsTr("Starting the legionella cycle: it takes a while")
onTriggered: api.sendCommand("legionella_cycle")
}
// ---- rumore ----------------------------------------------------- //
SectionHeader { text: qsTr("Noise") }
ActionButton {
text: qsTr("Night mode for one hour")
onTriggered: api.sendCommand("night_mode_1h")
}
Label {
x: Theme.horizontalPageMargin
width: parent.width - 2 * Theme.horizontalPageMargin
text: qsTr("The switches show the current state of the plant: the Status section is not needed any more.")
color: Theme.secondaryColor
font.pixelSize: Theme.fontSizeExtraSmall
wrapMode: Text.Wrap
}
Label {
x: Theme.horizontalPageMargin
width: parent.width - 2 * Theme.horizontalPageMargin
text: qsTr("Commands go through the bridge and may take a few seconds. The status refreshes by itself afterwards.")
color: Theme.secondaryColor
font.pixelSize: Theme.fontSizeExtraSmall
wrapMode: Text.Wrap
}
Item { width: 1; height: Theme.paddingMedium }
}
}
NoticeBar { }
}