Skip to content

Commit

Permalink
Scene: Device state change trigger should update value in case presen…
Browse files Browse the repository at this point in the history
…ce sensor change
  • Loading branch information
Pierre-Gilles committed Nov 8, 2024
1 parent 37f76c4 commit 51333f6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class TurnOnLight extends Component {
</div>
</div>
{binaryDevice && <BinaryDeviceState {...props} selectedDeviceFeature={selectedDeviceFeature} />}
{presenceDevice && <PresenceSensorDeviceState {...props} />}
{presenceDevice && <PresenceSensorDeviceState {...props} selectedDeviceFeature={selectedDeviceFeature} />}
{buttonClickDevice && <ButtonClickDeviceState {...props} />}
{pilotWireModeDevice && <PilotWireModeDeviceState {...props} />}
{defaultDevice && <DefaultDeviceState {...props} selectedDeviceFeature={selectedDeviceFeature} />}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<div class="col-6">
Expand Down

0 comments on commit 51333f6

Please sign in to comment.