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