Commit graph

236 commits

Author SHA1 Message Date
Marc Mueller
dc47792ff2
Update codespell to 2.3.0 (#118001) 2024-05-24 08:22:29 +02:00
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
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
ac3321cef1
Fix setting MQTT socket buffer size with WebsocketWrapper (#117672) 2024-05-19 14:09:21 -10: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
J. Nick Koston
481de8cdc9
Ensure config entry operations are always holding the lock (#117214)
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2024-05-12 08:20:08 +09:00
Jan Bouwhuis
589104f63d
Export MQTT subscription helpers at integration level (#116150) 2024-05-08 23:46:50 +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
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
J. Nick Koston
6cf1c5c1f2
Hold a lock to prevent concurrent setup of config entries (#116482) 2024-04-30 18:47:12 -05:00
Jan Bouwhuis
3c7cbf5794
Add test MQTT subscription is completed when birth message is sent (#116476) 2024-04-30 18:15:46 -05:00
epenet
ad84ff18eb
Use remove_device helper in tests (1/2) (#116240)
* Use remove_device helper in tests

* Update test_tag.py

* Update test_tag.py
2024-04-30 12:52:33 +02:00
Jan Bouwhuis
43dc5415de
Fix no will published when mqtt is down (#116319) 2024-04-27 18:42:38 -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
Sid
895f73d8e4
Enable Ruff A001 (#115654) 2024-04-21 23:25:27 +02:00
J. Nick Koston
423544401e
Convert MQTT to use asyncio (#115910) 2024-04-21 22:33:58 +02:00
Marc Mueller
443bfee16d
Replace partial annotations (#114177) 2024-03-28 18:33:39 +01:00
Jan-Philipp Benecke
22b14d83e8
Use setup_test_component_platform helper for sensor entity component tests instead of hass.components (#114316)
* Use `setup_test_component_platform` helper for sensor entity component tests instead of `hass.components`

* Missing file

* Fix import

* Remove invalid device class
2024-03-28 12:07:55 +01:00
Jan Bouwhuis
3dc8df2403
Get ServiceValidationError message from translation cache only (#113704)
* Get ServiceValidationError message from translation cache only

* Remove message for NotValidPresetModeError
2024-03-18 14:42:21 +01:00
Sid
d5fd005db8
Add ruff rule PIE808 (#113621) 2024-03-17 09:56:26 +01:00
Jan Bouwhuis
c608d1cb85
Fix mqtt platform setup race (#112888) 2024-03-10 08:36:17 -10:00
Jan Bouwhuis
caaa03536b
Cleanup mqtt PLATFORMS constant and CI-test platform filters (#112847) 2024-03-09 23:48:54 +01:00
Jan Bouwhuis
3b0ea52167
Allow Just-in-Time platform setup for mqtt (#112720)
* Allow Just-in-Time platform setup for mqtt

* Only forward the setup of new platforms

* Fix new  platforms being setup at reload + test

* Revert not related changes

* Remove unused partial

* Address comments, only import plaforms if needed

* Apply suggestions from code review

* Add multipl platform discovery test

* Improve test

* Use a lock per platform
2024-03-09 21:55:00 +01:00
Marc Mueller
959826c4b4
Update byte string formatting (#112752) 2024-03-08 20:32:40 +01:00
Marc Mueller
32f3f46542
Add empty line after module docstring (2) [tests.components] (#112737) 2024-03-08 19:16:21 +01:00
Jan Bouwhuis
c13231fc00
Improve mqtt value template error logging (#110492)
* Refactor mqtt value template error logging

* Remove import
2024-03-04 08:49:12 +01:00
Jan Bouwhuis
1b2e669302
Improve handling mqtt command template exceptions (#110499)
* Improve handling mqtt command template exceptions

* Fix test

* Cleanup stale exception handler

* Throw on topic template exception
2024-02-26 11:04:55 +01:00
J. Nick Koston
5b8591ec7e
Avoid reschedule churn in Storage.async_delay_save (#111091)
* Avoid circular import in Storage.async_delay_save

We call Storage.async_delay_save for every entity being added or removed
from the registry. The late import took more time than everything else
in the function.

* Avoid reschedule churn in Storage.async_delay_save

When we are adding or removing entities we will call async_delay_save
quite often which has to add and remove a TimerHandle on the event loop
which can add up when there are a lot of registry items changing.

If the timer handle still has 80% of the time remaining on it
we will avoid resceduling and let it fire at the time the
original async_delay_save call was made. This ensures we
do not force the event loop to rebuild its heapq because
too many timer handlers were cancelled at once

* div0

* add coverage for 0 since we had none

* fix bad conflict

* tweaks

* tweaks

* tweaks

* tweaks

* tweaks

* tweaks

* more test fixes

* mqtt tests rely on event loop overhead
2024-02-24 08:46:00 +01:00
Jan Bouwhuis
c048b840fc
Do not directly call async_setup_entry in MQTT tests (#111010) 2024-02-21 07:47:30 +01:00
Jan Bouwhuis
09f1ec78a5
Handle template errors on MQTT payload handling (#110180)
* Handle template errors on MQTT payload handling (alt)

* Handle mqtt event en image template errors correctly
2024-02-13 10:59:55 +01:00
J. Nick Koston
04dccc7ec6
Migrate mqtt to use async_update_entry to alter config entries (#110407) 2024-02-12 21:38:13 +01:00
Marc Mueller
a9147cf3dd
Use builtin TimeoutError [k-n] (#109681) 2024-02-05 12:08:18 +01:00
J. Nick Koston
c399cab427
Small speed up to checking core state (#107845) 2024-01-18 08:41:32 -10:00
Jan Bouwhuis
26058bf922
Add serial_number attribute to MQTT device properties (#108105) 2024-01-16 14:02:34 +01:00
Jan Bouwhuis
c7b6c9da31
Remove work-a-round for mqtt sensors with an entity_category set to config (#107199)
* Remove work-a-round for mqtt sensors with an entity_category set to `config`

* Cleanup strings
2024-01-05 09:24:52 +01:00
Jan-Philipp Benecke
ff85d0c290
Migrate mqtt tests to use freezegun (#105414) 2023-12-10 09:25:16 +01:00
Jan-Philipp Benecke
9326ea09a5
Update m* tests to use entity & device registry fixtures (#103980) 2023-11-15 10:33:11 +01:00
Jan Bouwhuis
db97e7588b
Fix entity category for binary_sensor fails setup (#103511) 2023-11-08 14:10:24 +01:00
Jan Bouwhuis
cbccdbc6fa
Fix entity category for sensor fails mqtt sensor platform setup (#103449) 2023-11-08 00:03:47 +01:00
Jan Bouwhuis
4a4d2ad743
Fix mqtt config validation error handling (#103210)
* Fix MQTT config check

* Fix handling invalid enity_category for sensors

* Improve docstr

* Update comment

* Use correct util for yaml dump
2023-11-02 10:57:00 +01:00
Jan Bouwhuis
daee5baef6
Fix mqtt is not reloading without yaml config (#103159) 2023-11-01 09:25:56 +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
d149bffb07
Do not fail MQTT setup if lights configured via yaml can't be validated (#101649)
* Add light

* Deduplicate code

* Follow up comment
2023-10-19 17:34:43 +02:00
Jan Bouwhuis
c377cf1ce0
Do not fail mqtt entry on single platform config schema error (#101373)
* Do not fail mqtt entry on platform config

* Raise on reload with invalid config

* Do not store issues

* Follow up
2023-10-19 12:06:33 +02:00
Jan Bouwhuis
74464fd94e
Ensure coverage mqtt entry disabled test (#101617) 2023-10-07 23:08:34 +02:00
Jan Bouwhuis
0ded0ef4ee
Use dataclass instead of attr slots for mqtt PublishMessage and ReceiveMessage (#101062)
Use dataclass instead of attr slots
2023-09-28 20:36:30 +02:00
Jan Bouwhuis
dc1d3f727b
Fix handling reload with invalid mqtt config (#101015)
Fix handling reload whith invalid mqtt config
2023-09-27 20:59:19 -04:00