Skip to content

Commit

Permalink
Merge pull request #18 from jimmyeao/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
jimmyeao authored Dec 18, 2023
2 parents ac20187 + 9c6ad7d commit ff42502
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 31 deletions.
2 changes: 1 addition & 1 deletion MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
<TextBlock Text="MQTT host address:" Width="200" VerticalAlignment="Center"/>
<TextBox x:Name="MqttAddress" Width="300" Margin="10,0,0,0" Style="{DynamicResource MaterialDesignTextBox}"/>
<TextBlock Text="MQTT port:" Width="100" VerticalAlignment="Center" Margin="10,0,0,0"/>
<TextBox x:Name="MqttPort" Width="80" Margin="10,0,0,0" Style="{DynamicResource MaterialDesignTextBox}"/>
<TextBox x:Name="MqttPort" Width="80" Margin="10,0,0,0" Style="{DynamicResource MaterialDesignTextBox}" Text="1883"/>
</StackPanel>

<StackPanel Grid.Row="3" Margin="0,10,0,0" Orientation="Horizontal">
Expand Down
62 changes: 32 additions & 30 deletions MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ private void LoadSettingsFromFile()
}
else
{
// Set default values if the file does not exist
this.MqttPort = "1883"; // Default MQTT port
}
}

Expand Down Expand Up @@ -294,17 +294,17 @@ public MainWindow()
#endregion Public Constructors

#region Public Methods
public static List<string> GetEntityNames()
{
// Example: return a list of entity names based on the sensors and switches
return new List<string>
{
"Teams Mute Switch",
"Teams Video Switch",
"Teams Hand Raised Sensor",
// Add more entities as per your application's functionality
};
}
//public static List<string> GetEntityNames()
//{
// // Example: return a list of entity names based on the sensors and switches
// return new List<string>
// {
// "Teams Mute Switch",
// "Teams Video Switch",
// "Teams Hand Raised Sensor",
// // Add more entities as per your application's functionality
// };
//}
public async Task InitializeConnections()
{
await InitializeMQTTConnection();
Expand Down Expand Up @@ -903,24 +903,24 @@ private async Task PublishConfigurations(MeetingUpdate meetingUpdate, AppSetting

}

private async Task PublishDiscoveryMessages()
{
var muteSwitchConfig = new
{
name = "Teams Mute",
unique_id = "TEAMS2HA_mute",
state_topic = "TEAMS2HA/TEAMS/mute",
command_topic = "TEAMS2HA/TEAMS/mute/set",
payload_on = "true",
payload_off = "false",
device = new { identifiers = new[] { "TEAMS2HA" }, name = "Teams Integration", manufacturer = "Your Company" }
};

string muteConfigTopic = "homeassistant/switch/TEAMS2HA/mute/config";
await mqttClientWrapper.PublishAsync(muteConfigTopic, JsonConvert.SerializeObject(muteSwitchConfig));

// Repeat for other entities like video
}
//private async Task PublishDiscoveryMessages()
//{
// var muteSwitchConfig = new
// {
// name = "Teams Mute",
// unique_id = "TEAMS2HA_mute",
// state_topic = "TEAMS2HA/TEAMS/mute",
// command_topic = "TEAMS2HA/TEAMS/mute/set",
// payload_on = "true",
// payload_off = "false",
// device = new { identifiers = new[] { "TEAMS2HA" }, name = "Teams Integration", manufacturer = "Your Company" }
// };

// string muteConfigTopic = "homeassistant/switch/TEAMS2HA/mute/config";
// await mqttClientWrapper.PublishAsync(muteConfigTopic, JsonConvert.SerializeObject(muteSwitchConfig));

// // Repeat for other entities like video
//}

private bool SaveSettings()
{
Expand Down Expand Up @@ -991,6 +991,8 @@ private async void SetupMqttSensors()

// Call PublishConfigurations with the dummy MeetingUpdate
await PublishConfigurations(dummyMeetingUpdate, _settings);


}

private async void TeamsClient_TeamsUpdateReceived(object sender, WebSocketClient.TeamsUpdateEventArgs e)
Expand Down

0 comments on commit ff42502

Please sign in to comment.