Commit graph

99 commits

Author SHA1 Message Date
J. Nick Koston
226d010ab2
Simplify mqtt connection state dispatcher (#118184) 2024-05-26 10:21:21 -10:00
J. Nick Koston
5d37217d96
Avoid expensive inspection of callbacks to setup mqtt subscriptions (#118161) 2024-05-26 01:22:44 -10:00
J. Nick Koston
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
Jan Bouwhuis
521ed0a220
Fix mqtt callback exception logging (#118138)
* Fix mqtt callback exception logging

* Improve code

* Add test
2024-05-25 22:46:33 +02:00
Marc Mueller
2f16c3aa80
Fix mqtt callback typing (#118104) 2024-05-25 18:59:29 +02:00
J. Nick Koston
de275878c4
Small speed up to mqtt _async_queue_subscriptions (#118094) 2024-05-25 12:32:15 +02:00
J. Nick Koston
4da125e27b
Simplify mqtt discovery cooldown calculation (#118095) 2024-05-24 23:27:22 -10:00
J. Nick Koston
ad638dbcc5
Speed up removing MQTT subscriptions (#118088) 2024-05-25 10:28:14 +02:00
J. Nick Koston
90d10dd773
Use defaultdict instead of setdefault in mqtt client (#118070) 2024-05-24 14:34:06 -10:00
J. Nick Koston
3031e4733b
Reduce duplicate code to handle mqtt message replies (#118067) 2024-05-24 14:33:21 -10:00
J. Nick Koston
c7a1c59215
Avoid catch_log_exception overhead in MQTT for simple callbacks (#118036) 2024-05-24 14:32:32 -10:00
J. Nick Koston
65a702761b
Avoid generating matchers that will never be used in MQTT (#118068) 2024-05-24 14:04:03 -10:00
Jan Bouwhuis
fa1ef8b0cf
Split mqtt subscribe and unsubscribe calls to smaller chunks (#118035) 2024-05-24 13:33:28 -10:00
J. Nick Koston
4e3c4400a7
Refactor MQTT to replace get_mqtt_data with HassKey (#117899) 2024-05-21 23:21:51 -10:00
J. Nick Koston
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
J. Nick Koston
fe769c4527
Fix missing type for mqtt websocket wrapper (#117752) 2024-05-20 09:32:50 +02:00
J. Nick Koston
ac3321cef1
Fix setting MQTT socket buffer size with WebsocketWrapper (#117672) 2024-05-19 14:09:21 -10:00
Marc Mueller
87bb7ced79
Use PEP 695 for simple type aliases (#117633) 2024-05-17 14:42:21 +02:00
Jan Bouwhuis
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
Jan Bouwhuis
96ccf7f2da
Log some mqtt of the discovery logging at debug level (#117185) 2024-05-10 14:49:27 +02:00
J. Nick Koston
649dd55da9
Simplify MQTT subscribe debouncer execution (#117006) 2024-05-07 14:41:31 -05:00
Jan Bouwhuis
a3248ccff9
Log an exception mqtt client call back throws (#117028)
* Log an exception mqtt client call back throws

* Supress exceptions and add test
2024-05-07 21:19:46 +02:00
Jan Bouwhuis
7148c849d6
Only log loop client subscription log if log level is DEBUG (#117008)
Co-authored-by: J. Nick Koston <nick@koston.org>
2024-05-07 18:38:59 +02:00
Sid
2cc916db6d
Replace pylint broad-except with Ruff BLE001 (#116250) 2024-05-07 14:00:27 +02:00
Jan Bouwhuis
4b8b9ce92d
Fix initial mqtt subcribe cooldown timeout (#116904) 2024-05-06 14:32:37 +02:00
J. Nick Koston
041456759f
Remove duplicate mid handling in MQTT (#116531) 2024-05-01 15:18:44 -05:00
Jan Bouwhuis
7fd60ddba4
Fix MQTT discovery cooldown too short with large setup (#116550)
* Fix MQTT discovery cooldown too short with large setup

* Set to 5 sec

* Only change the discovery cooldown

* Fire immediatly when teh debouncing period is over
2024-05-01 21:19:55 +02:00
J. Nick Koston
25df41475a
Simplify MQTT mid handling (#116522)
* Simplify MQTT mid handling

switch from asyncio.Event to asyncio.Future

* preen

* preen

* preen
2024-05-01 11:03:10 -05:00
J. Nick Koston
2ad6353bf8
Fix stop event cleanup when reloading MQTT (#116525) 2024-05-01 10:22:50 -05:00
J. Nick Koston
2e9b1916c0
Ensure MQTT resubscribes happen before birth message (#116471) 2024-04-30 22:31:40 +02:00
Jan Bouwhuis
43dc5415de
Fix no will published when mqtt is down (#116319) 2024-04-27 18:42:38 -05:00
Jan Bouwhuis
372c6c7874
Use existing monotonic timestamp on mqtt messages for debugging (#116196) 2024-04-25 19:09:54 -05:00
Jan Bouwhuis
31d11b2362
Add re-auth flow for MQTT broker username and password (#116011)
Co-authored-by: J. Nick Koston <nick@koston.org>
2024-04-23 22:26:01 +02:00
J. Nick Koston
0ed56694b0
Migrate MQTT EnsureJobAfterCooldown to use eager start (#115977) 2024-04-22 20:09:45 +02:00
J. Nick Koston
423544401e
Convert MQTT to use asyncio (#115910) 2024-04-21 22:33:58 +02:00
Sid
0d66d298ec
Enable Ruff RET504 (#114528)
* Enable Ruff RET504

* fix test

* Use noqa instead of cast

* fix sonos RET504

---------

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2024-04-06 11:07:37 +02:00
J. Nick Koston
3d8a110908
Dispatch the same ReceiveMessage object if the subscription topic is the same (#114769) 2024-04-03 09:36:57 -10:00
Jan Bouwhuis
488dae43d4
Improve lists for MQTT integration (#113184)
* Improve lists for MQTT integration

* Extra diagnostics tests

* Revert changes where the original version was probably faster

* Revert change to gather and await in series
2024-03-13 11:04:59 +01:00
Marc Mueller
59a6035d3f
Add empty line after module docstring [j-m] (#112700) 2024-03-08 09:01:29 -05:00
Marc Mueller
a9147cf3dd
Use builtin TimeoutError [k-n] (#109681) 2024-02-05 12:08:18 +01:00
J. Nick Koston
5c3bf13ca4
Only decode msg topic once when handling mqtt payloads (#109258) 2024-02-01 03:42:58 +01:00
Jan Bouwhuis
677b06f502
Add comment to explain not using the core API in MQTT client (#108942) 2024-01-27 02:05:31 -10:00
J. Nick Koston
4b7a313ece
Use identity checks for CoreState (#107846)
Some of the checks used ==, and some used is. Switch
everything to is as its faster
2024-01-12 10:21:26 +01:00
Jan-Philipp Benecke
c81f909ee3
Use call_soon_threadsafe in mqtt client unsubscribe callback (#107266) 2024-01-05 19:45:56 +01:00
Jan Bouwhuis
f0ec1235b1
Remove naming warnings and work-a-rounds for incorrectly configured MQTT entities (#107188)
* Remove naming warnings for MQTT entities

* Remove unused const
2024-01-05 09:32:22 +01:00
Jan Bouwhuis
8a1f7b6802
Add translation key for some mqtt exceptions (#104550) 2023-11-26 17:33:54 +01:00
Jan Bouwhuis
485c52568d
Fix error handling on subscribe when mqtt is not initialized (#101832) 2023-10-20 15:16:45 +02:00
Jan Bouwhuis
77c519220d
Use dataclass for mqtt Subscription (#101064) 2023-09-28 20:35:49 +02:00
J. Nick Koston
7c87b38a23
Reduce overhead to process and publish MQTT messages (#99457) 2023-09-01 15:41:34 -05:00
Ville Skyttä
3094991236
Upgrade ruff to 0.0.285 (#98647) 2023-08-19 08:17:17 -04:00