Skip to content

Commit 2f66c2a

Browse files
committed
Added setting sensorInterval
1 parent 2dcbc48 commit 2f66c2a

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

library.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "HomieNodeCollection",
3-
"version": "0.9.0",
3+
"version": "0.9.1",
44
"keywords": "Homie, sensor, temperature, display",
55
"description": "Collection of Node implementations for the Homie-ESP8266 library.",
66
"repository": {

src/SensorNode.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212

1313
HomieSetting<double> SensorNode::tempOffset ("TempAdj", "offset to add to temperature");
14+
HomieSetting<long> SensorNode::interval("sensorInterval", "interval how often to read sensors");
1415

1516

1617
SensorNode::SensorNode() :
@@ -28,6 +29,10 @@ SensorNode::SensorNode() :
2829
tempOffset.setDefaultValue(0).setValidator([] (double candidate) {
2930
return ((!isnan(candidate) || candidate == 0.0) && candidate > -15.0 && candidate < 15.0);
3031
});
32+
interval.setDefaultValue(30000).setValidator([] (long candidate) {
33+
return (candidate > 1000 && candidate < 600000);
34+
});
35+
3136

3237
advertise("degrees");
3338
advertise("rel%");
@@ -48,7 +53,7 @@ void SensorNode::setup() {
4853
}
4954

5055
void SensorNode::loop() {
51-
if (millis() - lastLoop8000ms >= 30000UL || lastLoop8000ms == 0) {
56+
if (millis() - lastLoop8000ms >= interval.get() || lastLoop8000ms == 0) {
5257
lastLoop8000ms = millis();
5358
#ifdef SENSORS_BMP180_ATTACHED
5459
temp = Sensors::getThermometer()->getTemperature();

src/SensorNode.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class SensorNode: public HomieNode {
3030
private:
3131
unsigned long lastLoop8000ms;
3232
static HomieSetting<double> tempOffset;
33+
static HomieSetting<long> interval;
3334

3435
#ifndef SENSORS_BMP180_ATTACHED
3536
HTU21D htu;

0 commit comments

Comments
 (0)