Merge PR #338: Fix LogViewer and Weather view unit conversion
This commit is contained in:
commit
afbdba979b
@ -248,5 +248,6 @@ QVariant Types::toUiValue(const QVariant &value, Types::Unit unit) const
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
qDebug() << "**********" << value;
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -32,31 +32,32 @@ import QtQuick 2.5
|
|||||||
import QtQuick.Layouts 1.1
|
import QtQuick.Layouts 1.1
|
||||||
import QtQuick.Controls 2.1
|
import QtQuick.Controls 2.1
|
||||||
import "../components"
|
import "../components"
|
||||||
|
import Nymea 1.0
|
||||||
|
|
||||||
CustomViewBase {
|
CustomViewBase {
|
||||||
id: root
|
id: root
|
||||||
height: grid.implicitHeight + app.margins * 2
|
height: grid.implicitHeight + app.margins * 2
|
||||||
|
|
||||||
readonly property var weatherConditionStateType: deviceClass.stateTypes ? deviceClass.stateTypes.findByName("weatherCondition") : null
|
readonly property StateType weatherConditionStateType: deviceClass.stateTypes ? deviceClass.stateTypes.findByName("weatherCondition") : null
|
||||||
readonly property var weatherConditionState: weatherConditionStateType && device.states ? device.states.getState(weatherConditionStateType.id) : null
|
readonly property State weatherConditionState: weatherConditionStateType && device.states ? device.states.getState(weatherConditionStateType.id) : null
|
||||||
|
|
||||||
readonly property var weatherDescriptionStateType: deviceClass.stateTypes ? deviceClass.stateTypes.findByName("weatherDescription") : null
|
readonly property StateType weatherDescriptionStateType: deviceClass.stateTypes ? deviceClass.stateTypes.findByName("weatherDescription") : null
|
||||||
readonly property var weatherDescriptionState: weatherDescriptionStateType && device.states ? device.states.getState(weatherDescriptionStateType.id) : null
|
readonly property State weatherDescriptionState: weatherDescriptionStateType && device.states ? device.states.getState(weatherDescriptionStateType.id) : null
|
||||||
|
|
||||||
readonly property var temperatureStateType: deviceClass.stateTypes ? deviceClass.stateTypes.findByName("temperature") : null
|
readonly property StateType temperatureStateType: deviceClass.stateTypes ? deviceClass.stateTypes.findByName("temperature") : null
|
||||||
readonly property var temperatureState: temperatureStateType && device.states ? device.states.getState(temperatureStateType.id) : null
|
readonly property State temperatureState: temperatureStateType && device.states ? device.states.getState(temperatureStateType.id) : null
|
||||||
|
|
||||||
readonly property var humidityStateType: deviceClass.stateTypes ? deviceClass.stateTypes.findByName("humidity") : null
|
readonly property StateType humidityStateType: deviceClass.stateTypes ? deviceClass.stateTypes.findByName("humidity") : null
|
||||||
readonly property var humidityState: humidityStateType && device.states ? device.states.getState(humidityStateType.id) : null
|
readonly property State humidityState: humidityStateType && device.states ? device.states.getState(humidityStateType.id) : null
|
||||||
|
|
||||||
readonly property var pressureStateType: deviceClass.stateTypes ? deviceClass.stateTypes.findByName("pressure") : null
|
readonly property StateType pressureStateType: deviceClass.stateTypes ? deviceClass.stateTypes.findByName("pressure") : null
|
||||||
readonly property var pressureState: pressureStateType && device.states ? device.states.getState(pressureStateType.id) : null
|
readonly property State pressureState: pressureStateType && device.states ? device.states.getState(pressureStateType.id) : null
|
||||||
|
|
||||||
readonly property var windDirectionStateType: deviceClass.stateTypes ? deviceClass.stateTypes.findByName("windDirection") : null
|
readonly property StateType windDirectionStateType: deviceClass.stateTypes ? deviceClass.stateTypes.findByName("windDirection") : null
|
||||||
readonly property var windDirectionState: windDirectionStateType && device.states ? device.states.getState(windDirectionStateType.id) : null
|
readonly property State windDirectionState: windDirectionStateType && device.states ? device.states.getState(windDirectionStateType.id) : null
|
||||||
|
|
||||||
readonly property var windSpeedStateType: deviceClass.stateTypes ? deviceClass.stateTypes.findByName("windSpeed") : null
|
readonly property StateType windSpeedStateType: deviceClass.stateTypes ? deviceClass.stateTypes.findByName("windSpeed") : null
|
||||||
readonly property var windSpeedState: windSpeedStateType && device.states ? device.states.getState(windSpeedStateType.id) : null
|
readonly property State windSpeedState: windSpeedStateType && device.states ? device.states.getState(windSpeedStateType.id) : null
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
id: grid
|
id: grid
|
||||||
@ -80,7 +81,7 @@ CustomViewBase {
|
|||||||
color: app.interfaceToColor("temperaturesensor")
|
color: app.interfaceToColor("temperaturesensor")
|
||||||
}
|
}
|
||||||
Label {
|
Label {
|
||||||
text: (temperatureState ? Math.round(temperatureState.value * 10) / 10 : "N/A") + " °"
|
text: (temperatureState ? Math.round(Types.toUiValue(temperatureState.value, temperatureStateType.unit) * 10) / 10 : "N/A") + " °"
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
font.pixelSize: app.largeFont
|
font.pixelSize: app.largeFont
|
||||||
horizontalAlignment: Text.AlignHCenter
|
horizontalAlignment: Text.AlignHCenter
|
||||||
|
|||||||
@ -259,7 +259,7 @@ Page {
|
|||||||
|
|
||||||
return labelComponent
|
return labelComponent
|
||||||
}
|
}
|
||||||
Binding { target: valueLoader.item; property: "value"; value: Types.toUiValue(model.value, entryDelegate.stateType.unit) }
|
Binding { target: valueLoader.item; property: "value"; value: entryDelegate.stateType ? Types.toUiValue(model.value, entryDelegate.stateType.unit) : model.value }
|
||||||
Binding {
|
Binding {
|
||||||
target: entryDelegate.stateType && valueLoader.item.hasOwnProperty("unitString") ? valueLoader.item : null;
|
target: entryDelegate.stateType && valueLoader.item.hasOwnProperty("unitString") ? valueLoader.item : null;
|
||||||
property: "unitString"
|
property: "unitString"
|
||||||
|
|||||||
Reference in New Issue
Block a user