Skip to content

Commit

Permalink
Add presence-sensor category (#1024)
Browse files Browse the repository at this point in the history
Co-authored-by: Pierre-Gilles Leymarie <pierregilles.leymarie@gmail.com>
  • Loading branch information
atrovato and Pierre-Gilles authored Dec 21, 2020
1 parent 9024d4b commit 0d8e2c9
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ dayjs.extend(relativeTime);

import { DEVICE_FEATURE_UNITS, DEVICE_FEATURE_CATEGORIES } from '../../../../../../server/utils/constants';

const SPECIAL_SENSORS = [DEVICE_FEATURE_CATEGORIES.OPENING_SENSOR, DEVICE_FEATURE_CATEGORIES.MOTION_SENSOR];
const SPECIAL_SENSORS = [
DEVICE_FEATURE_CATEGORIES.OPENING_SENSOR,
DEVICE_FEATURE_CATEGORIES.MOTION_SENSOR,
DEVICE_FEATURE_CATEGORIES.PRESENCE_SENSOR
];
const LAST_SEEN_SENSORS = [DEVICE_FEATURE_CATEGORIES.MOTION_SENSOR, DEVICE_FEATURE_CATEGORIES.PRESENCE_SENSOR];

import { DeviceFeatureCategoriesIcon } from '../../../../utils/consts';

Expand Down Expand Up @@ -51,7 +56,7 @@ const SensorDeviceType = ({ children, ...props }) => (
{props.deviceFeature.last_value === 0 && <i class="fe fe-shield-off" />}
</td>
)}
{props.deviceFeature.category === DEVICE_FEATURE_CATEGORIES.MOTION_SENSOR && (
{LAST_SEEN_SENSORS.includes(props.deviceFeature.category) && (
<td class={cx('text-right', { 'text-nowrap': props.deviceFeature.last_value_changed })}>
{!props.deviceFeature.last_value_changed && <Text id="dashboard.boxes.devicesInRoom.noValue" />}
{props.deviceFeature.last_value_changed &&
Expand Down
15 changes: 14 additions & 1 deletion front/src/config/demo.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@
[
{
"type": "devices-in-room",
"room": "kitchen"
"room": "kitchen",
"device_features": ["main-presence-sensor"]
}
]
],
Expand Down Expand Up @@ -377,6 +378,18 @@
"last_value": 340,
"last_value_changed": "2019-02-12 07:49:07.556 +00:00"
},
{
"name": "Presence",
"selector": "main-presence-sensor",
"category": "presence-sensor",
"type": "push",
"unit": null,
"min": 0,
"max": 1,
"read_only": true,
"last_value": 0,
"last_value_changed": "2020-12-20 13:49:07.556 +01:00"
},
{
"name": "Kitchen door",
"selector": "temperature-living-room-celsius",
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 @@ -1234,6 +1234,10 @@
"push": "Motion (push)",
"binary": "Motion (binary)"
},
"presence-sensor": {
"shortCategoryName": "Presence sensor",
"push": "Presence"
},
"light-sensor": {
"shortCategoryName": "Luminosity sensor",
"integer": "Luminosity (integer)",
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 @@ -1234,6 +1234,10 @@
"push": "Détecteur de mouvement",
"binary": "Détection mouvement Oui/Non"
},
"presence-sensor": {
"shortCategoryName": "Détecteur de présence",
"push": "Présence"
},
"light-sensor": {
"shortCategoryName": "Capteur de luminosité",
"integer": "Luminosité entière",
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 @@ -108,6 +108,9 @@ export const DeviceFeatureCategoriesIcon = {
[DEVICE_FEATURE_TYPES.SENSOR.BINARY]: 'eye',
[DEVICE_FEATURE_TYPES.SENSOR.PUSH]: 'eye'
},
[DEVICE_FEATURE_CATEGORIES.PRESENCE_SENSOR]: {
[DEVICE_FEATURE_TYPES.SENSOR.PUSH]: 'users'
},
[DEVICE_FEATURE_CATEGORIES.SISMIC_SENSOR]: {
[DEVICE_FEATURE_TYPES.SENSOR.DECIMAL]: 'activity'
},
Expand Down
1 change: 1 addition & 0 deletions server/utils/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ const DEVICE_FEATURE_CATEGORIES = {
CO2_SENSOR: 'co2-sensor',
COUNTER_SENSOR: 'counter-sensor',
LEAK_SENSOR: 'leak-sensor',
PRESENCE_SENSOR: 'presence-sensor',
CAMERA: 'camera',
SWITCH: 'switch',
SIREN: 'siren',
Expand Down

0 comments on commit 0d8e2c9

Please sign in to comment.