Formatting
This commit is contained in:
@@ -4,9 +4,9 @@ mod mode;
|
||||
mod write;
|
||||
|
||||
use anyhow::Result;
|
||||
use chrono::Utc;
|
||||
use config::Config;
|
||||
use log::info;
|
||||
use chrono::Utc;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<()> {
|
||||
@@ -14,9 +14,8 @@ async fn main() -> Result<()> {
|
||||
|
||||
let settings: input::Input = fetch_settings()?;
|
||||
|
||||
match settings.program_mode
|
||||
{
|
||||
mode::Mode::ReadWeatherData => read_weather_data(&settings).await?
|
||||
match settings.program_mode {
|
||||
mode::Mode::ReadWeatherData => read_weather_data(&settings).await?,
|
||||
};
|
||||
|
||||
Ok(())
|
||||
@@ -24,14 +23,27 @@ async fn main() -> Result<()> {
|
||||
|
||||
async fn read_weather_data(settings: &input::Input) -> Result<()> {
|
||||
info!("Start fetching weather data...");
|
||||
let result = fetch::fetch_weather_data(&settings.weather_api_base_url, &settings.latitude, &settings.longitude, &settings.weather_api_key, &Utc::now()).await?;
|
||||
let result = fetch::fetch_weather_data(
|
||||
&settings.weather_api_base_url,
|
||||
&settings.latitude,
|
||||
&settings.longitude,
|
||||
&settings.weather_api_key,
|
||||
&Utc::now(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
info!("Start writing weather data...");
|
||||
let map = write::WeatherReading {
|
||||
wind_speed: result.wind.speed,
|
||||
time: Utc::now(),
|
||||
};
|
||||
write::write_weather_data(map, &settings.influx_db_base_url, "homeassistant", &settings.influx_db_token).await?;
|
||||
write::write_weather_data(
|
||||
map,
|
||||
&settings.influx_db_base_url,
|
||||
"homeassistant",
|
||||
&settings.influx_db_token,
|
||||
)
|
||||
.await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user