Commit Graph

1611 Commits (0ae49036866ef4b3fd9d2b9998bc41fd8df3b879)

Author SHA1 Message Date
Jan Bouwhuis b405e2f03e
Improve logging use of deprecated `schema` option for mqtt vacuum (#119724) 2024-06-15 16:50:12 +02:00
Jan Bouwhuis a992654a8b
Fix blocking IO calls in mqtt client setup (#119647) 2024-06-13 17:47:38 -05:00
J. Nick Koston dbd3147c9b
Remove `async_late_forward_entry_setups` and instead implicitly hold the lock (#119088)
* Refactor config entry forwards to implictly obtain the lock instead of explictly

This is a bit of a tradeoff to not need async_late_forward_entry_setups

The downside is we can no longer detect non-awaited plastform setups
as we will always implicitly obtain the lock instead of explictly.

Note, this PR is incomplete and is only for discussion purposes
at this point

* preen

* cover

* cover

* restore check for non-awaited platform setup

* cleanup

* fix missing word

* make non-awaited test safer
2024-06-12 21:06:11 -04:00
Marc Mueller fe21e2b8ba
Import Generator from typing_extensions (1) (#118986) 2024-06-06 17:02:13 +02:00
J. Nick Koston ed0568c655
Ensure config entries are not unloaded while their platforms are setting up (#118767)
* Report non-awaited/non-locked config entry platform forwards

Its currently possible for config entries to be reloaded while their platforms
are being forwarded if platform forwards are not awaited or done after the
config entry is setup since the lock will not be held in this case.

In https://developers.home-assistant.io/blog/2022/07/08/config_entry_forwards
we advised to await platform forwards to ensure this does not happen, however
for sleeping devices and late discovered devices, platform forwards may happen
later.

If config platform forwards are happening during setup, they should be awaited

If config entry platform forwards are not happening during setup, instead
async_late_forward_entry_setups should be used which will hold the lock to
prevent the config entry from being unloaded while its platforms are being
setup

* Report non-awaited/non-locked config entry platform forwards

Its currently possible for config entries to be reloaded while their platforms
are being forwarded if platform forwards are not awaited or done after the
config entry is setup since the lock will not be held in this case.

In https://developers.home-assistant.io/blog/2022/07/08/config_entry_forwards
we advised to await platform forwards to ensure this does not happen, however
for sleeping devices and late discovered devices, platform forwards may happen
later.

If config platform forwards are happening during setup, they should be awaited

If config entry platform forwards are not happening during setup, instead
async_late_forward_entry_setups should be used which will hold the lock to
prevent the config entry from being unloaded while its platforms are being
setup

* run with error on to find them

* cert_exp, hold lock

* cert_exp, hold lock

* shelly async_late_forward_entry_setups

* compact

* compact

* found another

* patch up mobileapp

* patch up hue tests

* patch up smartthings

* fix mqtt

* fix esphome

* zwave_js

* mqtt

* rework

* fixes

* fix mocking

* fix mocking

* do not call async_forward_entry_setup directly

* docstrings

* docstrings

* docstrings

* add comments

* doc strings

* fixed all in core, turn off strict

* coverage

* coverage

* missing

* coverage
2024-06-04 21:34:39 -04:00
J. Nick Koston 67b3be8432
Remove useless threading locks in mqtt (#118737) 2024-06-04 14:21:03 -05:00
Jan Bouwhuis e799270578
Recover mqtt abbrevations optimizations (#118762)
Co-authored-by: J. Nick Koston <nick@koston.org>
2024-06-04 06:20:18 +02:00
Jan Bouwhuis 2c206c18d4
Do not log mqtt origin info if the log level does not allow it (#118752) 2024-06-03 23:38:31 +02:00
Jan Bouwhuis 39f5f30ca9
Revert "Allow MQTT device based auto discovery" (#118746)
Revert "Allow MQTT device based auto discovery (#109030)"

This reverts commit 585892f067.
2024-06-03 22:30:37 +02:00
J. Nick Koston 9cb113e5d4
Convert mqtt to use a timer instead of task sleep loop (#118666) 2024-06-03 11:19:19 -05:00
Jan Bouwhuis 375f48142c
Fix handling undecoded mqtt sensor payloads (#118633) 2024-06-02 21:25:05 +02:00
J. Nick Koston 1743d1700d
Ensure paho.mqtt.client is imported in the executor (#118412)
fixes #118405
2024-05-29 15:55:34 -04:00
Jan Bouwhuis 585892f067
Allow MQTT device based auto discovery (#109030)
* Add MQTT device based auto discovery

* Respect override of component options over shared ones

* Add state_topic, command_topic, qos and encoding as shared options

* Add shared option test

* Rename device.py to schemas.py

* Remove unused legacy `platform` attribute to avoid confusion

* Split validation device and origin info

* Require `origin` info on device based discovery

* Log origin info for only once for device discovery

* Fix tests and linters

* ruff

* speed up _replace_all_abbreviations

* Fix imports and merging errors - add slots attr

* Fix unrelated const changes

* More unrelated changes

* join string

* fix merge

* Undo move

* Adjust logger statement

* fix task storm to load platforms

* Revert "fix task storm to load platforms"

This reverts commit 8f12a5f251.

* bail if logging is disabled

* Correct mixup object_id and node_id

* Auto migrate entities to device discovery

* Add device discovery test for device_trigger

* Add migration support for non entity platforms

* Use helper to remove discovery payload

* Fix tests after update branch

* Add discovery migration test

* Refactor

* Repair after rebase

* Fix discovery is broken after migration

* Improve comments

* More comment improvements

* Split long lines

* Add comment to indicate payload dict can be empty

* typo

* Add walrus and update comment

* Add tag to migration test

* Join try blocks

* Refactor

* Cleanup not used attribute

* Refactor

* Move _replace_all_abbreviations out of try block

---------

Co-authored-by: J. Nick Koston <nick@koston.org>
2024-05-29 11:12:05 +02:00
J. Nick Koston 9de066d9e1
Replace pop calls with del where the result is discarded in mqtt (#118338) 2024-05-28 15:26:35 -10:00
J. Nick Koston 69353d2719
Speed up mqtt debug info on message callback (#118303) 2024-05-28 11:10:07 -10:00
J. Nick Koston a3c3f938a7
Migrate mqtt mixin async_added_to_hass inner functions to bound methods (#118280) 2024-05-27 22:45:40 -10:00
J. Nick Koston 69a177e864
Migrate mqtt discovery subscribes to use internal helper (#118279) 2024-05-27 18:14:58 -10:00
Jan Bouwhuis bfc3194661
Fix mqtt not publishing null payload payload to remove discovery (#118261) 2024-05-27 12:53:22 -10:00
epenet 97f6b578c8
Enforce namespace import in core (#118235) 2024-05-27 14:03:00 +02:00
J. Nick Koston 6b8223e339
Try to read multiple packets in MQTT (#118222) 2024-05-27 11:07:24 +02:00
J. Nick Koston 21b9a4ef2e
Increase MQTT incoming buffer to 8MiB (#118220) 2024-05-27 10:07:53 +02:00
J. Nick Koston 3ebcee9bbb
Fix mqtt chunk subscribe logging (#118217) 2024-05-26 21:56:09 -10:00
J. Nick Koston 3680d1f8c5
Remove legacy mqtt debug_info implementation (#118212) 2024-05-26 21:55:54 -10:00
J. Nick Koston cfc2cadb77
Eagerly remove MQTT entities on reload (#118213) 2024-05-26 21:55:42 -10:00
J. Nick Koston 5b608bea01
Remove extra inner function for mqtt reload service (#118211) 2024-05-26 18:55:00 -10:00
J. Nick Koston 872e9f2d5e
Fix thundering herd of mqtt component setup tasks (#118210)
We had a thundering herd of tasks to back up against the lock to load each MQTT platform at startup because we had to wait to import the platforms.
2024-05-27 00:29:35 -04:00
J. Nick Koston c391d73fec
Remove unneeded time fetch in mqtt discovery (#118208) 2024-05-26 18:07:27 -10:00
J. Nick Koston c15f7f304f
Remove unneeded dispatcher in mqtt discovery (#118205) 2024-05-26 17:07:24 -10:00
J. Nick Koston 811ec57c31
Convert mqtt entity discovery to use callbacks (#118200) 2024-05-26 16:12:40 -10:00
J. Nick Koston 98d7821f47
Avoid creating template objects in mqtt sensor if they are not configured (#118194) 2024-05-26 12:09:06 -10:00
J. Nick Koston 039bc3501b
Fix mqtt switch types (#118193)
Remove unused code, add missing type for _is_on_map
2024-05-26 23:18:07 +02:00
J. Nick Koston f0b4f4655c
Simplify mqtt switch state message processor (#118187) 2024-05-26 10:42:24 -10:00
J. Nick Koston e74292e358
Move sensor mqtt state update functions to bound methods (#118188) 2024-05-26 10:42:09 -10:00
J. Nick Koston 226d010ab2
Simplify mqtt connection state dispatcher (#118184) 2024-05-26 10:21:21 -10:00
Jan Bouwhuis b7f1f805fa
Simplify subscription mqtt entity platforms (#118177) 2024-05-26 09:25:54 -10:00
Jan Bouwhuis 4a5c5fa311
Remove remove unreachable code in async_wait_for_mqtt_client (#118172) 2024-05-26 16:04:03 +02:00
J. Nick Koston 8b3cad372e
Avoid constructing mqtt availability template objects when there is no template (#118171) 2024-05-26 02:02:13 -10:00
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