diff --git a/Cargo.lock b/Cargo.lock index e406282..ba69ffd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -15,12 +15,27 @@ dependencies = [ "zerocopy", ] +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + [[package]] name = "atomic-waker" version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" +[[package]] +name = "autocfg" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53" + [[package]] name = "aws-lc-rs" version = "1.17.0" @@ -97,6 +112,19 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" +[[package]] +name = "chrono" +version = "0.4.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1aa79e62e7697b8e29b513a68abacf485adcd1fe8284a4316c5ae868e6633327" +dependencies = [ + "iana-time-zone", + "js-sys", + "num-traits", + "wasm-bindgen", + "windows-link", +] + [[package]] name = "cmake" version = "0.1.58" @@ -553,6 +581,30 @@ dependencies = [ "tracing", ] +[[package]] +name = "iana-time-zone" +version = "0.1.65" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e31bc9ad994ba00e440a8aa5c9ef0ec67d5cb5e5cb0cc7f8b744a35b389cc470" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "log", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + [[package]] name = "icu_collections" version = "2.2.0" @@ -776,6 +828,15 @@ version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086" +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + [[package]] name = "once_cell" version = "1.21.4" @@ -2003,6 +2064,7 @@ dependencies = [ name = "weather" version = "0.1.0" dependencies = [ + "chrono", "reqwest 0.13.4", "rumqttc", "scraper 0.27.0", @@ -2054,12 +2116,65 @@ dependencies = [ "rustls-pki-types", ] +[[package]] +name = "windows-core" +version = "0.62.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb" +dependencies = [ + "windows-implement", + "windows-interface", + "windows-link", + "windows-result", + "windows-strings", +] + +[[package]] +name = "windows-implement" +version = "0.60.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "windows-interface" +version = "0.59.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "windows-link" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" +[[package]] +name = "windows-result" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-strings" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091" +dependencies = [ + "windows-link", +] + [[package]] name = "windows-sys" version = "0.52.0" diff --git a/Cargo.toml b/Cargo.toml index fa9183d..46c0672 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,6 +12,7 @@ rumqttc = "0.25.1" serde = { version = "1.0.228", features = ["derive"] } serde_derive = "1.0.228" serde_json = "1.0.149" +chrono = "0.4.45" # Raspberrypi # cross build --release --target aarch64-unknown-linux-gnu diff --git a/src/main.rs b/src/main.rs index 02e8278..bc97090 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,5 @@ mod weather_data; - +use chrono::{Local}; use crate::weather_data::{DwdWeather, MucWeather}; use rumqttc::{AsyncClient, EventLoop, MqttOptions, QoS}; use scraper::{Html as HtmlScraper, Selector}; @@ -43,6 +43,7 @@ async fn main() { } pub async fn meteo_weather(latitude: f64, longitude: f64) -> Result { + let response = trpl::get(METEO_MUNICH_API_URL).await; let response_text = response.text().await; @@ -51,14 +52,14 @@ pub async fn meteo_weather(latitude: f64, longitude: f64) -> Result Result Result Result Result (AsyncClient, EventLoop) { let mut mqttoptions = MqttOptions::new("rust-mqqt", "192.168.1.37", 1883); mqttoptions diff --git a/src/weather_data.rs b/src/weather_data.rs index b027b02..e954c7e 100644 --- a/src/weather_data.rs +++ b/src/weather_data.rs @@ -10,6 +10,8 @@ pub struct MucWeather { pub(crate) pressure: f64, #[serde(rename = "Precipitation")] pub(crate) precipitation: f64, + #[serde(rename = "Date")] + pub(crate) date: String, } #[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]