Only show unit of measurement if we have it and if the state is not a string while managing sensors (#3685)

* Only show unit of measurement if we have it and if the state is not a string

* Remove parentheses
This commit is contained in:
Daniel Shokouhi 2023-07-20 18:44:37 -07:00 committed by GitHub
parent 7e12eaee3a
commit 8cc594e945
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View file

@ -312,7 +312,7 @@ fun SensorDetailTopPanel(
if (sensor.state.isBlank()) {
stringResource(commonR.string.enabled)
} else {
if (sensor.unitOfMeasurement.isNullOrBlank()) {
if (sensor.unitOfMeasurement.isNullOrBlank() || sensor.state.toDoubleOrNull() == null) {
sensor.state
} else {
"${sensor.state} ${sensor.unitOfMeasurement}"

View file

@ -100,7 +100,7 @@ fun SensorRow(
if (dbSensor.state.isBlank()) {
stringResource(commonR.string.enabled)
} else {
if (basicSensor.unitOfMeasurement.isNullOrBlank()) {
if (basicSensor.unitOfMeasurement.isNullOrBlank() || dbSensor.state.toDoubleOrNull() == null) {
dbSensor.state
} else {
"${dbSensor.state} ${basicSensor.unitOfMeasurement}"