fix: move only the tilt of a tilt-only shade for sun and wind

The three places that act on the sun and wind each set different targets
for a tilt-only shade: the sun timer moved its lift, the no-sun and wind
timers moved tilt and lift, a group's sun flag moved its lift and only a
remote's sun flag moved its tilt. They now share sensorTargets(): a
tilt-only shade moves its tilt to the favorite tilt (or fully) and back to
0, and every other shade its lift, as Up and Down already do.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
cjkas 2026-10-13 21:14:20 +02:00
parent 8276c1c3cd
commit 5f26340d06
5 changed files with 83 additions and 37 deletions

View file

@ -152,17 +152,7 @@ void SomfyShade::checkMovement() {
case TxHoldCheck::none:
break;
}
switch(this->sensors.check(sunFlag, isSunny, isWindy, (uint32_t)curTime)) {
case SensorMove::extend:
this->p_target(this->myPos >= 0 ? this->myPos : 100.0f);
break;
case SensorMove::retract:
if(this->tiltType == tilt_types::tiltonly) this->p_tiltTarget(0.0f);
this->p_target(0.0f);
break;
case SensorMove::none:
break;
}
this->applySensorMove(this->sensors.check(sunFlag, isSunny, isWindy, (uint32_t)curTime));
if(!tilt_first && this->direction > 0) {
this->p_currentPos(travelPosition(this->startPos, 1, (uint32_t)(curTime - this->moveStart), downTime));
@ -609,22 +599,7 @@ void SomfyShade::processFrame(somfy_frame_t &frame, bool internal) {
const bool isSunny = this->flags & static_cast<uint8_t>(somfy_flags_t::Sunny);
//this->flags |= static_cast<uint8_t>(somfy_flags_t::SunFlag);
this->p_sunFlag(true);
switch(this->sensors.onSunFlag(isSunny, isWindy)) {
case SensorMove::extend:
if(this->tiltType == tilt_types::tiltonly)
this->p_tiltTarget(this->myTiltPos >= 0 ? this->myTiltPos : 100.0f);
else
this->p_target(this->myPos >= 0 ? this->myPos : 100.0f);
break;
case SensorMove::retract:
if(this->tiltType == tilt_types::tiltonly)
this->p_tiltTarget(0.0f);
else
this->p_target(0.0f);
break;
case SensorMove::none:
break;
}
this->applySensorMove(this->sensors.onSunFlag(isSunny, isWindy));
somfy.isDirty = true;
this->emitState();
this->emitCommand(cmd, internal ? "internal" : "remote", frame.remoteAddress);
@ -1007,16 +982,7 @@ void SomfyShade::processInternalCommand(somfy_commands cmd, uint8_t repeat) {
const bool isSunny = this->flags & static_cast<uint8_t>(somfy_flags_t::Sunny);
this->p_sunFlag(true);
//this->flags |= static_cast<uint8_t>(somfy_flags_t::SunFlag);
switch(this->sensors.onSunFlag(isSunny, isWindy)) {
case SensorMove::extend:
this->p_target(this->myPos >= 0 ? this->myPos : 100.0f);
break;
case SensorMove::retract:
this->p_target(0.0f);
break;
case SensorMove::none:
break;
}
this->applySensorMove(this->sensors.onSunFlag(isSunny, isWindy));
somfy.isDirty = true;
this->emitState();
}
@ -1126,6 +1092,11 @@ void SomfyShade::runToLimit(int8_t dir, bool tilt, uint32_t since) {
// The favorite can't be set where the shade won't stop.
this->settingMyPos = false;
}
void SomfyShade::applySensorMove(SensorMove move) {
const SensorTargets t = sensorTargets(move, this->tiltType, this->myPos, this->myTiltPos);
if(t.setLift) this->p_target(t.lift);
if(t.setTilt) this->p_tiltTarget(t.tilt);
}
void SomfyShade::setMovement(int8_t dir) {
int8_t currDir = this->direction;
int8_t currTiltDir = this->tiltDirection;