From 51333f62ab19055acd9b16759f41c55cd82a7de0 Mon Sep 17 00:00:00 2001 From: Pierre-Gilles Leymarie Date: Fri, 8 Nov 2024 16:01:25 +0100 Subject: [PATCH] Scene: Device state change trigger should update value in case presence sensor change --- .../scene/edit-scene/triggers/DeviceFeatureState.jsx | 2 +- .../device-states/PresenceSensorDeviceState.jsx | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/front/src/routes/scene/edit-scene/triggers/DeviceFeatureState.jsx b/front/src/routes/scene/edit-scene/triggers/DeviceFeatureState.jsx index 2cac11f1c8..d74d04edae 100644 --- a/front/src/routes/scene/edit-scene/triggers/DeviceFeatureState.jsx +++ b/front/src/routes/scene/edit-scene/triggers/DeviceFeatureState.jsx @@ -55,7 +55,7 @@ class TurnOnLight extends Component { {binaryDevice && } - {presenceDevice && } + {presenceDevice && } {buttonClickDevice && } {pilotWireModeDevice && } {defaultDevice && } diff --git a/front/src/routes/scene/edit-scene/triggers/device-states/PresenceSensorDeviceState.jsx b/front/src/routes/scene/edit-scene/triggers/device-states/PresenceSensorDeviceState.jsx index e1a4d63307..8e086069f2 100644 --- a/front/src/routes/scene/edit-scene/triggers/device-states/PresenceSensorDeviceState.jsx +++ b/front/src/routes/scene/edit-scene/triggers/device-states/PresenceSensorDeviceState.jsx @@ -8,6 +8,18 @@ class PresenceSensorDeviceState extends Component { this.props.updateTriggerProperty(this.props.index, 'threshold_only', false); } + componentDidUpdate(prevProps) { + if ( + prevProps.selectedDeviceFeature && + this.props.selectedDeviceFeature && + prevProps.selectedDeviceFeature.selector !== this.props.selectedDeviceFeature.selector + ) { + this.props.updateTriggerProperty(this.props.index, 'operator', '='); + this.props.updateTriggerProperty(this.props.index, 'value', 1); + this.props.updateTriggerProperty(this.props.index, 'threshold_only', false); + } + } + render() { return (