-
-
Notifications
You must be signed in to change notification settings - Fork 79
Upgrade mqtt #1311
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
base: main
Are you sure you want to change the base?
Upgrade mqtt #1311
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR upgrades the MQTT.NET dependency to v5 and refactors the MqttEntityManager extension to use the new raw IMqttClient
APIs.
- Bumped MQTTnet (and related) package versions across projects.
- Replaced all
IManagedMqttClient
usages withIMqttClient
, updating factories, subscriber/sender logic, and connection handling. - Adjusted integration and unit tests to align with the new client API and payload handling.
Reviewed Changes
Copilot reviewed 33 out of 33 changed files in this pull request and generated 3 comments.
Show a summary per file
File | Description |
---|---|
src/Extensions/NetDaemon.Extensions.MqttEntityManager/*.csproj | Upgraded MQTTnet package to 5.x and removed managed-client refs. |
src/Extensions/NetDaemon.Extensions.MqttEntityManager/MqttFactoryFactory.cs | Switched factory to produce IMqttClient . |
src/Extensions/NetDaemon.Extensions.MqttEntityManager/MqttClientOptionsFactory.cs | Updated options builder to use MqttClientOptionsBuilder . |
src/Extensions/NetDaemon.Extensions.MqttEntityManager/MessageSubscriber.cs | Swapped to SubscribeAsync with new options; streamlined payload parsing. |
src/Extensions/NetDaemon.Extensions.MqttEntityManager/MessageSender.cs | Replaced EnqueueAsync with PublishAsync on IMqttClient . |
src/Extensions/NetDaemon.Extensions.MqttEntityManager/AssuredMqttConnection.cs | Reworked connection loop for raw client with retry/cancellation. |
src/Client/NetDaemon.HassClient.Tests/**/*Tests.cs | Updated tests to use ReadOnlySequence<byte> payload helpers. |
Comments suppressed due to low confidence (2)
src/Extensions/NetDaemon.Extensions.MqttEntityManager/MqttFactoryFactory.cs:17
- The class
MqttClientFactory
does not exist in MQTTnet v5; you should usenew MqttFactory().CreateMqttClient()
instead.
return new MqttClientFactory().CreateMqttClient();
src/Extensions/NetDaemon.Extensions.MqttEntityManager/AssuredMqttConnection.cs:138
- Extraneous quotes after the closing brace are causing a syntax error; remove the stray
''
.
}''
src/Extensions/NetDaemon.Extensions.MqttEntityManager/MessageSubscriber.cs
Outdated
Show resolved
Hide resolved
|
||
mqttSetup.LastPublishedMessage.Topic.Should().Be("homeassistant/domain/sensor/availability"); | ||
payload.Should().Be("up"); | ||
} | ||
|
||
|
||
private static byte[] ConvertPayloadToArray(ReadOnlySequence<byte> payload) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The ConvertPayloadToArray
helper is duplicated across multiple test classes; consider moving it into a shared test utility to reduce duplication.
Copilot uses AI. Check for mistakes.
src/Extensions/NetDaemon.Extensions.MqttEntityManager/AssuredMqttConnection.cs
Show resolved
Hide resolved
…ubscriber.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@skotl would you mind check this out. As far as I can tell it works when I run it locally. It would be great if you could manually confirm it works. At some point I will add an integration tests for this too. |
Breaking change
Proposed change
Trying to upgrade the mqtt manager to the latest breaking version of MQTTNet.
Type of change
Additional information
This PR is far from ready. Needs manual testing and also add some integration tests imo. Like reconnect logic.
Checklist
If user exposed functionality or configuration are added/changed: