fix topics

This commit is contained in:
Laila van Reenen 2025-01-30 12:14:49 +01:00
parent 53beba07fa
commit 111e998d89
Signed by: LailaTheElf
GPG Key ID: 8A3EF0226518C12D
3 changed files with 9 additions and 9 deletions

2
Cargo.lock generated
View File

@ -289,7 +289,7 @@ dependencies = [
[[package]] [[package]]
name = "mqttAutomation" name = "mqttAutomation"
version = "1.1.1" version = "1.1.2"
dependencies = [ dependencies = [
"crossbeam", "crossbeam",
"json", "json",

View File

@ -1,6 +1,6 @@
[package] [package]
name = "mqttAutomation" name = "mqttAutomation"
version = "1.1.1" version = "1.1.2"
edition = "2021" edition = "2021"
[dependencies] [dependencies]

View File

@ -114,12 +114,12 @@ impl Automation {
impl mqtt_client::MqttTool for Automation { impl mqtt_client::MqttTool for Automation {
fn new(client: rumqttc::Client, tx: Sender<mqtt_client::MqttMessage>) -> Automation { fn new(client: rumqttc::Client, tx: Sender<mqtt_client::MqttMessage>) -> Automation {
match client.subscribe("clock/hour", rumqttc::QoS::AtMostOnce) { match client.subscribe("clock/time/hour", rumqttc::QoS::AtMostOnce) {
Err(e) => println!("ERROR: main: faild to subscribe to clock/hour ({})", e), Err(e) => println!("ERROR: main: faild to subscribe to clock/time/hour ({})", e),
Ok(_) => {} Ok(_) => {}
} }
match client.subscribe("clock/dow", rumqttc::QoS::AtMostOnce) { match client.subscribe("clock/date/dow", rumqttc::QoS::AtMostOnce) {
Err(e) => println!("ERROR: main: faild to subscribe to clock/dow ({})", e), Err(e) => println!("ERROR: main: faild to subscribe to clock/date/dow ({})", e),
Ok(_) => {} Ok(_) => {}
} }
match client.subscribe("/cool/devices/KNMITemp/values", rumqttc::QoS::AtMostOnce) { 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) { fn rx(&mut self, message: mqtt_client::MqttMessage) {
println!("INFO : mqtt_automation: {}: {}", message.topic, message.payload); 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) { if message.payload.eq("7") && (self.clock_dow >= 1 && self.clock_dow <= 7) {
self.lamp01_set(true); 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::<u8>() { match message.payload.parse::<u8>() {
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 Ok(n) => self.clock_dow = n
} }