Skip to content

Commit

Permalink
Zigbee2mqtt: Add voc_index expose (#1963)
Browse files Browse the repository at this point in the history
  • Loading branch information
William-De71 authored Dec 8, 2023
1 parent 1956b16 commit b39e024
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,21 @@ const getAqiColor = value => {
return 'danger';
};

const getVocIndexColor = value => {
if (value < 150) {
return 'success';
} else if (value < 250) {
return 'warning';
} else if (value < 400) {
return 'orange';
}
return 'danger';
};

const BADGE_CATEGORIES = {
[DEVICE_FEATURE_CATEGORIES.CO2_SENSOR]: value => colorLowAsGreen(value, 600, 1200),
[DEVICE_FEATURE_CATEGORIES.VOC_SENSOR]: value => colorLowAsGreen(value, 250, 2000),
[DEVICE_FEATURE_CATEGORIES.VOC_INDEX_SENSOR]: value => getVocIndexColor(value),
[DEVICE_FEATURE_CATEGORIES.PM25_SENSOR]: value => colorLowAsGreen(value, 12, 35),
[DEVICE_FEATURE_CATEGORIES.FORMALDEHYD_SENSOR]: value => colorLowAsGreen(value, 50, 120),
[DEVICE_FEATURE_CATEGORIES.AIRQUALITY_SENSOR]: value => getAqiColor(value)
Expand Down
4 changes: 4 additions & 0 deletions front/src/config/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -2702,6 +2702,10 @@
"shortCategoryName": "VOC Sensor",
"decimal": "VOC (decimal)"
},
"voc-index-sensor": {
"shortCategoryName": "VOC Index",
"integer": "VOC Index (integer)"
},
"shutter": {
"shortCategoryName": "Shutter",
"state": "Shutter state",
Expand Down
4 changes: 4 additions & 0 deletions front/src/config/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -2704,6 +2704,10 @@
"shortCategoryName": "Capteur de pollution COV",
"decimal": "COV (Décimale)"
},
"voc-index-sensor": {
"shortCategoryName": "Indice COV",
"integer": "Indice COV (entier)"
},
"shutter": {
"shortCategoryName": "Volet",
"state": "Etat du volet",
Expand Down
3 changes: 3 additions & 0 deletions front/src/utils/consts.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,9 @@ export const DeviceFeatureCategoriesIcon = {
[DEVICE_FEATURE_CATEGORIES.VOC_SENSOR]: {
[DEVICE_FEATURE_TYPES.VOC_SENSOR.DECIMAL]: 'bar-chart-2'
},
[DEVICE_FEATURE_CATEGORIES.VOC_INDEX_SENSOR]: {
[DEVICE_FEATURE_TYPES.VOC_INDEX_SENSOR.INTEGER]: 'bar-chart-2'
},
[DEVICE_FEATURE_CATEGORIES.DATA]: {
[DEVICE_FEATURE_TYPES.DATA.SIZE]: 'hard-drive'
},
Expand Down
8 changes: 8 additions & 0 deletions server/services/zigbee2mqtt/exposes/numericType.js
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,14 @@ module.exports = {
max: 5500,
},
},
voc_index: {
feature: {
category: DEVICE_FEATURE_CATEGORIES.VOC_INDEX_SENSOR,
type: DEVICE_FEATURE_TYPES.VOC_INDEX_SENSOR.INTEGER,
min: 1,
max: 500,
},
},
soil_moisture: {
feature: {
category: DEVICE_FEATURE_CATEGORIES.SOIL_MOISTURE_SENSOR,
Expand Down
4 changes: 4 additions & 0 deletions server/utils/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,7 @@ const DEVICE_FEATURE_CATEGORIES = {
UV_SENSOR: 'uv-sensor',
VIBRATION_SENSOR: 'vibration-sensor',
VOC_SENSOR: 'voc-sensor',
VOC_INDEX_SENSOR: 'voc-index-sensor',
VOLUME_SENSOR: 'volume-sensor',
TEXT: 'text',
};
Expand Down Expand Up @@ -578,6 +579,9 @@ const DEVICE_FEATURE_TYPES = {
VOC_SENSOR: {
DECIMAL: 'decimal',
},
VOC_INDEX_SENSOR: {
INTEGER: 'integer',
},
SHUTTER: {
STATE: 'state',
POSITION: 'position',
Expand Down

0 comments on commit b39e024

Please sign in to comment.