Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #18

Merged
merged 3 commits into from
Dec 18, 2023
Merged

Dev #18

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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