From 3b286d277d284ce44126c931388a7f339dad4aef Mon Sep 17 00:00:00 2001 From: Jimmy White Date: Tue, 20 Feb 2024 14:15:25 +0000 Subject: [PATCH] Fixes for MQTT connectivity in #10 --- MainWindow.xaml.cs | 3 +++ TEAMS2HA.csproj | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs index 9870fa4..bb3ba8d 100644 --- a/MainWindow.xaml.cs +++ b/MainWindow.xaml.cs @@ -464,6 +464,7 @@ private async void ReestablishConnections() if (!mqttClientWrapper.IsConnected) { await mqttClientWrapper.ConnectAsync(); + await mqttClientWrapper.SubscribeAsync("homeassistant/switch/+/set", MqttQualityOfServiceLevel.AtLeastOnce); SetupMqttSensors(); } if (!_teamsClient.IsConnected) @@ -588,6 +589,7 @@ private async void CheckMqttConnection() { Log.Debug("CheckMqttConnection: MQTT Client Not Connected. Attempting reconnection."); await mqttClientWrapper.ConnectAsync(); + await mqttClientWrapper.SubscribeAsync("homeassistant/switch/+/set", MqttQualityOfServiceLevel.AtLeastOnce); UpdateConnectionStatus(); } } @@ -1076,6 +1078,7 @@ private async void TestMQTTConnection_Click(object sender, RoutedEventArgs e) } UpdateStatusMenuItems(); Log.Debug("TestMQTTConnection_Click: MQTT Client Connected in TestMQTTConnection_Click"); + await mqttClientWrapper.SubscribeAsync("homeassistant/switch/+/set", MqttQualityOfServiceLevel.AtLeastOnce); return; // Exit the method if connected } catch (Exception ex) diff --git a/TEAMS2HA.csproj b/TEAMS2HA.csproj index 5459bd0..ea5f5c3 100644 --- a/TEAMS2HA.csproj +++ b/TEAMS2HA.csproj @@ -5,8 +5,8 @@ net7.0-windows enable true - 1.1.0.280 - 1.1.0.280 + 1.1.0.282 + 1.1.0.282 Assets\Square150x150Logo.scale-200.ico Teams2HA Square150x150Logo.scale-200.png