From 54e39f3da317d8244f9cc2a9ab07a2fcf6160f67 Mon Sep 17 00:00:00 2001 From: William Deren Date: Sun, 27 Oct 2024 23:40:20 +0100 Subject: [PATCH 1/3] add pilot wire mode device in DeviceSetValue --- .../src/routes/scene/edit-scene/actions/DeviceSetValue.jsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/front/src/routes/scene/edit-scene/actions/DeviceSetValue.jsx b/front/src/routes/scene/edit-scene/actions/DeviceSetValue.jsx index 7b1cd3b295..3c6b9b1905 100644 --- a/front/src/routes/scene/edit-scene/actions/DeviceSetValue.jsx +++ b/front/src/routes/scene/edit-scene/actions/DeviceSetValue.jsx @@ -144,6 +144,12 @@ class DeviceSetValue extends Component { ); } + if (this.state.deviceFeature.type === DEVICE_FEATURE_TYPES.HEATER.PILOT_WIRE_MODE) { + return ( + + ); + } + return (
From b41977ebd74631d0150aaf17ada9477b78430b61 Mon Sep 17 00:00:00 2001 From: William Deren Date: Mon, 28 Oct 2024 22:03:23 +0100 Subject: [PATCH 2/3] add pilot wire mode device to scene triggers list --- .../triggers/DeviceFeatureState.jsx | 8 ++- .../PilotWireModeDeviceState.jsx | 62 +++++++++++++++++++ 2 files changed, 68 insertions(+), 2 deletions(-) create mode 100644 front/src/routes/scene/edit-scene/triggers/device-states/PilotWireModeDeviceState.jsx diff --git a/front/src/routes/scene/edit-scene/triggers/DeviceFeatureState.jsx b/front/src/routes/scene/edit-scene/triggers/DeviceFeatureState.jsx index 9e8764dc10..f7ebe10df8 100644 --- a/front/src/routes/scene/edit-scene/triggers/DeviceFeatureState.jsx +++ b/front/src/routes/scene/edit-scene/triggers/DeviceFeatureState.jsx @@ -9,6 +9,7 @@ import PresenceSensorDeviceState from './device-states/PresenceSensorDeviceState import ThresholdDeviceState from './device-states/ThresholdDeviceState'; import DefaultDeviceState from './device-states/DefaultDeviceState'; import ButtonClickDeviceState from './device-states/ButtonClickDeviceState'; +import PilotWireModeDeviceState from './device-states/PilotWireModeDeviceState'; class TurnOnLight extends Component { onDeviceFeatureChange = deviceFeature => { @@ -27,6 +28,7 @@ class TurnOnLight extends Component { let binaryDevice = false; let presenceDevice = false; let buttonClickDevice = false; + let pilotWireModeDevice = false; if (selectedDeviceFeature) { const { category, type } = selectedDeviceFeature; @@ -34,10 +36,11 @@ class TurnOnLight extends Component { binaryDevice = type === DEVICE_FEATURE_TYPES.SWITCH.BINARY; presenceDevice = category === DEVICE_FEATURE_CATEGORIES.PRESENCE_SENSOR; buttonClickDevice = category === DEVICE_FEATURE_CATEGORIES.BUTTON; + pilotWireModeDevice = category === DEVICE_FEATURE_CATEGORIES.HEATER; } - const defaultDevice = selectedDeviceFeature && !binaryDevice && !presenceDevice && !buttonClickDevice; - const thresholdDevice = selectedDeviceFeature && !presenceDevice && !buttonClickDevice; + const defaultDevice = selectedDeviceFeature && !binaryDevice && !presenceDevice && !buttonClickDevice && !pilotWireModeDevice; + const thresholdDevice = selectedDeviceFeature && !presenceDevice && !buttonClickDevice && !pilotWireModeDevice; return (
@@ -53,6 +56,7 @@ class TurnOnLight extends Component { {binaryDevice && } {presenceDevice && } {buttonClickDevice && } + {pilotWireModeDevice && } {defaultDevice && }
{thresholdDevice && } diff --git a/front/src/routes/scene/edit-scene/triggers/device-states/PilotWireModeDeviceState.jsx b/front/src/routes/scene/edit-scene/triggers/device-states/PilotWireModeDeviceState.jsx new file mode 100644 index 0000000000..25756a0f8c --- /dev/null +++ b/front/src/routes/scene/edit-scene/triggers/device-states/PilotWireModeDeviceState.jsx @@ -0,0 +1,62 @@ +import { Component, Fragment } from 'preact'; +import Select from 'react-select'; +import get from 'get-value'; + +import { PILOT_WIRE_MODE } from '../../../../../../../server/utils/constants'; +import withIntlAsProp from '../../../../../utils/withIntlAsProp'; + +class PilotWireModeDeviceState extends Component { + handleValueChange = ({ value }) => { + this.props.updateTriggerProperty(this.props.index, 'value', value); + }; + + getOptions = () => { + const modeLabels = { + 0: 'deviceFeatureAction.category.heater.pilot-wire-mode.off', + 1: 'deviceFeatureAction.category.heater.pilot-wire-mode.frost-protection', + 2: 'deviceFeatureAction.category.heater.pilot-wire-mode.eco', + 3: 'deviceFeatureAction.category.heater.pilot-wire-mode.comfort_-1', + 4: 'deviceFeatureAction.category.heater.pilot-wire-mode.comfort_-2', + 5: 'deviceFeatureAction.category.heater.pilot-wire-mode.comfort' + }; + + const options = Object.keys(PILOT_WIRE_MODE).map(key => { + const value = PILOT_WIRE_MODE[key]; + return { + label: get(this.props.intl.dictionary, modeLabels[value], { + default: value + }), + value + }; + }); + + this.setState({ options }); + }; + + componentWillMount() { + this.props.updateTriggerProperty(this.props.index, 'operator', '='); + + this.getOptions(); + } + + render({ trigger }, { options }) { + const defaultValue = options.find(option => trigger.value === option.value); + + return ( + +
+
+ +
+
+
+
+ } + /> + ); + } +} + +export default withIntlAsProp(SelectPilotWireMode); diff --git a/front/src/config/i18n/de.json b/front/src/config/i18n/de.json index ecb6580da5..c0d0f2ec15 100644 --- a/front/src/config/i18n/de.json +++ b/front/src/config/i18n/de.json @@ -2842,6 +2842,16 @@ "51": "Doppeltes Drücken" } }, + "heater": { + "pilot-wire-mode": { + "0": "Aus", + "1": "Frostschutz", + "2": "Öko", + "3": "Komfort -1°C", + "4": "Komfort -2°C", + "5": "Komfort" + } + }, "opening-sensor": { "binary": { "other": "Kein Wert empfangen", diff --git a/front/src/config/i18n/en.json b/front/src/config/i18n/en.json index 85f1b09322..923b1832e0 100644 --- a/front/src/config/i18n/en.json +++ b/front/src/config/i18n/en.json @@ -2842,6 +2842,16 @@ "51": "Double press" } }, + "heater": { + "pilot-wire-mode": { + "0": "Off", + "1": "Frost Protection", + "2": "Eco", + "3": "Comfort -1°C", + "4": "Comfort -2°C", + "5": "Comfort" + } + }, "opening-sensor": { "binary": { "other": "No value received", diff --git a/front/src/config/i18n/fr.json b/front/src/config/i18n/fr.json index dba32fdf4a..d4c4c55dd2 100644 --- a/front/src/config/i18n/fr.json +++ b/front/src/config/i18n/fr.json @@ -2842,6 +2842,16 @@ "51": "Pression double" } }, + "heater": { + "pilot-wire-mode": { + "0": "Off", + "1": "Hors Gel", + "2": "Eco", + "3": "Confort -1°C", + "4": "Confort -2°C", + "5": "Confort" + } + }, "opening-sensor": { "binary": { "other": "Aucune valeur reçue", diff --git a/front/src/routes/scene/edit-scene/actions/DeviceSetValue.jsx b/front/src/routes/scene/edit-scene/actions/DeviceSetValue.jsx index 3c6b9b1905..3f81fb8e6f 100644 --- a/front/src/routes/scene/edit-scene/actions/DeviceSetValue.jsx +++ b/front/src/routes/scene/edit-scene/actions/DeviceSetValue.jsx @@ -13,6 +13,7 @@ import TextWithVariablesInjected from '../../../../components/scene/TextWithVari import '../../../../components/boxs/device-in-room/device-features/style.css'; import style from './DeviceSetValue.css'; import ShutterButtons from '../../../../components/device/ShutterButtons'; +import SelectPilotWireMode from '../../../../components/device/SelectPilotWireMode'; class DeviceSetValue extends Component { constructor(props) { @@ -146,7 +147,12 @@ class DeviceSetValue extends Component { if (this.state.deviceFeature.type === DEVICE_FEATURE_TYPES.HEATER.PILOT_WIRE_MODE) { return ( - + ); } diff --git a/front/src/routes/scene/edit-scene/triggers/DeviceFeatureState.jsx b/front/src/routes/scene/edit-scene/triggers/DeviceFeatureState.jsx index f7ebe10df8..2cac11f1c8 100644 --- a/front/src/routes/scene/edit-scene/triggers/DeviceFeatureState.jsx +++ b/front/src/routes/scene/edit-scene/triggers/DeviceFeatureState.jsx @@ -39,7 +39,8 @@ class TurnOnLight extends Component { pilotWireModeDevice = category === DEVICE_FEATURE_CATEGORIES.HEATER; } - const defaultDevice = selectedDeviceFeature && !binaryDevice && !presenceDevice && !buttonClickDevice && !pilotWireModeDevice; + const defaultDevice = + selectedDeviceFeature && !binaryDevice && !presenceDevice && !buttonClickDevice && !pilotWireModeDevice; const thresholdDevice = selectedDeviceFeature && !presenceDevice && !buttonClickDevice && !pilotWireModeDevice; return ( diff --git a/front/src/routes/scene/edit-scene/triggers/device-states/PilotWireModeDeviceState.jsx b/front/src/routes/scene/edit-scene/triggers/device-states/PilotWireModeDeviceState.jsx index 25756a0f8c..a4bf6a75c8 100644 --- a/front/src/routes/scene/edit-scene/triggers/device-states/PilotWireModeDeviceState.jsx +++ b/front/src/routes/scene/edit-scene/triggers/device-states/PilotWireModeDeviceState.jsx @@ -11,19 +11,10 @@ class PilotWireModeDeviceState extends Component { }; getOptions = () => { - const modeLabels = { - 0: 'deviceFeatureAction.category.heater.pilot-wire-mode.off', - 1: 'deviceFeatureAction.category.heater.pilot-wire-mode.frost-protection', - 2: 'deviceFeatureAction.category.heater.pilot-wire-mode.eco', - 3: 'deviceFeatureAction.category.heater.pilot-wire-mode.comfort_-1', - 4: 'deviceFeatureAction.category.heater.pilot-wire-mode.comfort_-2', - 5: 'deviceFeatureAction.category.heater.pilot-wire-mode.comfort' - }; - const options = Object.keys(PILOT_WIRE_MODE).map(key => { const value = PILOT_WIRE_MODE[key]; return { - label: get(this.props.intl.dictionary, modeLabels[value], { + label: get(this.props.intl.dictionary, `deviceFeatureValue.category.heater.pilot-wire-mode.${value}`, { default: value }), value