Improved how mqtt topics are handled
This commit is contained in:
@@ -4,7 +4,7 @@ use std::net::{TcpStream, SocketAddr, Ipv4Addr};
|
||||
use bytes::{BufMut, Buf};
|
||||
use google_home::errors::{ErrorCode, DeviceError};
|
||||
use google_home::traits::{self, OnOff};
|
||||
use rumqttc::AsyncClient;
|
||||
use rumqttc::{AsyncClient, matches};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tracing::{error, warn};
|
||||
use pollster::FutureExt as _;
|
||||
@@ -225,7 +225,7 @@ impl Device for AudioSetup {
|
||||
|
||||
impl OnMqtt for AudioSetup {
|
||||
fn on_mqtt(&mut self, message: &rumqttc::Publish) {
|
||||
if message.topic != self.mqtt.topic {
|
||||
if !matches(&message.topic, &self.mqtt.topic) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use std::time::Duration;
|
||||
|
||||
use pollster::FutureExt;
|
||||
use rumqttc::AsyncClient;
|
||||
use rumqttc::{AsyncClient, matches};
|
||||
use tokio::task::JoinHandle;
|
||||
use tracing::{error, debug, warn};
|
||||
|
||||
@@ -50,7 +50,7 @@ impl OnPresence for ContactSensor {
|
||||
|
||||
impl OnMqtt for ContactSensor {
|
||||
fn on_mqtt(&mut self, message: &rumqttc::Publish) {
|
||||
if message.topic != self.mqtt.topic {
|
||||
if !matches(&message.topic, &self.mqtt.topic) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ use std::time::Duration;
|
||||
|
||||
use google_home::errors::ErrorCode;
|
||||
use google_home::{GoogleHomeDevice, device, types::Type, traits};
|
||||
use rumqttc::{AsyncClient, Publish};
|
||||
use rumqttc::{AsyncClient, Publish, matches};
|
||||
use tracing::{debug, trace, error};
|
||||
use tokio::task::JoinHandle;
|
||||
use pollster::FutureExt as _;
|
||||
@@ -48,7 +48,7 @@ impl Device for IkeaOutlet {
|
||||
impl OnMqtt for IkeaOutlet {
|
||||
fn on_mqtt(&mut self, message: &Publish) {
|
||||
// Update the internal state based on what the device has reported
|
||||
if message.topic != self.mqtt.topic {
|
||||
if !matches(&message.topic, &self.mqtt.topic) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use google_home::{GoogleHomeDevice, types::Type, device, traits::{self, Scene}, errors::{ErrorCode, DeviceError}};
|
||||
use tracing::{debug, error};
|
||||
use rumqttc::{AsyncClient, Publish};
|
||||
use rumqttc::{AsyncClient, Publish, matches};
|
||||
use pollster::FutureExt as _;
|
||||
|
||||
use crate::{config::{InfoConfig, MqttDeviceConfig}, mqtt::{OnMqtt, ActivateMessage}};
|
||||
@@ -31,7 +31,7 @@ impl Device for WakeOnLAN {
|
||||
|
||||
impl OnMqtt for WakeOnLAN {
|
||||
fn on_mqtt(&mut self, message: &Publish) {
|
||||
if message.topic != self.mqtt.topic {
|
||||
if !matches(&message.topic, &self.mqtt.topic) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user