Commit Graph

130 Commits

Author SHA1 Message Date
2c13c70e12 Update ruff to 0.12.0 (#147106) 2025-06-19 20:39:09 +02:00
4cd3527761 Enable B009 (#144192) 2025-05-21 16:37:51 +01:00
b936739917 Update pylint to 3.3.6 (#141028) 2025-03-21 00:33:16 +01:00
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
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 75806736cf.

* 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
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
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
aa741a9207 Combine short strings in components (#135265) 2025-01-10 11:07:51 +01:00
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
551a584ca6 Handle mqtt.WebsocketConnectionError when connecting to the MQTT broker (#133610)
fixes #132985
2024-12-19 21:39:39 +01:00
dc8b7cfede Allow bytearray for mqtt payload type (#132906) 2024-12-11 11:51:16 +01:00
8f43a71ff6 Ensure MQTT subscriptions can be made when the broker is disconnected (#132270) 2024-12-04 15:18:04 +01:00
47aebabc51 Add final translations to mqtt exceptions (#131933) 2024-12-01 12:20:45 +01:00
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
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
87e377cf84 Ensure mqtt subscriptions are in a set (#122201) 2024-07-21 12:36:06 +02:00
ca55986057 Import Generator from collections.abc (1) (#120914) 2024-07-01 11:51:51 +02:00
8f98fb2ec4 Fix publish cancellation handling in MQTT (#120826) 2024-06-29 11:06:56 -05:00
1d16cbec96 Move mqtt debouncer to mqtt utils (#120392) 2024-06-25 10:33:58 +02:00
f0452e9ba0 Update mypy dev 1.11.0a8 (#120032) 2024-06-21 13:15:18 +02:00
60ba80a28d Only (re)subscribe MQTT topics using the debouncer (#119995)
* Only (re)subscribe using the debouncer

* Update test

* Fix test

* Reset mock
2024-06-19 23:57:18 +02:00
6eb9d1e01d Gracefully disconnect MQTT entry if entry is reloaded (#119753) 2024-06-18 09:29:22 +02:00
a992654a8b Fix blocking IO calls in mqtt client setup (#119647) 2024-06-13 17:47:38 -05:00
fe21e2b8ba Import Generator from typing_extensions (1) (#118986) 2024-06-06 17:02:13 +02:00
67b3be8432 Remove useless threading locks in mqtt (#118737) 2024-06-04 14:21:03 -05:00
9cb113e5d4 Convert mqtt to use a timer instead of task sleep loop (#118666) 2024-06-03 11:19:19 -05:00
1743d1700d Ensure paho.mqtt.client is imported in the executor (#118412)
fixes #118405
2024-05-29 15:55:34 -04:00
bfc3194661 Fix mqtt not publishing null payload payload to remove discovery (#118261) 2024-05-27 12:53:22 -10:00
6b8223e339 Try to read multiple packets in MQTT (#118222) 2024-05-27 11:07:24 +02:00
21b9a4ef2e Increase MQTT incoming buffer to 8MiB (#118220) 2024-05-27 10:07:53 +02:00
3ebcee9bbb Fix mqtt chunk subscribe logging (#118217) 2024-05-26 21:56:09 -10:00
226d010ab2 Simplify mqtt connection state dispatcher (#118184) 2024-05-26 10:21:21 -10:00
5d37217d96 Avoid expensive inspection of callbacks to setup mqtt subscriptions (#118161) 2024-05-26 01:22:44 -10:00
9be829ba1f Make mqtt internal subscription a normal function (#118092)
Co-authored-by: Jan Bouwhuis <jbouwh@users.noreply.github.com>
2024-05-25 11:34:24 -10:00
521ed0a220 Fix mqtt callback exception logging (#118138)
* Fix mqtt callback exception logging

* Improve code

* Add test
2024-05-25 22:46:33 +02:00
2f16c3aa80 Fix mqtt callback typing (#118104) 2024-05-25 18:59:29 +02:00
de275878c4 Small speed up to mqtt _async_queue_subscriptions (#118094) 2024-05-25 12:32:15 +02:00
4da125e27b Simplify mqtt discovery cooldown calculation (#118095) 2024-05-24 23:27:22 -10:00
ad638dbcc5 Speed up removing MQTT subscriptions (#118088) 2024-05-25 10:28:14 +02:00
90d10dd773 Use defaultdict instead of setdefault in mqtt client (#118070) 2024-05-24 14:34:06 -10:00
3031e4733b Reduce duplicate code to handle mqtt message replies (#118067) 2024-05-24 14:33:21 -10:00
c7a1c59215 Avoid catch_log_exception overhead in MQTT for simple callbacks (#118036) 2024-05-24 14:32:32 -10:00
65a702761b Avoid generating matchers that will never be used in MQTT (#118068) 2024-05-24 14:04:03 -10:00
fa1ef8b0cf Split mqtt subscribe and unsubscribe calls to smaller chunks (#118035) 2024-05-24 13:33:28 -10:00
4e3c4400a7 Refactor MQTT to replace get_mqtt_data with HassKey (#117899) 2024-05-21 23:21:51 -10:00
f429bfa903 Fix mqtt timer churn (#117885)
Borrows the same design from homeassistant.helpers.storage to avoid
rescheduling the timer every time async_schedule is called if a timer
is already running.

Instead of the timer fires too early it gets rescheduled for the time
we wanted it. This avoids 1000s of timer add/cancel during startup
2024-05-21 21:05:33 -04:00
fe769c4527 Fix missing type for mqtt websocket wrapper (#117752) 2024-05-20 09:32:50 +02:00
ac3321cef1 Fix setting MQTT socket buffer size with WebsocketWrapper (#117672) 2024-05-19 14:09:21 -10:00
87bb7ced79 Use PEP 695 for simple type aliases (#117633) 2024-05-17 14:42:21 +02:00
92254772ca Increase MQTT broker socket buffer size (#117267)
* Increase MQTT broker socket buffer size

* Revert unrelated change

* Try to increase buffer size

* Set INITIAL_SUBSCRIBE_COOLDOWN back to 0.5 sec

* Sinplify and add test

* comments

* comments

---------

Co-authored-by: J. Nick Koston <nick@koston.org>
2024-05-12 13:13:41 +02:00