import QtQuick 2.2 import Sailfish.Silica 1.0 import "../components" // Comandi secondari: quelli che non stanno nella home. In cima lo stato // attuale, cosi' non si preme alla cieca. Page { id: page allowedOrientations: Orientation.All property string notice: "" property bool noticeIsError: false function raw(key) { return api.summary[key] } function flag(key) { return page.raw(key) ? qsTr("sì") : qsTr("no") } function stato(key) { return api.modeLabel(page.raw(key)) } function showNotice(msg, isError) { page.notice = msg page.noticeIsError = isError === true noticeTimer.restart() } Timer { id: noticeTimer interval: 4000 onTriggered: page.notice = "" } Connections { target: api onErrorOccurred: page.showNotice(message, true) onCommandFinished: page.showNotice(message, !ok) } SilicaFlickable { anchors.fill: parent contentHeight: col.height + Theme.paddingLarge Column { id: col width: parent.width spacing: Theme.paddingSmall PageHeader { title: qsTr("Altri comandi") } Label { visible: page.notice.length > 0 x: Theme.horizontalPageMargin width: parent.width - 2 * Theme.horizontalPageMargin text: page.notice color: page.noticeIsError ? Theme.errorColor : Theme.highlightColor font.pixelSize: Theme.fontSizeSmall wrapMode: Text.Wrap } // ---- stato attuale -------------------------------------------- // SectionHeader { text: qsTr("Stato attuale") } InfoRow { label: qsTr("Assenza"); value: page.flag("away_mode") } InfoRow { label: qsTr("Night mode"); value: page.flag("night_mode") } InfoRow { label: qsTr("Riscaldamento forzato"); value: page.flag("force_heating") } InfoRow { label: qsTr("Acqua calda attiva"); value: page.flag("hot_water_heating") } InfoRow { label: qsTr("Pompa"); value: page.stato("pump_active_state") } InfoRow { label: qsTr("Modalità consentite"); value: page.stato("configured_modes") } // ---- assenza --------------------------------------------------- // SectionHeader { text: qsTr("Assenza") } ActionButton { text: qsTr("Attiva assenza") onTriggered: api.sendCommand("away_mode_on") } ActionButton { text: qsTr("Disattiva assenza") onTriggered: api.sendCommand("away_mode_off") } // ---- rumore ---------------------------------------------------- // SectionHeader { text: qsTr("Rumore") } ActionButton { text: qsTr("Night mode per un'ora") onTriggered: api.sendCommand("night_mode_1h") } // ---- riscaldamento --------------------------------------------- // SectionHeader { text: qsTr("Riscaldamento") } ActionButton { text: qsTr("Forza riscaldamento") confirmText: qsTr("Avvio del riscaldamento forzato") onTriggered: api.sendCommand("force_heating_on") } ActionButton { text: qsTr("Ferma riscaldamento forzato") onTriggered: api.sendCommand("force_heating_off") } ActionButton { text: qsTr("Abilita funzione riscaldamento") onTriggered: api.sendCommand("heating_on") } ActionButton { text: qsTr("Disabilita funzione riscaldamento") confirmText: qsTr("Il riscaldamento verrà disabilitato") onTriggered: api.sendCommand("heating_off") } // ---- acqua calda ----------------------------------------------- // SectionHeader { text: qsTr("Acqua calda sanitaria") } ActionButton { text: qsTr("Ciclo antilegionella") confirmText: qsTr("Avvio del ciclo antilegionella: richiede tempo") onTriggered: api.sendCommand("legionella_cycle") } ActionButton { text: qsTr("Abilita riscaldamento ACS") onTriggered: api.sendCommand("hot_water_heating_on") } ActionButton { text: qsTr("Disabilita riscaldamento ACS") confirmText: qsTr("L'acqua calda smetterà di essere riscaldata") onTriggered: api.sendCommand("hot_water_heating_off") } // ---- diagnostica ----------------------------------------------- // SectionHeader { text: qsTr("Diagnostica") } ActionButton { text: qsTr("Verifica impianto") onTriggered: api.sendCommand("ping") } BusyIndicator { visible: api.busy anchors.horizontalCenter: parent.horizontalCenter size: BusyIndicatorSize.Small running: true } Label { x: Theme.horizontalPageMargin width: parent.width - 2 * Theme.horizontalPageMargin text: qsTr("I comandi passano dal bridge e possono richiedere qualche secondo. Dopo l'invio lo stato si aggiorna da solo.") color: Theme.secondaryColor font.pixelSize: Theme.fontSizeExtraSmall wrapMode: Text.Wrap } } } Component.onCompleted: { if (api.configured) api.refresh() } }