Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zigbee2mqtt add missing exposes owon pir313 e #1958

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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,
DEVICE_FEATURE_CATEGORIES.TAMPER
];

const BinaryDeviceValue = ({ deviceFeature }) => {
Expand Down
21 changes: 20 additions & 1 deletion front/src/config/i18n/en.json
Expand Up @@ -2481,6 +2481,20 @@
"zero": "No",
"one": "Yes"
}
},
"battery": {
"binary": {
"other": "No value received",
"zero": "No",
"one": "Yes"
}
},
"tamper": {
"binary": {
"other": "No value received",
"zero": "No",
"one": "Yes"
}
}
}
},
Expand All @@ -2499,7 +2513,8 @@
},
"battery": {
"shortCategoryName": "Battery",
"integer": "Battery"
"integer": "Battery",
"binary": "Low battery (yes/no)"
},
"temperature-sensor": {
"shortCategoryName": "Temperature sensor",
Expand Down Expand Up @@ -2630,6 +2645,10 @@
"mode": "Mode",
"target-temperature": "Temperature"
},
"tamper": {
"shortCategoryName": "Tamper",
"binary": "Tamper (yes/no)"
},
"television": {
"shortCategoryName": "Television",
"binary": "Power",
Expand Down
21 changes: 20 additions & 1 deletion front/src/config/i18n/fr.json
Expand Up @@ -2483,6 +2483,20 @@
"zero": "Non",
"one": "Oui"
}
},
"battery": {
"binary": {
"other": "Aucune valeur reçue",
"zero": "Non",
"one": "Oui"
}
},
"tamper": {
"binary": {
"other": "Aucune valeur reçue",
"zero": "Non",
"one": "Oui"
}
}
}
},
Expand All @@ -2501,7 +2515,8 @@
},
"battery": {
"shortCategoryName": "Batterie",
"integer": "Batterie"
"integer": "Batterie",
"binary": "Batterie faible (Oui/Non)"
},
"temperature-sensor": {
"shortCategoryName": "Capteur température",
Expand Down Expand Up @@ -2632,6 +2647,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: 4 additions & 2 deletions front/src/routes/integration/all/mqtt/device-page/Device.jsx
Expand Up @@ -5,7 +5,7 @@ import cx from 'classnames';
import get from 'get-value';

import { RequestStatus } from '../../../../../utils/consts';
import { DEVICE_FEATURE_CATEGORIES } from '../../../../../../../server/utils/constants';
import { DEVICE_FEATURE_CATEGORIES, DEVICE_FEATURE_TYPES } from '../../../../../../../server/utils/constants';
import MqttDeviceForm from './DeviceForm';
import BatteryLevelFeature from '../../../../../components/device/view/BatteryLevelFeature';

Expand Down Expand Up @@ -42,7 +42,9 @@ class MqttDeviceBox extends Component {
return null;
}
const batteryLevelDeviceFeature = this.props.device.features.find(
deviceFeature => deviceFeature.category === DEVICE_FEATURE_CATEGORIES.BATTERY
deviceFeature =>
deviceFeature.category === DEVICE_FEATURE_CATEGORIES.BATTERY &&
deviceFeature.type === DEVICE_FEATURE_TYPES.BATTERY.INTEGER
);
const batteryLevel = get(batteryLevelDeviceFeature, 'last_value');
let mostRecentValueAt = null;
Expand Down
6 changes: 5 additions & 1 deletion front/src/utils/consts.js
Expand Up @@ -99,7 +99,8 @@ export const DASHBOARD_BOX_DATA_KEY = 'DashboardBoxData';

export const DeviceFeatureCategoriesIcon = {
[DEVICE_FEATURE_CATEGORIES.BATTERY]: {
[DEVICE_FEATURE_TYPES.SENSOR.INTEGER]: 'battery'
[DEVICE_FEATURE_TYPES.SENSOR.INTEGER]: 'battery',
[DEVICE_FEATURE_TYPES.SENSOR.BINARY]: 'battery'
},
[DEVICE_FEATURE_CATEGORIES.CAMERA]: {
[DEVICE_FEATURE_TYPES.CAMERA.IMAGE]: 'camera'
Expand Down Expand Up @@ -220,6 +221,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
6 changes: 6 additions & 0 deletions server/services/zigbee2mqtt/exposes/binaryType.js
Expand Up @@ -78,6 +78,12 @@ const names = {
type: DEVICE_FEATURE_TYPES.SENSOR.BINARY,
},
},
battery_low: {
feature: {
category: DEVICE_FEATURE_CATEGORIES.BATTERY,
type: DEVICE_FEATURE_TYPES.SENSOR.BINARY,
},
},
};

module.exports = {
Expand Down
5 changes: 5 additions & 0 deletions server/utils/constants.js
Expand Up @@ -426,6 +426,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 @@ -480,6 +481,7 @@ const DEVICE_FEATURE_TYPES = {
},
BATTERY: {
INTEGER: 'integer',
BINARY: 'binary',
},
VIBRATION_SENSOR: {
BINARY: 'binary',
Expand Down Expand Up @@ -507,6 +509,9 @@ const DEVICE_FEATURE_TYPES = {
SURFACE: {
DECIMAL: 'decimal',
},
TAMPER: {
BINARY: 'binary',
},
TELEVISION: {
BINARY: 'binary',
SOURCE: 'source',
Expand Down