From 111e998d8945cb68228a143b39c18ea92ec17ca6 Mon Sep 17 00:00:00 2001 From: LailaTheElf Date: Thu, 30 Jan 2025 12:14:49 +0100 Subject: [PATCH] fix topics --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/main.rs | 14 +++++++------- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index eaf02d9..a7da4ee 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -289,7 +289,7 @@ dependencies = [ [[package]] name = "mqttAutomation" -version = "1.1.1" +version = "1.1.2" dependencies = [ "crossbeam", "json", diff --git a/Cargo.toml b/Cargo.toml index c1fc7fd..a0d986e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mqttAutomation" -version = "1.1.1" +version = "1.1.2" edition = "2021" [dependencies] diff --git a/src/main.rs b/src/main.rs index cb43f50..cbee677 100644 --- a/src/main.rs +++ b/src/main.rs @@ -114,12 +114,12 @@ impl Automation { impl mqtt_client::MqttTool for Automation { fn new(client: rumqttc::Client, tx: Sender) -> Automation { - match client.subscribe("clock/hour", rumqttc::QoS::AtMostOnce) { - Err(e) => println!("ERROR: main: faild to subscribe to clock/hour ({})", e), + match client.subscribe("clock/time/hour", rumqttc::QoS::AtMostOnce) { + Err(e) => println!("ERROR: main: faild to subscribe to clock/time/hour ({})", e), Ok(_) => {} } - match client.subscribe("clock/dow", rumqttc::QoS::AtMostOnce) { - Err(e) => println!("ERROR: main: faild to subscribe to clock/dow ({})", e), + match client.subscribe("clock/date/dow", rumqttc::QoS::AtMostOnce) { + Err(e) => println!("ERROR: main: faild to subscribe to clock/date/dow ({})", e), Ok(_) => {} } match client.subscribe("/cool/devices/KNMITemp/values", rumqttc::QoS::AtMostOnce) { @@ -135,7 +135,7 @@ impl mqtt_client::MqttTool for Automation { fn rx(&mut self, message: mqtt_client::MqttMessage) { println!("INFO : mqtt_automation: {}: {}", message.topic, message.payload); - if message.topic.eq("clock/hour") { + if message.topic.eq("clock/time/hour") { if message.payload.eq("7") && (self.clock_dow >= 1 && self.clock_dow <= 7) { self.lamp01_set(true); @@ -153,10 +153,10 @@ impl mqtt_client::MqttTool for Automation { } } - else if message.topic.eq("clock/dow") { + else if message.topic.eq("clock/date/dow") { match message.payload.parse::() { - Err(e) => println!("ERROR: mqtt_automation: clock/dow has invalid payload ({:?})", e), + Err(e) => println!("ERROR: mqtt_automation: clock/date/dow has invalid payload ({:?})", e), Ok(n) => self.clock_dow = n }