Commit Graph

1574 Commits (05c24e92d19b9ba7f69e324c52df669709347997)

Author SHA1 Message Date
J. Nick Koston 80371d3a73
Reduce duplicate publish code in mqtt (#118163) 2024-05-26 01:22:54 -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 04101b044b
Avoid constructing mqtt json attrs template if its not defined (#118146) 2024-05-25 16:13:54 -10:00
J. Nick Koston 5eeeb8c11f
Remove code that is no longer used in mqtt (#118143) 2024-05-25 11:59:34 -10:00
Jan Bouwhuis 991d6d92db
Refactor mqtt callbacks for valve (#118140) 2024-05-25 11:34:56 -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 d4a95b3735
Refactor mqtt callbacks for light basic, json and template schema (#118113) 2024-05-25 11:24:38 -10:00
Jan Bouwhuis f21c0679b4
Rework mqtt callbacks for camera, image and event (#118109) 2024-05-25 11:23:45 -10:00
Jan Bouwhuis ae0c00218a
Refactor mqtt callbacks for vacuum (#118137) 2024-05-25 11:19:37 -10:00
Jan Bouwhuis fc9f7aee7e
Refactor mqtt callbacks for switch (#118127) 2024-05-25 11:17:54 -10:00
Jan Bouwhuis 6b1b15ef9b
Refactor mqtt callbacks for text (#118130) 2024-05-25 11:16:54 -10:00
Jan Bouwhuis e740e2cdc1
Refactor mqtt callbacks for select platform (#118121) 2024-05-25 11:16:16 -10:00
Jan Bouwhuis 3dbe9a41af
Refactor mqtt callbacks for number (#118119) 2024-05-25 11:15:53 -10:00
Jan Bouwhuis c510031fcf
Refactor mqtt callbacks for siren (#118125) 2024-05-25 11:15:22 -10:00
Jan Bouwhuis 0f44ebd51e
Refactor mqtt callbacks for update platform (#118131) 2024-05-25 11:14:48 -10:00
Jan Bouwhuis e30297d837
Refactor mqtt callbacks for lawn_mower (#118117) 2024-05-25 11:13:43 -10:00
Jan Bouwhuis 05d8ec85aa
Refactor mqtt callbacks for lock (#118118) 2024-05-25 11:13:14 -10:00
Jan Bouwhuis 6580a07308
Refactor mqtt callbacks for humidifier (#118116) 2024-05-25 11:11:07 -10:00
Jan Bouwhuis b4acadc992
Rework mqtt callbacks for fan (#118115) 2024-05-25 11:09:24 -10:00
Jan Bouwhuis 5d7a735da6
Rework mqtt callbacks for device_tracker (#118110) 2024-05-25 11:07:50 -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 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