Skip to content

Commit

Permalink
Expose lastWanted and wantedSettings to handle duplicate settings.
Browse files Browse the repository at this point in the history
Enable fastSync mode to speed up settings and status sync time by 2x.
  • Loading branch information
dzungpv committed Dec 13, 2023
1 parent b28b8e6 commit 7e8e701
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ hp.setSettings(settings);
// OR individual settings
// hp.setModeSetting("COOL");

// hp.setFastSync(true); // enable fast sync mode, we only request RQST_PKT_SETTINGS, RQST_PKT_ROOM_TEMP and RQST_PKT_STATUS
hp.update();
```

Expand Down
22 changes: 20 additions & 2 deletions src/HeatPump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,21 @@ heatpumpSettings HeatPump::getSettings() {
return currentSettings;
}

heatpumpSettings HeatPump::getWantedSettings()
{
return wantedSettings;
}

unsigned long HeatPump::getLastWanted()
{
return lastWanted;
}

void HeatPump::setFastSync(bool setting)
{
fastSync = setting;
}

bool HeatPump::isConnected() {
return connected;
}
Expand Down Expand Up @@ -543,9 +558,12 @@ void HeatPump::createInfoPacket(byte *packet, byte packetType) {
} else {
// request current infoMode, and increment for the next request
packet[5] = INFOMODE[infoMode];
if(infoMode == (INFOMODE_LEN - 1)) {
if (infoMode == (fastSync ? 2 : (INFOMODE_LEN - 1)))
{ // if enable fastSync we only request RQST_PKT_SETTINGS, RQST_PKT_ROOM_TEMP and RQST_PKT_STATUS, so the sync will be 2x faster
infoMode = 0;
} else {
}
else
{
infoMode++;
}
}
Expand Down
8 changes: 7 additions & 1 deletion src/HeatPump.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@ class HeatPump
const byte INFOMODE[INFOMODE_LEN] = {
0x02, // request a settings packet - RQST_PKT_SETTINGS
0x03, // request the current room temp - RQST_PKT_ROOM_TEMP
0x06, // request status - RQST_PKT_STATUS
0x04, // unknown
0x05, // request the timers - RQST_PKT_TIMERS
0x06, // request status - RQST_PKT_STATUS
0x09 // request standby mode (maybe?) RQST_PKT_STANDBY
};

Expand Down Expand Up @@ -206,6 +206,7 @@ class HeatPump
bool tempMode;
bool externalUpdate;
bool wideVaneAdj;
bool fastSync = false;

const char* lookupByteMapValue(const char* valuesMap[], const byte byteMap[], int len, byte byteValue);
int lookupByteMapValue(const int valuesMap[], const byte byteMap[], int len, byte byteValue);
Expand Down Expand Up @@ -253,6 +254,8 @@ class HeatPump

// settings
heatpumpSettings getSettings();
// wanted settings
heatpumpSettings getWantedSettings();
void setSettings(heatpumpSettings settings);
void setPowerSetting(bool setting);
bool getPowerSettingBool();
Expand All @@ -270,6 +273,9 @@ class HeatPump
const char* getWideVaneSetting();
void setWideVaneSetting(const char* setting);
bool getIseeBool();
void setFastSync(bool setting);
// hacks
unsigned long getLastWanted();

// status
heatpumpStatus getStatus();
Expand Down

0 comments on commit 7e8e701

Please sign in to comment.