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

Feature: ignore availability topic option for sensors #22

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
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
Next Next commit
cleanup
amadeo-alex committed Aug 26, 2023
commit 93071c4eea6403e0dbcb375d43f82a5fb0344d11
Original file line number Diff line number Diff line change
@@ -59,7 +59,7 @@ internal static async Task UnpublishAllCommands()
foreach (var command in Variables.Commands)
{
await command.UnPublishAutoDiscoveryConfigAsync();
await Variables.MqttManager.UnubscribeAsync(command);
await Variables.MqttManager.UnsubscribeAsync(command);
command.ClearAutoDiscoveryConfig();
count++;
}
@@ -188,7 +188,7 @@ internal static async Task<bool> StoreAsync(List<ConfiguredCommand> commands, Li

// remove and unregister
await abstractCommand.UnPublishAutoDiscoveryConfigAsync();
await Variables.MqttManager.UnubscribeAsync(abstractCommand);
await Variables.MqttManager.UnsubscribeAsync(abstractCommand);
Variables.Commands.RemoveAt(Variables.Commands.FindIndex(x => x.Id == abstractCommand.Id));

Log.Information("[COMMANDS] Removed command: {command}", abstractCommand.Name);
@@ -220,7 +220,7 @@ internal static async Task<bool> StoreAsync(List<ConfiguredCommand> commands, Li
Log.Information("[COMMANDS] Command changed, re-registering as new entity: {old} to {new}", Variables.Commands[currentCommandIndex].Name, abstractCommand.Name);

await Variables.Commands[currentCommandIndex].UnPublishAutoDiscoveryConfigAsync();
await Variables.MqttManager.UnubscribeAsync(Variables.Commands[currentCommandIndex]);
await Variables.MqttManager.UnsubscribeAsync(Variables.Commands[currentCommandIndex]);
await Variables.MqttManager.SubscribeAsync(abstractCommand);
}

252 changes: 132 additions & 120 deletions src/HASS.Agent.Staging/HASS.Agent.Satellite.Service/MQTT/MqttManager.cs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -22,7 +22,7 @@ public interface IMqttManager
Task ClearDeviceConfigAsync();
void Disconnect();
Task SubscribeAsync(AbstractCommand command);
Task UnubscribeAsync(AbstractCommand command);
Task UnsubscribeAsync(AbstractCommand command);

Task SubscribeNotificationsAsync();

6 changes: 3 additions & 3 deletions src/HASS.Agent.Staging/HASS.Agent/Commands/CommandsManager.cs
Original file line number Diff line number Diff line change
@@ -64,7 +64,7 @@ internal static async Task UnpublishAllCommands()
foreach (var command in Variables.Commands)
{
await command.UnPublishAutoDiscoveryConfigAsync();
await Variables.MqttManager.UnubscribeAsync(command);
await Variables.MqttManager.UnsubscribeAsync(command);
}
}

@@ -212,7 +212,7 @@ internal static async Task<bool> StoreAsync(List<ConfiguredCommand> commands, Li
{
// remove and unregister
await abstractCommand.UnPublishAutoDiscoveryConfigAsync();
await Variables.MqttManager.UnubscribeAsync(abstractCommand);
await Variables.MqttManager.UnsubscribeAsync(abstractCommand);
Variables.Commands.RemoveAt(Variables.Commands.FindIndex(x => x.Id == abstractCommand.Id));

Log.Information("[COMMANDS] Removed command: {command}", abstractCommand.Name);
@@ -242,7 +242,7 @@ internal static async Task<bool> StoreAsync(List<ConfiguredCommand> commands, Li
Log.Information("[COMMANDS] Command changed, re-registering as new entity: {old} to {new}", Variables.Commands[currentCommandIndex].Name, abstractCommand.Name);

await Variables.Commands[currentCommandIndex].UnPublishAutoDiscoveryConfigAsync();
await Variables.MqttManager.UnubscribeAsync(Variables.Commands[currentCommandIndex]);
await Variables.MqttManager.UnsubscribeAsync(Variables.Commands[currentCommandIndex]);
await Variables.MqttManager.SubscribeAsync(abstractCommand);
}

322 changes: 174 additions & 148 deletions src/HASS.Agent.Staging/HASS.Agent/MQTT/MqttManager.cs

Large diffs are not rendered by default.