diff --git a/src/components/panels/Temperature/TemperaturePanelListItemAdditionalSensor.vue b/src/components/panels/Temperature/TemperaturePanelListItemAdditionalSensor.vue index 40f1afd7e..fdceb7fd2 100644 --- a/src/components/panels/Temperature/TemperaturePanelListItemAdditionalSensor.vue +++ b/src/components/panels/Temperature/TemperaturePanelListItemAdditionalSensor.vue @@ -5,6 +5,7 @@ :key="keyName" :printer-object="printerObject" :object-name="objectName" + :sensor-type="sensorType" :key-name="keyName" /> @@ -30,5 +31,9 @@ export default class TemperaturePanelListItemAdditionalSensor extends Mixins(Bas return Object.keys(this.printerObject).filter((key) => key !== 'temperature') } + + get sensorType() { + return this.additionalObjectName.split(' ')[0] + } } diff --git a/src/components/panels/Temperature/TemperaturePanelListItemAdditionalSensorValue.vue b/src/components/panels/Temperature/TemperaturePanelListItemAdditionalSensorValue.vue index aadc033b1..1cf063c98 100644 --- a/src/components/panels/Temperature/TemperaturePanelListItemAdditionalSensorValue.vue +++ b/src/components/panels/Temperature/TemperaturePanelListItemAdditionalSensorValue.vue @@ -13,6 +13,7 @@ import BaseMixin from '@/components/mixins/base' export default class TemperaturePanelListItemAdditionalSensorValue extends Mixins(BaseMixin) { @Prop({ type: Object, required: true }) readonly printerObject!: { [key: string]: number } @Prop({ type: String, required: true }) readonly objectName!: string + @Prop({ type: String, required: true }) readonly sensorType!: string @Prop({ type: String, required: true }) readonly keyName!: string get value() { @@ -23,20 +24,35 @@ export default class TemperaturePanelListItemAdditionalSensorValue extends Mixin } get formatValue() { + const output = [] let value = this.value?.toFixed(1) if (this.value === null) value = '--' // get unit - let unit: string | null = null + let unitPrefix: string | null = null + let unitSuffix: string | null = null + + if (this.keyName === 'gas') { + switch (this.sensorType) { + case 'sgp40': + unitPrefix = 'VOC' + break + + case 'bme680': + unitPrefix = 'IAQ' + break + } + } + switch (this.keyName) { case 'pressure': - unit = 'hPa' + unitSuffix = 'hPa' break case 'humidity': - unit = '%' + unitSuffix = '%' break case 'current_z_adjust': - unit = 'mm' + unitSuffix = 'mm' break } @@ -47,11 +63,16 @@ export default class TemperaturePanelListItemAdditionalSensorValue extends Mixin // convert z_adjust value if it is smaller than 0.1 to μm if (Math.abs(this.value) < 0.1) { value = Math.round(this.value * 1000).toString() - unit = 'μm' + unitSuffix = 'μm' } } + if (this.keyName.startsWith('gas') || this.keyName === 'voc') value = this.value?.toFixed(0) + + if (unitPrefix) output.push(`${unitPrefix}:`) + output.push(value) + if (unitSuffix) output.push(unitSuffix) - return unit ? `${value} ${unit}` : value + return output.join(' ') } get guiSetting() {