FIX: added missing sensor->loopBeforeValues()
This commit is contained in:
parent
7cac90875f
commit
ad4e425895
@ -50,12 +50,17 @@ private:
|
||||
auto sensorIndex = 0;
|
||||
Sensor *sensor;
|
||||
while ((sensor = getSensor(sensorIndex++)) != nullptr) {
|
||||
auto valueIndex = 0;
|
||||
Value *value;
|
||||
while ((value = sensor->getValue(valueIndex++)) != nullptr) {
|
||||
if (value->loop()) {
|
||||
cache.put(timestamp, cacheIndex++, value->getCurrentValue());
|
||||
}
|
||||
sensor->loopBeforeValues();
|
||||
loopValues(timestamp, cacheIndex, sensor);
|
||||
}
|
||||
}
|
||||
|
||||
void loopValues(const time_t timestamp, int& cacheIndex, Sensor *sensor) {
|
||||
auto valueIndex = 0;
|
||||
Value *value;
|
||||
while ((value = sensor->getValue(valueIndex++)) != nullptr) {
|
||||
if (value->loop()) {
|
||||
cache.put(timestamp, cacheIndex++, value->getCurrentValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -52,15 +52,16 @@ public:
|
||||
update(NAN);
|
||||
}
|
||||
|
||||
const auto now = time(nullptr);
|
||||
const auto dueToNAN = isnan(currentValue) != isnan(sentValue);
|
||||
const auto dueToThreshold = abs(sentValue - currentValue) >= threshold;
|
||||
const auto dueToTime = sentInterval != 0 && sentInterval != time(nullptr) / overdueSeconds;
|
||||
const auto dueToTime = sentInterval != 0 && sentInterval != now / overdueSeconds;
|
||||
const auto changed = dueToNAN || dueToThreshold || dueToTime;
|
||||
if (changed) {
|
||||
mqttPublish(name + "/retain", String(currentValue), RETAIN);
|
||||
websocketSendAll(toJson(false));
|
||||
sentValue = currentValue;
|
||||
sentInterval = time(nullptr) / overdueSeconds;
|
||||
sentInterval = now / overdueSeconds;
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user