v0.14.21
This commit is contained in:
+17
-1
@@ -4,7 +4,9 @@ use reqwest::Client;
|
||||
use serde_json::Value;
|
||||
use std::collections::HashMap;
|
||||
|
||||
use crate::models::{EnergyReading, HaReading, InfluxDbSettings, NetworkReading, Reading, ZoneReading};
|
||||
use crate::models::{
|
||||
EnergyReading, HaReading, InfluxDbSettings, NetworkReading, Reading, ZoneReading,
|
||||
};
|
||||
|
||||
const DEVICE_MEASUREMENT: &str = "gree_device";
|
||||
const ZONE_MEASUREMENT: &str = "gree_zone";
|
||||
@@ -16,3 +18,17 @@ const NETWORK_MEASUREMENT: &str = "gree_network";
|
||||
include!("influxdb/write.rs");
|
||||
include!("influxdb/query.rs");
|
||||
include!("influxdb/codec.rs");
|
||||
|
||||
pub async fn test_connection(client: &Client, settings: &InfluxDbSettings) -> Result<()> {
|
||||
validate(settings)?;
|
||||
if settings.version == "1" {
|
||||
query_v1(client, settings, "SHOW MEASUREMENTS LIMIT 1").await?;
|
||||
} else {
|
||||
let query = format!(
|
||||
"from(bucket: {}) |> range(start: -1m) |> limit(n: 1)",
|
||||
flux_string(&settings.bucket)
|
||||
);
|
||||
query_v2(client, settings, &query).await?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user