fix topics
This commit is contained in:
parent
53beba07fa
commit
111e998d89
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -289,7 +289,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "mqttAutomation"
|
||||
version = "1.1.1"
|
||||
version = "1.1.2"
|
||||
dependencies = [
|
||||
"crossbeam",
|
||||
"json",
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "mqttAutomation"
|
||||
version = "1.1.1"
|
||||
version = "1.1.2"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
|
||||
14
src/main.rs
14
src/main.rs
@ -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
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user