diff --git a/front/src/components/boxs/device-in-room/DeviceRow.jsx b/front/src/components/boxs/device-in-room/DeviceRow.jsx
index 6b82c03c56..7f2af0eac5 100644
--- a/front/src/components/boxs/device-in-room/DeviceRow.jsx
+++ b/front/src/components/boxs/device-in-room/DeviceRow.jsx
@@ -7,6 +7,7 @@ import SensorDeviceFeature from './device-features/sensor-value/SensorDeviceFeat
import LightTemperatureDeviceFeature from './device-features/LightTemperatureDeviceFeature';
import MultiLevelDeviceFeature from './device-features/MultiLevelDeviceFeature';
import NumberDeviceFeature from './device-features/NumberDeviceFeature';
+import CoverDeviceFeature from './device-features/CoverDeviceFeature';
const ROW_TYPE_BY_FEATURE_TYPE = {
[DEVICE_FEATURE_TYPES.LIGHT.BINARY]: BinaryDeviceFeature,
@@ -15,7 +16,11 @@ const ROW_TYPE_BY_FEATURE_TYPE = {
[DEVICE_FEATURE_TYPES.LIGHT.BRIGHTNESS]: MultiLevelDeviceFeature,
[DEVICE_FEATURE_TYPES.LIGHT.TEMPERATURE]: LightTemperatureDeviceFeature,
[DEVICE_FEATURE_TYPES.TELEVISION.CHANNEL]: NumberDeviceFeature,
- [DEVICE_FEATURE_TYPES.TELEVISION.VOLUME]: MultiLevelDeviceFeature
+ [DEVICE_FEATURE_TYPES.TELEVISION.VOLUME]: MultiLevelDeviceFeature,
+ [DEVICE_FEATURE_TYPES.SHUTTER.STATE]: CoverDeviceFeature,
+ [DEVICE_FEATURE_TYPES.SHUTTER.POSITION]: MultiLevelDeviceFeature,
+ [DEVICE_FEATURE_TYPES.CURTAIN.STATE]: CoverDeviceFeature,
+ [DEVICE_FEATURE_TYPES.CURTAIN.POSITION]: MultiLevelDeviceFeature
};
const DeviceRow = ({ children, ...props }) => {
diff --git a/front/src/components/boxs/device-in-room/device-features/CoverDeviceFeature.jsx b/front/src/components/boxs/device-in-room/device-features/CoverDeviceFeature.jsx
new file mode 100644
index 0000000000..aefeb38a99
--- /dev/null
+++ b/front/src/components/boxs/device-in-room/device-features/CoverDeviceFeature.jsx
@@ -0,0 +1,61 @@
+import get from 'get-value';
+import { Text } from 'preact-i18n';
+
+import { getDeviceName } from './utils';
+import { DeviceFeatureCategoriesIcon } from '../../../../utils/consts';
+import { COVER_STATE } from '../../../../../../server/utils/constants';
+
+const UpDownDeviceFeature = ({ children, ...props }) => {
+ const { device, deviceFeature } = props;
+ const { category, type, last_value: lastValue } = deviceFeature;
+
+ function updateValue(value) {
+ props.updateValueWithDebounce(
+ props.x,
+ props.y,
+ device,
+ deviceFeature,
+ props.deviceIndex,
+ props.deviceFeatureIndex,
+ value,
+ lastValue
+ );
+ }
+
+ function open() {
+ updateValue(COVER_STATE.OPEN);
+ }
+
+ function close() {
+ updateValue(COVER_STATE.CLOSE);
+ }
+
+ function stop() {
+ updateValue(COVER_STATE.STOP);
+ }
+
+ return (
+
+
+
+ |
+ {getDeviceName(device, deviceFeature)} |
+
+
+
+ |
+
+ );
+};
+
+export default UpDownDeviceFeature;
diff --git a/front/src/config/demo.js b/front/src/config/demo.js
index 9d136b2f90..18f35e765a 100644
--- a/front/src/config/demo.js
+++ b/front/src/config/demo.js
@@ -166,6 +166,11 @@ const data = {
},
{
type: 'user-presence'
+ },
+ {
+ type: 'devices-in-room',
+ room: 'parental-room',
+ device_features: ['curtain-actions', 'shutter-actions']
}
]
],
@@ -456,6 +461,71 @@ const data = {
}
]
},
+ 'get /api/v1/room/parental-room?expand=devices': {
+ id: '1c634ff4-0476-4733-a084-b4a43d649c84',
+ name: 'Parental Room',
+ selector: 'parental-room',
+ devices: [
+ {
+ id: 'cb3b1a30-d1b6-4624-ac18-e581e3e3b00f',
+ name: 'Main curtain',
+ selector: 'main-curtain',
+ features: [
+ {
+ name: 'Curtain',
+ selector: 'curtain-actions',
+ category: 'curtain',
+ type: 'state',
+ min: 0,
+ max: 1,
+ read_only: false,
+ last_value: 1,
+ last_value_changed: '2019-02-12 07:49:07.556 +00:00'
+ },
+ {
+ name: 'Curtain',
+ selector: 'curtain-position',
+ category: 'curtain',
+ type: 'position',
+ min: 0,
+ max: 100,
+ read_only: true,
+ last_value: 30,
+ last_value_changed: '2019-02-12 07:49:07.556 +00:00'
+ }
+ ]
+ },
+ {
+ id: '919be7a4-df47-4726-b1c0-7412aed99769',
+ name: 'Main shutter',
+ selector: 'main-shutter',
+ features: [
+ {
+ name: 'Shutter',
+ selector: 'shutter-actions',
+ category: 'shutter',
+ type: 'state',
+ min: 0,
+ max: 1,
+ read_only: false,
+ last_value: 1,
+ last_value_changed: '2019-02-12 07:49:07.556 +00:00'
+ },
+ {
+ name: 'Shutter',
+ selector: 'shutter-position',
+ category: 'shutter',
+ type: 'position',
+ min: 0,
+ max: 100,
+ read_only: true,
+ last_value: 30,
+ last_value_changed: '2019-02-12 07:49:07.556 +00:00'
+ }
+ ]
+ }
+ ]
+ },
'get /api/v1/room/kitchen?expand=devices': {
id: 'be6ba391-ebb3-472d-81af-d75d710a8430',
name: 'Kitchen',
diff --git a/front/src/config/i18n/en.json b/front/src/config/i18n/en.json
index 6510d790ae..a93593ea30 100644
--- a/front/src/config/i18n/en.json
+++ b/front/src/config/i18n/en.json
@@ -1671,6 +1671,24 @@
"months": "m",
"years": "y"
},
+ "deviceFeatureAction": {
+ "category": {
+ "shutter": {
+ "state": {
+ "zero": "Stop",
+ "one": "Open",
+ "other": "Close"
+ }
+ },
+ "curtain": {
+ "state": {
+ "zero": "Stop",
+ "one": "Open",
+ "other": "Close"
+ }
+ }
+ }
+ },
"deviceFeatureValue": {
"type": {
"binary": {
@@ -1879,6 +1897,16 @@
"decimal": "Duration (decimal)",
"integer": "Duration (integer)"
},
+ "shutter": {
+ "shortCategoryName": "Shutter",
+ "state": "State",
+ "position": "Position"
+ },
+ "curtain": {
+ "shortCategoryName": "Curtain",
+ "state": "State",
+ "position": "Position"
+ },
"unknown": {
"shortCategoryName": "Unknown",
"unknown": "Unknown"
diff --git a/front/src/config/i18n/fr.json b/front/src/config/i18n/fr.json
index eefbf1c401..0958ce63b1 100644
--- a/front/src/config/i18n/fr.json
+++ b/front/src/config/i18n/fr.json
@@ -1671,6 +1671,24 @@
"months": "m",
"years": "an"
},
+ "deviceFeatureAction": {
+ "category": {
+ "shutter": {
+ "state": {
+ "zero": "Arrêter",
+ "one": "Ouvrir",
+ "other": "Fermer"
+ }
+ },
+ "curtain": {
+ "state": {
+ "zero": "Arrêter",
+ "one": "Ouvrir",
+ "other": "Fermer"
+ }
+ }
+ }
+ },
"deviceFeatureValue": {
"type": {
"binary": {
@@ -1879,6 +1897,16 @@
"decimal": "Durée (décimale)",
"integer": "Durée (entier)"
},
+ "shutter": {
+ "shortCategoryName": "Volet",
+ "state": "Etat",
+ "position": "Position"
+ },
+ "curtain": {
+ "shortCategoryName": "Rideau",
+ "state": "Etat",
+ "position": "Position"
+ },
"unknown": {
"shortCategoryName": "Inconnu",
"unknown": "Inconnu"
diff --git a/front/src/utils/consts.js b/front/src/utils/consts.js
index a009f7fe04..315c832aa5 100644
--- a/front/src/utils/consts.js
+++ b/front/src/utils/consts.js
@@ -185,6 +185,14 @@ export const DeviceFeatureCategoriesIcon = {
[DEVICE_FEATURE_TYPES.TELEVISION.FORWARD]: 'fast-forward',
[DEVICE_FEATURE_TYPES.TELEVISION.RECORD]: 'circle'
},
+ [DEVICE_FEATURE_CATEGORIES.SHUTTER]: {
+ [DEVICE_FEATURE_TYPES.SHUTTER.STATE]: 'sliders',
+ [DEVICE_FEATURE_TYPES.SHUTTER.POSITION]: 'sliders'
+ },
+ [DEVICE_FEATURE_CATEGORIES.CURTAIN]: {
+ [DEVICE_FEATURE_TYPES.CURTAIN.STATE]: 'sliders',
+ [DEVICE_FEATURE_TYPES.CURTAIN.POSITION]: 'sliders'
+ },
[DEVICE_FEATURE_CATEGORIES.SMOKE_SENSOR]: {
[DEVICE_FEATURE_TYPES.SENSOR.BINARY]: 'wind',
[DEVICE_FEATURE_TYPES.SENSOR.DECIMAL]: 'wind'
diff --git a/server/utils/constants.js b/server/utils/constants.js
index 4b36a44f9f..923dba4590 100644
--- a/server/utils/constants.js
+++ b/server/utils/constants.js
@@ -12,6 +12,12 @@ const BUTTON_STATUS = {
LONG_CLICK: 6,
};
+const COVER_STATE = {
+ STOP: 0,
+ OPEN: 1,
+ CLOSE: 2,
+};
+
const USER_ROLE = {
ADMIN: 'admin',
HABITANT: 'habitant',
@@ -332,6 +338,8 @@ const DEVICE_FEATURE_CATEGORIES = {
PRECIPITATION_SENSOR: 'precipitation-sensor',
UV_SENSOR: 'uv-sensor',
DURATION: 'duration',
+ SHUTTER: 'shutter',
+ CURTAIN: 'curtain',
UNKNOWN: 'unknown',
};
@@ -451,6 +459,14 @@ const DEVICE_FEATURE_TYPES = {
DECIMAL: 'decimal',
INTEGER: 'integer',
},
+ SHUTTER: {
+ STATE: 'state',
+ POSITION: 'position',
+ },
+ CURTAIN: {
+ STATE: 'state',
+ POSITION: 'position',
+ },
UNKNOWN: {
UNKNOWN: 'unknown',
},
@@ -784,6 +800,7 @@ const JOB_ERROR_TYPES_LIST = createList(JOB_ERROR_TYPES);
module.exports.STATE = STATE;
module.exports.BUTTON_STATUS = BUTTON_STATUS;
+module.exports.COVER_STATE = COVER_STATE;
module.exports.EVENTS = EVENTS;
module.exports.LIFE_EVENTS = LIFE_EVENTS;
module.exports.STATES = STATES;