import QtQuick 2.9 import QtQuick.Controls 2.2 import QtQuick.Layouts 1.3 import QtQuick.Controls.Material 2.2 import Nymea 1.0 import "../components" MainPageTile { id: root text: interfaceToString(model.name).toUpperCase() iconName: interfaceToIcon(model.name) iconColor: app.accentColor disconnected: devicesSubProxyConnectables.count > 0 batteryCritical: devicesSubProxyBattery.count > 0 backgroundImage: inlineControlLoader.item && inlineControlLoader.item.hasOwnProperty("backgroundImage") ? inlineControlLoader.item.backgroundImage : "" onClicked: { var page; switch (model.name) { case "heating": case "sensor": page = "SensorsDeviceListPage.qml" break; case "weather": page = "WeatherDeviceListPage.qml" break; case "light": page = "LightsDeviceListPage.qml" break; case "smartmeter": page ="SmartMeterDeviceListPage.qml"; break; case "garagegate": page = "GarageDeviceListPage.qml"; break; case "awning": case "extendedAwning": page = "AwningDeviceListPage.qml"; break; case "blind": case "extendedBlind": page = "ShutterDeviceListPage.qml"; break; case "shutter": case "extendedShutter": page = "ShutterDeviceListPage.qml"; break; case "powersocket": page = "PowerSocketsDeviceListPage.qml"; break; case "media": page = "MediaDeviceListPage.qml"; break; default: page = "GenericDeviceListPage.qml" } if (model.name === "uncategorized") { pageStack.push(Qt.resolvedUrl("../devicelistpages/" + page), {hiddenInterfaces: app.supportedInterfaces}) } else { print("= 0) { ret.push({ifaceName: supportedSensors.get(i).ifaceName, stateName: supportedSensors.get(i).stateName}) } } return ret; } property StateType shownStateType: shownSensors.length > currentSensor && currentSensor >= 0 ? deviceClass.stateTypes.findByName(shownSensors[currentSensor].stateName) : null function nextSensor() { var newSensorIndex = sensorsRoot.currentSensor + 1; if (newSensorIndex > sensorsRoot.shownSensors.length - 1) { var newDeviceIndex = (sensorsRoot.currentDevice + 1) % devicesProxy.count; newSensorIndex = 0; sensorsRoot.currentDevice = newDeviceIndex; } sensorsRoot.currentSensor = newSensorIndex; } onClicked: { nextSensorAnimation.start() timer.restart() } SequentialAnimation { id: nextSensorAnimation NumberAnimation { target: sensorsRoot; property: "opacity"; from: 1; to: 0; duration: 500 } ScriptAction { script: { nextSensor(); } } NumberAnimation { target: sensorsRoot; property: "opacity"; from: 0; to: 1; duration: 500 } } Timer { id: timer interval: 10000 repeat: true running: sensorsRoot.shownSensors.length > 1 || devicesProxy.count > 1 onTriggered: nextSensorAnimation.start() } RowLayout { anchors.fill: parent ColorIcon { Layout.preferredHeight: app.iconSize Layout.preferredWidth: app.iconSize name: sensorsRoot.currentSensor >= 0 && sensorsRoot.shownSensors.length > sensorsRoot.currentSensor ? app.interfaceToIcon(sensorsRoot.shownSensors[sensorsRoot.currentSensor].ifaceName) : "" color: sensorsRoot.currentSensor >= 0 && sensorsRoot.shownSensors.length > sensorsRoot.currentSensor ? app.interfaceToColor(sensorsRoot.shownSensors[sensorsRoot.currentSensor].ifaceName) : keyColor } ColumnLayout { Label { text: sensorsRoot.device.name font.pixelSize: app.smallFont Layout.fillWidth: true elide: Text.ElideRight } Label { text: sensorsRoot.shownStateType ? Math.round(sensorsRoot.device.states.getState(shownStateType.id).value * 100) / 100 + " " + sensorsRoot.shownStateType.unitString : "" // font.pixelSize: app.smallFont Layout.fillWidth: true visible: sensorsRoot.shownStateType && sensorsRoot.shownStateType.type.toLowerCase() !== "bool" elide: Text.ElideRight } Led { Layout.preferredHeight: app.iconSize * .5 Layout.preferredWidth: height state: sensorsRoot.shownStateType && sensorsRoot.device.states.getState(sensorsRoot.shownStateType.id).value === true ? "on" : "off" visible: sensorsRoot.shownStateType && sensorsRoot.shownStateType.type.toLowerCase() === "bool" } } } } } }