Suport for many OWM monitoring

This commit is contained in:
2022-04-08 20:46:49 +02:00
parent 3e858fa48e
commit 46734d537f
2 changed files with 41 additions and 21 deletions

View File

@@ -47,7 +47,7 @@ emyPxgcYxn/eR44/KJ4EBs+lVDR3veyJm+kXQ99b21/+jh5Xos1AnX5iItreGCc=\n\
class Influx {
public:
Influx(Sensor* _sensor, OWM* _owm0, OWM* _owm1): sensor(_sensor), owm0(_owm0), owm1(_owm1) {}
Influx(Sensor* _sensor, OWM* _owm[]): sensor(_sensor), owm(_owm) {}
void check(){
if (client.validateConnection()) {
@@ -60,14 +60,20 @@ class Influx {
}
void record(){
if(owm0) record_weather(owm0);
if(owm1) record_weather(owm1);
uint8_t i = 0;
while(owm && owm[i] != NULL){
record_weather(owm[i]);
++i;
}
if(sensor) record_local();
}
void record(bool w, bool s){
if(owm0 && w) record_weather(owm0);
if(owm1 && w) record_weather(owm1);
uint8_t i = 0;
while(w && owm && owm[i] != NULL){
record_weather(owm[i]);
++i;
}
if(sensor && s) record_local();
}
@@ -155,8 +161,7 @@ class Influx {
private:
OWM* owm0;
OWM* owm1;
OWM** owm;
Sensor* sensor;
InfluxDBClient client = InfluxDBClient(INFLUXDB_URL, INFLUXDB_ORG, INFLUXDB_BUCKET, INFLUXDB_TOKEN, cert);