Skip to content

Commit

Permalink
Zigbee2mqtt: Add low_battery and tamper expose on Owon pir313 e (#1962)
Browse files Browse the repository at this point in the history
  • Loading branch information
William-De71 authored Dec 8, 2023
1 parent b39e024 commit c1d76bd
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import { DEVICE_FEATURE_CATEGORIES } from '../../../../../../../server/utils/con
const DANGER_ON_VALUE_SENSORS = [
DEVICE_FEATURE_CATEGORIES.CO_SENSOR,
DEVICE_FEATURE_CATEGORIES.LEAK_SENSOR,
DEVICE_FEATURE_CATEGORIES.SMOKE_SENSOR
DEVICE_FEATURE_CATEGORIES.SMOKE_SENSOR,
DEVICE_FEATURE_CATEGORIES.BATTERY_LOW,
DEVICE_FEATURE_CATEGORIES.TAMPER
];

const BinaryDeviceValue = ({ deviceFeature }) => {
Expand Down
22 changes: 22 additions & 0 deletions front/src/config/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -2481,6 +2481,20 @@
"zero": "No",
"one": "Yes"
}
},
"battery-low": {
"binary": {
"other": "No value received",
"zero": "No",
"one": "Yes"
}
},
"tamper": {
"binary": {
"other": "No value received",
"zero": "No",
"one": "Yes"
}
}
}
},
Expand All @@ -2501,6 +2515,10 @@
"shortCategoryName": "Battery",
"integer": "Battery"
},
"battery-low": {
"shortCategoryName": "Low Battery",
"binary": "Low battery (yes/no)"
},
"temperature-sensor": {
"shortCategoryName": "Temperature sensor",
"decimal": "Temperature"
Expand Down Expand Up @@ -2630,6 +2648,10 @@
"mode": "Mode",
"target-temperature": "Temperature"
},
"tamper": {
"shortCategoryName": "Tamper",
"binary": "Tamper (yes/no)"
},
"television": {
"shortCategoryName": "Television",
"binary": "Power",
Expand Down
22 changes: 22 additions & 0 deletions front/src/config/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -2483,6 +2483,20 @@
"zero": "Non",
"one": "Oui"
}
},
"battery-low": {
"binary": {
"other": "Aucune valeur reçue",
"zero": "Non",
"one": "Oui"
}
},
"tamper": {
"binary": {
"other": "Aucune valeur reçue",
"zero": "Non",
"one": "Oui"
}
}
}
},
Expand All @@ -2503,6 +2517,10 @@
"shortCategoryName": "Batterie",
"integer": "Batterie"
},
"battery-low": {
"shortCategoryName": "Batterie faible",
"binary": "Batterie faible (Oui/Non)"
},
"temperature-sensor": {
"shortCategoryName": "Capteur température",
"decimal": "Température"
Expand Down Expand Up @@ -2632,6 +2650,10 @@
"mode": "Mode",
"target-temperature": "Température"
},
"tamper": {
"shortCategoryName": "Détecteur de sabotage",
"binary": "Détection sabotage (Oui/Non)"
},
"television": {
"shortCategoryName": "Télévision",
"binary": "Power",
Expand Down
6 changes: 6 additions & 0 deletions front/src/utils/consts.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ export const DeviceFeatureCategoriesIcon = {
[DEVICE_FEATURE_CATEGORIES.BATTERY]: {
[DEVICE_FEATURE_TYPES.SENSOR.INTEGER]: 'battery'
},
[DEVICE_FEATURE_CATEGORIES.BATTERY_LOW]: {
[DEVICE_FEATURE_TYPES.SENSOR.BINARY]: 'battery'
},
[DEVICE_FEATURE_CATEGORIES.CAMERA]: {
[DEVICE_FEATURE_TYPES.CAMERA.IMAGE]: 'camera'
},
Expand Down Expand Up @@ -220,6 +223,9 @@ export const DeviceFeatureCategoriesIcon = {
[DEVICE_FEATURE_CATEGORIES.SIREN]: {
[DEVICE_FEATURE_TYPES.SIREN.BINARY]: 'bell'
},
[DEVICE_FEATURE_CATEGORIES.TAMPER]: {
[DEVICE_FEATURE_TYPES.SENSOR.BINARY]: 'shield'
},
[DEVICE_FEATURE_CATEGORIES.ACCESS_CONTROL]: {
[DEVICE_FEATURE_TYPES.ACCESS_CONTROL.MODE]: 'lock'
},
Expand Down
12 changes: 12 additions & 0 deletions server/services/zigbee2mqtt/exposes/binaryType.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,18 @@ const names = {
type: DEVICE_FEATURE_TYPES.SENSOR.BINARY,
},
},
battery_low: {
feature: {
category: DEVICE_FEATURE_CATEGORIES.BATTERY_LOW,
type: DEVICE_FEATURE_TYPES.SENSOR.BINARY,
},
},
tamper: {
feature: {
category: DEVICE_FEATURE_CATEGORIES.TAMPER,
type: DEVICE_FEATURE_TYPES.SENSOR.BINARY,
},
},
};

module.exports = {
Expand Down
8 changes: 8 additions & 0 deletions server/utils/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,7 @@ const DEVICE_FEATURE_CATEGORIES = {
AIRQUALITY_SENSOR: 'airquality-sensor',
AIR_CONDITIONING: 'air-conditioning',
BATTERY: 'battery',
BATTERY_LOW: 'battery-low',
BUTTON: 'button',
CAMERA: 'camera',
CUBE: 'cube',
Expand Down Expand Up @@ -426,6 +427,7 @@ const DEVICE_FEATURE_CATEGORIES = {
SURFACE: 'surface',
SWITCH: 'switch',
SPEED_SENSOR: 'speed-sensor',
TAMPER: 'tamper',
TELEVISION: 'television',
TEMPERATURE_SENSOR: 'temperature-sensor',
THERMOSTAT: 'thermostat',
Expand Down Expand Up @@ -482,6 +484,9 @@ const DEVICE_FEATURE_TYPES = {
BATTERY: {
INTEGER: 'integer',
},
BATTERY_LOW: {
BINARY: 'binary',
},
VIBRATION_SENSOR: {
BINARY: 'binary',
STATUS: 'status',
Expand All @@ -508,6 +513,9 @@ const DEVICE_FEATURE_TYPES = {
SURFACE: {
DECIMAL: 'decimal',
},
TAMPER: {
BINARY: 'binary',
},
TELEVISION: {
BINARY: 'binary',
SOURCE: 'source',
Expand Down

0 comments on commit c1d76bd

Please sign in to comment.