diff --git a/src/UnitHelper.jsx b/src/UnitHelper.jsx index 9a6f106..53dfef3 100644 --- a/src/UnitHelper.jsx +++ b/src/UnitHelper.jsx @@ -424,6 +424,22 @@ export function getAlertRange(type) { return { max: 0, min: -105 } case "offline": return { max: +Infinity, min: 120 } + case "co2": + return { max: 2500, min: 350 } + case "voc": + return { max: 500, min: 0 } + case "pm10": + return { max: 250, min: 0 } + case "pm25": + return { max: 250, min: 0 } + case "pm40": + return { max: 250, min: 0 } + case "pm100": + return { max: 250, min: 0 } + case "luminosity": + return { max: 10000, min: 0 } + case "sound": + return { max: 127, min: 0 } default: return { max: 100, min: 0 } } diff --git a/src/components/AlertItem.jsx b/src/components/AlertItem.jsx index 4dfe154..f9f155d 100644 --- a/src/components/AlertItem.jsx +++ b/src/components/AlertItem.jsx @@ -41,7 +41,7 @@ class AlertItem extends Component { if (max === +Infinity) max = 900 return addVariablesInString(this.props.t("alert_offline_description"), [max / 60]); } - var uh = getUnitHelper(type) + var uh = getUnitHelper(this.props.dataKey) if (type !== "humidity") { min = uh.value(min) max = uh.value(max) @@ -111,7 +111,7 @@ class AlertItem extends Component { getMinMaxArr() { var alert = this.state.alert; if (!alert) return null; - var uh = getUnitHelper(this.props.type.toLowerCase()) + var uh = getUnitHelper(this.props.dataKey) if (this.props.type.toLowerCase() === "humidity") return [alert.min, alert.max] let val = [uh.value(alert.min), uh.value(alert.max)] @@ -126,7 +126,7 @@ class AlertItem extends Component { var alert = this.state.alert; var type = this.props.type.toLowerCase(); var t = this.props.t - var uh = getUnitHelper(type) + var uh = getUnitHelper(this.props.dataKey) var enabled = alert && alert.enabled; var validRange = getAlertRange(type) if (type === "temperature" || type === "pressure") { diff --git a/src/states/Sensor.jsx b/src/states/Sensor.jsx index 9c4b7dd..6e8928c 100644 --- a/src/states/Sensor.jsx +++ b/src/states/Sensor.jsx @@ -715,9 +715,20 @@ class Sensor extends Component { return
{parts[0]}{t("cloud_ruuvi_link")}{parts[1]}
})()} } - {["temperature", "humidity", "pressure", "signal", "movement", "offline"].map(x => { + {["temperature", "humidity", "pressure", "signal", "movement", "offline", "co2", "voc", "pm10", "pm25", "pm40", "pm100", "luminosity", "sound"].map(x => { if (!x) return null - let dataKey = x === "movement" ? "movementCounter" : x === "signal" ? "rssi" : x; + const dataKeyMapping = { + "movement": "movementCounter", + "signal": "rssi", + "pm10": "pm1p0", + "pm25": "pm2p5", + "pm40": "pm4p0", + "pm100": "pm10p0", + "luminosity": "illuminance", + "sound": "soundLevelAvg" + }; + + const dataKey = dataKeyMapping[x] || x; let latestValue = this.getLatestReading()[dataKey] if (latestValue === undefined && x !== "offline") return null; var alert = this.getAlert(x) @@ -729,7 +740,7 @@ class Sensor extends Component { showDelay={sensorSubscription === "Business Starter"} detailedTitle={detailedTitle} detailedText={detailedText} detailedSubText={detailedSubText} - type={x} onChange={(a, prevEnabled) => this.updateAlert(a, prevEnabled)} /> + type={x} dataKey={dataKey} onChange={(a, prevEnabled) => this.updateAlert(a, prevEnabled)} /> })}