Skip to content

Commit

Permalink
ElectricityMeter: fix refreshRate setting, so it will also affect how
Browse files Browse the repository at this point in the history
often extended value is send with measurements
  • Loading branch information
klew committed Sep 30, 2024
1 parent 7587c5f commit 0a4208e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/supla/sensor/electricity_meter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ void Supla::Sensor::ElectricityMeter::updateChannelValues() {
}

// Prepare extended channel value
if (lastChannelUpdateTime == 0 || millis() - lastChannelUpdateTime >= 5000) {
if (lastChannelUpdateTime == 0 ||
millis() - lastChannelUpdateTime >= refreshRateSec * 1000) {
lastChannelUpdateTime = millis();
srpc_evtool_v2_emextended2extended(&emValue, extChannel.getExtValue());
extChannel.setNewValue(emValue);
Expand Down Expand Up @@ -637,6 +638,7 @@ const Supla::Channel *Supla::Sensor::ElectricityMeter::getChannel() const {
}

void Supla::Sensor::ElectricityMeter::setRefreshRate(unsigned int sec) {
SUPLA_LOG_INFO("EM: setRefreshRate: %d", sec);
refreshRateSec = sec;
if (refreshRateSec == 0) {
refreshRateSec = 1;
Expand Down

0 comments on commit 0a4208e

Please sign in to comment.