Commit Graph

1534 Commits (09e7156d2d272e5489c7d6c4516af677cb6070c1)

Author SHA1 Message Date
Jan Bouwhuis 050fc73056
Refactor shared mqtt schema's to new module (#117944)
* Refactor mqtt schema's to new module

* Remove unrelated change
2024-05-23 01:12:25 +02: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 f42b98336c
Reduce overhead to validate mqtt topics (#117891)
* Reduce overhead to validate mqtt topics

valid_topic would iterate all the chars 4x, refactor to only
do it 1x

valid_subscribe_topic would enumerate all the chars when there was
no + in the string

* check if adding a cache helps

* tweak lrus based on testing stats

* note to future maintainers

* note to future maintainers

* keep standard lru_cache size as increasing makes no material difference
2024-05-21 23:11:05 -04:00
J. Nick Koston 09213d8933
Avoid creating tasks to subscribe to discovery in MQTT (#117890) 2024-05-21 16:39:23 -10:00
J. Nick Koston 4ed45a322c
Reduce overhead to call get_mqtt_data (#117887)
We call this 100000s of times if there are many subscriptions

https://github.com/home-assistant/core/pull/109030#issuecomment-2123612530
2024-05-21 21:11:27 -04: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 1800a60a6d
Simplify and speed up mqtt_config_entry_enabled check (#117886) 2024-05-21 21:04:31 -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
Sid ac54cdcdb4
Enable Ruff RUF010 (#115371)
Co-authored-by: J. Nick Koston <nick@koston.org>
2024-05-08 23:54:49 +02:00
Jan Bouwhuis 589104f63d
Export MQTT subscription helpers at integration level (#116150) 2024-05-08 23:46:50 +02:00
Jan Bouwhuis 840d8cb39f
Add open and opening state support to MQTT lock (#117110) 2024-05-08 22:52:57 +02:00
Jan Bouwhuis 20b29242f1
Make the mqtt discovery update tasks eager and fix race (#117105)
* Fix mqtt discovery race for update rapidly followed on creation

* Revert unrelated renaming local var
2024-05-08 21:42:11 +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 eaf277844f
Correct typo in MQTT translations (#116956) 2024-05-06 23:21:34 +02:00
Jan Bouwhuis 821c7d813d
Correct formatting mqtt MQTT_DISCOVERY_DONE and MQTT_DISCOVERY_UPDATED message (#116947) 2024-05-06 22:32:46 +02:00
Jan Bouwhuis 4b8b9ce92d
Fix initial mqtt subcribe cooldown timeout (#116904) 2024-05-06 14:32:37 +02:00
Jan Bouwhuis 9fd31f6c92
Correct stale docstring on mqtt config flow method (#116848) 2024-05-05 14:06:13 +02:00
Jan Bouwhuis 84308c9e53
Add title feature to notify entity platform (#116426)
* Add title feature to notify entity platform

* Add overload variants

* Remove overloads, update signatures

* Improve test coverage

* Apply suggestions from code review

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* Do not use const

* fix typo

---------

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2024-05-03 11:17:28 +02:00
Jan Bouwhuis 5ddf21e4da
Cleanup MQTT sensor last_reset_topic config parameter a year after removal (#116657) 2024-05-03 00:04:58 +02:00
Jan Bouwhuis 2ec9728edb
Cleanup unused class attr for MQTT config flow (#116653) 2024-05-02 23:09:16 +02:00
Jan Bouwhuis bedd5c1cef
Cleanup removed MQTT broker settings (#116633) 2024-05-02 20:37:21 +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 18132916fa
Mask current password in MQTT option flow (#116098)
* Mask current password in MQTT option flow

* Update docstr

* Typo
2024-04-24 13:29:42 +02:00
Jan Bouwhuis 72ed16c3e0
Update quality scale mqtt integration to platinum (#116059) 2024-04-23 23:20:34 +02: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 8754b12d08
Temporarily pickup mqtt codeowner (#115934) 2024-04-21 22:57:57 +02:00
J. Nick Koston 423544401e
Convert MQTT to use asyncio (#115910) 2024-04-21 22:33:58 +02:00
Jan Bouwhuis 8275512130
Add mqtt notify platform (#115653)
* Add mqtt notify platform

* Stale docstring
2024-04-17 20:07:11 +02:00
Sid 3799d20d43
Enable Ruff B905 (#114197) 2024-04-14 00:14:26 -05:00
J. Nick Koston ee535ee611
Ensure test async_create_task eager start behavior matches production (#115517) 2024-04-13 15:58:52 -05:00
Sid 9bf87329da
Enable Ruff FLY002 rule (#115112)
Co-authored-by: J. Nick Koston <nick@koston.org>
Co-authored-by: Jan Bouwhuis <jbouwh@users.noreply.github.com>
2024-04-12 09:04:16 +02:00
Sid 8e98ba7312
Add first batch of Ruff PYI rules (#115100)
Co-authored-by: Jan Bouwhuis <jbouwh@users.noreply.github.com>
2024-04-07 11:30:50 -10:00
Øyvind Matheson Wergeland fdef3ece13
Fix placeholder quotes (#114974)
* When quoting placeholders, always use double quotes so Lokalise recognizes the placeholder.

* Ensure that strings does not contain placeholders in single quotes.

* Avoid redefining value

* Moved string_with_no_placeholders_in_single_quotes

* Define regex once

* Fix tests
2024-04-06 13:01:56 +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
Marc Mueller 443bfee16d
Replace partial annotations (#114177) 2024-03-28 18:33:39 +01:00