17 Commits

Author SHA1 Message Date
epenet
a13911e00e
Rename test helpers module in mqtt (#140375)
* Rename test helpers module in mqtt

* missed a file
2025-03-11 18:00:51 +01:00
Jan Bouwhuis
6284a83a34
Fix client_id not generated when connecting to the MQTT broker (#140264)
Fix client_id not generated when connecting to the MQTT broker
2025-03-10 11:04:49 +01:00
skobow
f8ffbf0506
Set clean_start=True on connect to MQTT broker (#136026)
* Addresses #135443: Set  on connect.

* Make clean start implementation compatible with v2 API

* Add tests

* Do not pass default value for `clean_start` on_connect

* Revert "Do not pass default value for `clean_start` on_connect"

This reverts commit 75806736cf511a6d6b6496454843de34f05f7758.

* Use partial top pass kwargs to mqtt client connect

---------

Co-authored-by: Jan Bouwhuis <jbouwh@users.noreply.github.com>
Co-authored-by: jbouwh <jan@jbsoft.nl>
2025-02-18 23:11:21 +01:00
Jan Bouwhuis
d6b7762dd6
Upgrade paho-mqtt API to v2 (#137613)
* Upgrade paho-mqtt API to v2

* Refactor on_connect callback

* Add tests

* Fix Tasmota tests
2025-02-13 22:13:19 +01:00
Jan Bouwhuis
7fa6f7e875
Bump paho-mqtt client to version 2.1.0 (#136130)
* Bump paho-mqtt client to version 2.1.0

* Remove commented code

* Bump pyeconet==0.1.26

* Ensure types-paho-mqtt==1.6.0.20240321 is uninstalled if test requirements are updated

* Update roombapy dependency

* Remove pyeconet from exceptions list

* Revert changes to install test requirements task
2025-02-04 20:59:28 +01:00
Jan Bouwhuis
b93aa760c5
Refactor the MQTT option and reconfigure flow (#133342)
* Move entry options to entry.options en remove broker setup from mqtt option flow

* UPdate diagnostics to export both entry data and options

* Parameterize entry options directly not depending on migration

* Update tests to use v2 entry and add separate migration test

* use start_reconfigure_flow helper

* Update quality scale comment

* Do minor entry upgrade, and do not force to upgrade entry

* Ensure options are read from older entries

* Add comment

* Follow up on code review

* Assert config entry version checking the broker connection

* Update comment
2025-01-13 19:00:18 +01:00
J. Nick Koston
4e316429d3
Handle WebsocketConnectionError during mqtt auto reconnect (#133697)
followup to #133610 to handle the exception in the auto reconnect
path as well

fixes #132985
2024-12-21 11:18:47 +01:00
J. Nick Koston
551a584ca6
Handle mqtt.WebsocketConnectionError when connecting to the MQTT broker (#133610)
fixes #132985
2024-12-19 21:39:39 +01:00
Jan Bouwhuis
8f43a71ff6
Ensure MQTT subscriptions can be made when the broker is disconnected (#132270) 2024-12-04 15:18:04 +01:00
Jan Bouwhuis
1773f2aadc
Allow MQTT device based auto discovery (#118757)
* Allow MQTT device based auto discovery

* Fix merge error

* Remove unused import

* Fix discovery device based topics

* Fix cannot delete twice

* Improve cleanup test

* Follow up comment

* Typo

Co-authored-by: Erik Montnemery <erik@montnemery.com>

* Explain more

* Use tuple

* Default a device payload to have priority over a platform based payload

* Add unique_id to sensor test data

* Set migration flag to mark a discovery topic for migration

* Correct type hint

* Make unique_id required for components in device based discovery payload

* Remove CONF_MIGRATE_DISCOVERY from platform schema

* Unload discovered MQTT item to allow migration

* Follow up comments from code review

* ruff

* Subscribe to platform discovery wildcards first

* Use normal dict

* Use dict to persist wildcard subscription order

* Remove missed unused parameter

* Add a comment to explain we use a dict  to preserve the subscription order

* Add wildcard subscription order test

* Remove discovery flag from test

* Improve discovery migration origin logging

* Assert initial  wildcard discovery topics subscription order and after reconnect

* Improve log messages

---------

Co-authored-by: Erik Montnemery <erik@montnemery.com>
2024-10-30 17:10:15 +01:00
Jan Bouwhuis
4e7397dc9d
Test discovery subscriptions not done when discovery is disabled (#129458)
Test discovery subscriptions not performend when discovery is disabled
2024-10-30 14:38:44 +01:00
Jan Bouwhuis
ac6d893758
Correct type hints on MQTT tests (#128299) 2024-10-16 13:49:18 +02:00
Jan Bouwhuis
1cb9690001
Cleanup unused hass_storage mocks in mqtt tests (#124846) 2024-08-29 10:52:57 +02:00
Jan Bouwhuis
b74aced6f3
Subscribe per component for MQTT discovery (#119974)
* Subscribe per component for MQTT discovery

* Use single assignment

* Handle wildcard subscriptions first

* Split subsRecription handling, update helper

* Fix help_all_subscribe_calls

* Fix import

* Fix test

* Update import order

* Undo move self._last_subscribe

* Recover removed test

* Revert not needed changes to binary_sensor platform tests

* Revert line removal

* Rework interation of discovery topics

* Reduce

* Add comment

* Move comment

* Chain subscriptions
2024-08-20 17:02:48 +02:00
Jan Bouwhuis
21987a67e7
Cleanup unneeded assignment of hass property on MQTT Template objects (#123706)
* Cleanup unneeded assignment of hass property on MQTT Template objects

* Commented out code and unneeded checks

* Consistent assign hass to Template in mqtt tests

* Remove unused hass attribute

* Missed line
2024-08-12 19:20:21 +02:00
J. Nick Koston
8f98fb2ec4
Fix publish cancellation handling in MQTT (#120826) 2024-06-29 11:06:56 -05:00
Jan Bouwhuis
f3c76cd698
Split mqtt client tests (#120636) 2024-06-27 19:37:43 +02:00