Skip to content

Commit

Permalink
switchprog: fetch immediate after mode change, verify write
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelDvP committed Nov 22, 2024
1 parent d2bd480 commit 56e57c9
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions src/devices/thermostat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2447,11 +2447,22 @@ bool Thermostat::set_switchProgMode(const char * value, const int8_t id) {
return false;
}
write_command(set_typeids[hc->hc()], 19, set + 1, set_typeids[hc->hc()]);
hc->switchProgMode = set;
toggle_fetch(timer_typeids[hc->hc()], hc->program != 1 && hc->switchProgMode != 1); // RC100 or both 0
toggle_fetch(timer2_typeids[hc->hc()], hc->program == 1 && hc->switchProgMode == 0);
toggle_fetch(timer3_typeids[hc->hc()], hc->program == 0 && hc->switchProgMode == 1);
toggle_fetch(timer4_typeids[hc->hc()], hc->program == 1 && hc->switchProgMode == 1);
if (set != hc->switchProgMode) {
hc->switchProgMode = set;
toggle_fetch(timer_typeids[hc->hc()], hc->program != 1 && hc->switchProgMode != 1); // RC100 or both 0
toggle_fetch(timer2_typeids[hc->hc()], hc->program == 1 && hc->switchProgMode == 0);
toggle_fetch(timer3_typeids[hc->hc()], hc->program == 0 && hc->switchProgMode == 1);
toggle_fetch(timer4_typeids[hc->hc()], hc->program == 1 && hc->switchProgMode == 1);
if (hc->program == 1 && hc->switchProgMode == 1) {
read_command(timer4_typeids[hc->hc()]);
} else if (hc->program == 0 && hc->switchProgMode == 1) {
read_command(timer3_typeids[hc->hc()]);
} else if (hc->program == 1 && hc->switchProgMode == 0) {
read_command(timer2_typeids[hc->hc()]);
} else {
read_command(timer_typeids[hc->hc()]);
}
}
return true;
}

Expand Down Expand Up @@ -3520,10 +3531,10 @@ bool Thermostat::set_switchtimes(const char * value, const uint16_t type_id, uin
offset += 2;
}
// write all 84 bytes, split even to have the 2 bytes switchpoint in one telegram part
write_command(type_id, 72, &switchtimes[72], 12, 0);
write_command(type_id, 48, &switchtimes[48], 24, 0);
write_command(type_id, 24, &switchtimes[24], 24, 0);
write_command(type_id, 0, switchtimes, 24, 0);
write_command(type_id, 72, &switchtimes[72], 12, type_id);
write_command(type_id, 48, &switchtimes[48], 24, type_id);
write_command(type_id, 24, &switchtimes[24], 24, type_id);
write_command(type_id, 0, switchtimes, 24, type_id);
return true;
}
// set a single switchpoint
Expand Down

0 comments on commit 56e57c9

Please sign in to comment.