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]]
name = "mqttAutomation"
version = "1.1.1"
version = "1.1.2"
dependencies = [
"crossbeam",
"json",

View File

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

View File

@ -114,12 +114,12 @@ impl Automation {
impl mqtt_client::MqttTool for Automation {
fn new(client: rumqttc::Client, tx: Sender<mqtt_client::MqttMessage>) -> 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::<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
}