Commit graph

1654 commits

Author SHA1 Message Date
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
3f76b865fa
Switch mqtt to use async_unload_platforms (#118097) 2024-05-25 11:55:36 +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
d71c7705ae
Convert remaining mqtt attrs classes to dataclasses (#118073) 2024-05-24 17:44:50 -10: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
Jan Bouwhuis
01f3a5a97c
Consequently ignore empty MQTT state payloads and set state to unknown on "None" payload (#117813)
* Consequently ignore empty MQTT state payloads and set state to `unknown` on "None" payload

* Do not change preset mode behavior

* Add device tracker ignoring empty state

* Ignore empty state for lock

* Resolve merge errors
2024-05-25 01:29:43 +02:00
Jan Bouwhuis
7522bbfa9d
Refactor mqtt callbacks for climate and water_heater (#118040)
* Refactor mqtt callbacks for climate and water_heater

* Reduce callbacks
2024-05-25 00:20:05 +02:00
Jan Bouwhuis
35a20d9c60
Refactor mqtt callbacks for cover (#118044) 2024-05-24 10:26:24 -10:00
Jan Bouwhuis
4b89443f62
Refactor mqtt callbacks for alarm_control_panel (#118037) 2024-05-24 10:20:37 -10:00
Jan Bouwhuis
6f81852eb4
Rename MQTT mixin classes (#118039) 2024-05-24 15:41:59 +02:00
Jan Bouwhuis
f12aee28a8
Improve error logging on invalid MQTT entity state (#118006)
* Improve error logging on invalid MQTT entity state

* Explain not hanlding TpeError and ValueError

* Move length check closer to source

* use _LOGGER.exception
2024-05-24 13:11:52 +02:00
Jan Bouwhuis
9333965b23
Create bound callback_message_received method for handling mqtt callbacks (#117951)
* Create bound callback_message_received method for handling mqtt callbacks

* refactor a bit

* fix ruff

* reduce overhead

* cleanup

* cleanup

* Revert changes alarm_control_panel

* Add sensor and binary sensor

* use same pattern for MqttAttributes/MqttAvailability

* remove useless function since we did not need to add to it

* code cleanup

* collapse

---------

Co-authored-by: J. Nick Koston <nick@koston.org>
2024-05-24 11:18:25 +02:00
Marc Mueller
0e03e591e7
Improve callable annotations (#118024) 2024-05-24 10:24:09 +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
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