|
@ -43,7 +43,6 @@ class PubMqtt { |
|
|
memset(mLastIvState, (uint8_t)InverterStatus::OFF, MAX_NUM_INVERTERS); |
|
|
memset(mLastIvState, (uint8_t)InverterStatus::OFF, MAX_NUM_INVERTERS); |
|
|
memset(mIvLastRTRpub, 0, MAX_NUM_INVERTERS * 4); |
|
|
memset(mIvLastRTRpub, 0, MAX_NUM_INVERTERS * 4); |
|
|
mLastAnyAvail = false; |
|
|
mLastAnyAvail = false; |
|
|
mZeroValues = false; |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
~PubMqtt() { } |
|
|
~PubMqtt() { } |
|
@ -134,7 +133,7 @@ class PubMqtt { |
|
|
#endif |
|
|
#endif |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
bool tickerSun(uint32_t sunrise, uint32_t sunset, int16_t offsM, int16_t offsE) { |
|
|
bool tickerSun(uint32_t sunrise, uint32_t sunset, int16_t offsM, int16_t offsE, bool isSunrise = false) { |
|
|
if (!mClient.connected()) |
|
|
if (!mClient.connected()) |
|
|
return false; |
|
|
return false; |
|
|
|
|
|
|
|
@ -153,10 +152,12 @@ class PubMqtt { |
|
|
publish(mSubTopic, ((iv->commEnabled) ? dict[STR_TRUE] : dict[STR_FALSE]), true); |
|
|
publish(mSubTopic, ((iv->commEnabled) ? dict[STR_TRUE] : dict[STR_FALSE]), true); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
snprintf(mSubTopic, 32 + MAX_NAME_LENGTH, "comm_disabled"); |
|
|
snprintf(mSubTopic, 32 + MAX_NAME_LENGTH, "comm_disabled"); |
|
|
publish(mSubTopic, (((*mUtcTimestamp > (sunset + offsE)) || (*mUtcTimestamp < (sunrise + offsM))) ? dict[STR_TRUE] : dict[STR_FALSE]), true); |
|
|
publish(mSubTopic, (((*mUtcTimestamp > (sunset + offsE)) || (*mUtcTimestamp < (sunrise + offsM))) ? dict[STR_TRUE] : dict[STR_FALSE]), true); |
|
|
|
|
|
|
|
|
|
|
|
if(isSunrise) |
|
|
|
|
|
mSendIvData.resetYieldDay(); |
|
|
|
|
|
|
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -239,10 +240,6 @@ class PubMqtt { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void setZeroValuesEnable(void) { |
|
|
|
|
|
mZeroValues = true; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private: |
|
|
private: |
|
|
void onConnect(bool sessionPreset) { |
|
|
void onConnect(bool sessionPreset) { |
|
|
DPRINTLN(DBG_INFO, F("MQTT connected")); |
|
|
DPRINTLN(DBG_INFO, F("MQTT connected")); |
|
@ -592,8 +589,7 @@ class PubMqtt { |
|
|
if(mSendList.empty()) |
|
|
if(mSendList.empty()) |
|
|
return; |
|
|
return; |
|
|
|
|
|
|
|
|
mSendIvData.start(mZeroValues); |
|
|
mSendIvData.start(); |
|
|
mZeroValues = false; |
|
|
|
|
|
mLastAnyAvail = anyAvail; |
|
|
mLastAnyAvail = anyAvail; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -612,7 +608,6 @@ class PubMqtt { |
|
|
std::array<bool, MAX_NUM_INVERTERS> mSendAlarm{}; |
|
|
std::array<bool, MAX_NUM_INVERTERS> mSendAlarm{}; |
|
|
subscriptionCb mSubscriptionCb; |
|
|
subscriptionCb mSubscriptionCb; |
|
|
bool mLastAnyAvail; |
|
|
bool mLastAnyAvail; |
|
|
bool mZeroValues; |
|
|
|
|
|
InverterStatus mLastIvState[MAX_NUM_INVERTERS]; |
|
|
InverterStatus mLastIvState[MAX_NUM_INVERTERS]; |
|
|
uint32_t mIvLastRTRpub[MAX_NUM_INVERTERS]; |
|
|
uint32_t mIvLastRTRpub[MAX_NUM_INVERTERS]; |
|
|
uint16_t mIntervalTimeout; |
|
|
uint16_t mIntervalTimeout; |
|
|