Skip to content

Commit

Permalink
switchprog temp reading fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelDvP committed Nov 20, 2024
1 parent 208be42 commit 1704e30
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/devices/thermostat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3412,13 +3412,15 @@ bool Thermostat::set_reducehours(const char * value, const int8_t id) {
}

bool Thermostat::set_switchpoint(JsonObject doc, uint8_t & offset, uint8_t * data) {
uint8_t no = doc["no"] | 0xFF;
float tempF = doc["temp"] | 0;
std::string s_day = doc["day"].as<std::string>();
std::string s_mode = doc["mode"].as<std::string>();
std::string s_time = doc["time"].as<std::string>();
uint8_t day;
uint8_t temp = tempF;
uint8_t no = doc["no"] | 0xFF;
auto s_temp = doc["temp"].as<std::string>();
auto s_day = doc["day"].as<std::string>();
auto s_mode = doc["mode"].as<std::string>();
auto s_time = doc["time"].as<std::string>();
uint8_t day;
float tempF;
Helpers::value2float(s_temp.c_str(), tempF);
uint8_t temp = (uint8_t)tempF;
// LOG_DEBUG("id: %d, day: %s, mode: %s, time: %s", no, s_day.c_str(), s_mode.c_str(), s_time.c_str());
if (!Helpers::value2enum(s_day.c_str(), day, FL_(enum_dayOfWeek))) {
day = 7;
Expand Down Expand Up @@ -3461,9 +3463,9 @@ bool Thermostat::set_switchpoint(JsonObject doc, uint8_t & offset, uint8_t * dat
data[1] = 0xFF;
}
} else { // RC300
if (temp == 0) {
if (tempF == 0) {
if (!Helpers::value2enum(s_mode.c_str(), temp, FL_(enum_switchmode))) {
LOG_ERROR("wrong switchmode");
LOG_ERROR("wrong switchmode '%s' or temp '%d", s_mode.c_str(), temp);
return false;
}
temp--; // set on->0xFF, off to 0x00
Expand Down

0 comments on commit 1704e30

Please sign in to comment.