feature: add additional sensor support in temperature panel (bme280...)
Signed-off-by: Stefan Dej <meteyou@gmail.com>
This commit is contained in:
parent
4b678468ab
commit
f958027671
@ -75,7 +75,10 @@
|
||||
</v-col>
|
||||
<v-col class="py-2 font-weight-bold"><span style="cursor: pointer;" @click="openHeater(heater)">{{ convertName(heater.name) }}</span></v-col>
|
||||
<v-col class="py-2 text-center d-none d-sm-block"><small>{{ heater.target > 0 ? (heater.power !== null ? (heater.power > 0 ? (heater.power * 100).toFixed(0)+'%' : "0%") : "active") : "off" }}</small></v-col>
|
||||
<v-col class="py-2 text-center">{{ heater.temperature ? heater.temperature.toFixed(1) : 0 }}°C</v-col>
|
||||
<v-col class="py-2 text-center">
|
||||
<span class="d-block">{{ heater.temperature ? heater.temperature.toFixed(1) : 0 }}°C</span>
|
||||
<span v-for="(values, key) of heater.additionValues" v-bind:key="key" class="d-block">{{ values.value.toFixed(1) }} {{ values.unit }}</span>
|
||||
</v-col>
|
||||
<v-col class="text-center py-2 pr-8 vertical_align_center">
|
||||
<toolInput :name="heater.name" :target="heater.target" :min_temp="heater.min_temp" :max_temp="heater.max_temp" :items="heater.presets" command="SET_HEATER_TEMPERATURE" attribute-name="HEATER" ></toolInput>
|
||||
</v-col>
|
||||
@ -89,7 +92,10 @@
|
||||
</v-col>
|
||||
<v-col class="py-2 font-weight-bold"><span style="cursor: pointer;" @click="openHeater(fan)">{{ convertName(fan.name) }}</span></v-col>
|
||||
<v-col class="py-2 text-center d-none d-sm-block"><small>{{ fan.target > 0 && fan.speed > 0 ? (fan.speed * 100).toFixed(0)+"%" : (fan.target > 0 ? "standby" : "off") }}</small></v-col>
|
||||
<v-col class="py-2 text-center">{{ fan.temperature ? fan.temperature.toFixed(1) : 0}}°C</v-col>
|
||||
<v-col class="py-2 text-center">
|
||||
<span class="d-block">{{ fan.temperature ? fan.temperature.toFixed(1) : 0}}°C</span>
|
||||
<span v-for="(values, key) of fan.additionValues" v-bind:key="key" class="d-block">{{ values.value.toFixed(1) }} {{ values.unit }}</span>
|
||||
</v-col>
|
||||
<v-col class="text-center py-2 pr-8 pr-0 vertical_align_center">
|
||||
<toolInput :name="fan.name" :target="fan.target" command="SET_TEMPERATURE_FAN_TARGET" attribute-name="temperature_fan" :items="fan.presets" ></toolInput>
|
||||
</v-col>
|
||||
@ -101,20 +107,23 @@
|
||||
<v-col class="flex-grow-0 py-2 pl-8 pr-0 colHeaterIcons">
|
||||
<v-icon color="grey darken-2" :title="'min: '+sensor.min_temp+'° / max: '+sensor.max_temp+'°'">{{ sensor.icon }}</v-icon>
|
||||
</v-col>
|
||||
<v-col class="py-2 font-weight-bold"><span style="cursor: pointer;" @click="openHeater(sensor)">{{ convertName(sensor.name) }}</span></v-col>
|
||||
<v-col class="py-2 font-weight-bold">
|
||||
<span style="cursor: pointer;" @click="openHeater(sensor)">{{ convertName(sensor.name) }}</span>
|
||||
</v-col>
|
||||
<v-col class="py-2 d-none d-sm-block"><span> </span></v-col>
|
||||
<v-col class="py-2 text-center">
|
||||
<v-tooltip top>
|
||||
<template v-slot:activator="{ on, attrs }">
|
||||
<span
|
||||
style="cursor: default;"
|
||||
class=" px-0"
|
||||
class="d-block px-0"
|
||||
v-bind="attrs"
|
||||
v-on="on"
|
||||
>{{ sensor.temperature ? sensor.temperature.toFixed(1) : 0 }}°C</span>
|
||||
</template>
|
||||
<span>min: {{ sensor.measured_min_temp ? sensor.measured_min_temp.toFixed(1) : 0}}°<br />max: {{ sensor.measured_max_temp ? sensor.measured_max_temp.toFixed(1) : 0 }}°</span>
|
||||
</v-tooltip>
|
||||
<span v-for="(values, key) of sensor.additionValues" v-bind:key="key" class="d-block">{{ values.value.toFixed(1) }} {{ values.unit }}</span>
|
||||
</v-col>
|
||||
<v-col class="text-center py-2 pr-8 vertical_align_center"><span> </span></v-col>
|
||||
</v-row>
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { caseInsensitiveNameSort } from '@/plugins/helpers'
|
||||
import { additionalSensors } from '@/store/variables'
|
||||
|
||||
export default {
|
||||
|
||||
@ -77,6 +78,7 @@ export default {
|
||||
color: color,
|
||||
target: value.target,
|
||||
temperature: value.temperature,
|
||||
additionValues: getters.getAdditionSensors(nameSplit[1]),
|
||||
power: 'power' in value ? value.power : null,
|
||||
presets: rootGetters["gui/getPresetsFromHeater"]({ name: key }),
|
||||
chartColor: getters["tempHistory/getDatasetColor"](name),
|
||||
@ -104,6 +106,7 @@ export default {
|
||||
name: nameSplit[1],
|
||||
target: value.target,
|
||||
temperature: value.temperature,
|
||||
additionValues: getters.getAdditionSensors(nameSplit[1]),
|
||||
speed: value.speed,
|
||||
presets: rootGetters["gui/getPresetsFromHeater"]({ name: key }),
|
||||
chartColor: getters["tempHistory/getDatasetColor"](nameSplit[1]),
|
||||
@ -132,9 +135,12 @@ export default {
|
||||
if (value.temperature <= min_temp + split) icon = "mdi-thermometer-low"
|
||||
if (value.temperature >= max_temp - split) icon = "mdi-thermometer-high"
|
||||
|
||||
|
||||
|
||||
sensors.push({
|
||||
name: nameSplit[1],
|
||||
temperature: value.temperature,
|
||||
additionValues: getters.getAdditionSensors(nameSplit[1]),
|
||||
icon: icon,
|
||||
min_temp: min_temp,
|
||||
max_temp: max_temp,
|
||||
@ -277,6 +283,38 @@ export default {
|
||||
})
|
||||
},
|
||||
|
||||
getAdditionSensors: state => (name) => {
|
||||
let additionValues = {}
|
||||
additionalSensors.forEach(sensorName => {
|
||||
if (sensorName+" "+name in state) {
|
||||
Object.keys(state[sensorName+" "+name]).forEach(key => {
|
||||
if (key !== "temperature") {
|
||||
let tmp = {}
|
||||
tmp[key] = {}
|
||||
tmp[key]['value'] = state[sensorName+" "+name][key]
|
||||
|
||||
switch(key) {
|
||||
case 'pressure':
|
||||
tmp[key]['unit'] = "hPa"
|
||||
break
|
||||
|
||||
case 'humidity':
|
||||
tmp[key]['unit'] = "%"
|
||||
break
|
||||
|
||||
default:
|
||||
tmp[key]['unit'] = ""
|
||||
}
|
||||
|
||||
additionValues = Object.assign(additionValues, tmp)
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
return additionValues
|
||||
},
|
||||
|
||||
getAllMacros: state => {
|
||||
let array = []
|
||||
|
||||
|
@ -16,4 +16,9 @@ export const datasetTypes = [
|
||||
"temperature",
|
||||
"target",
|
||||
"power",
|
||||
]
|
||||
|
||||
export const additionalSensors = [
|
||||
"bme280",
|
||||
"htu21d",
|
||||
]
|
Loading…
x
Reference in New Issue
Block a user