1
0
mirror of https://github.com/home-assistant/core.git synced 2025-11-03 16:09:36 +00:00
Commit Graph

30 Commits

Author SHA1 Message Date
Jan Bouwhuis
4a5c5fa311 Remove remove unreachable code in async_wait_for_mqtt_client () 2024-05-26 16:04:03 +02:00
Jan Bouwhuis
f12aee28a8 Improve error logging on invalid MQTT entity state ()
* 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
J. Nick Koston
4e3c4400a7 Refactor MQTT to replace get_mqtt_data with HassKey () 2024-05-21 23:21:51 -10:00
J. Nick Koston
f42b98336c Reduce overhead to validate mqtt topics ()
* 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
4ed45a322c Reduce overhead to call get_mqtt_data ()
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
1800a60a6d Simplify and speed up mqtt_config_entry_enabled check () 2024-05-21 21:04:31 -04:00
Sid
0d66d298ec Enable Ruff RET504 ()
* 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
Marc Mueller
1dbc94162d Update byte string formatting (2) () 2024-03-23 00:22:15 +01:00
Jan Bouwhuis
c608d1cb85 Fix mqtt platform setup race () 2024-03-10 08:36:17 -10:00
Jan Bouwhuis
3b0ea52167 Allow Just-in-Time platform setup for mqtt ()
* 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
a9147cf3dd Use builtin TimeoutError [k-n] () 2024-02-05 12:08:18 +01:00
Aarni Koskela
706add4a57 Switch formatting from black to ruff-format ()
Co-authored-by: Franck Nijhof <git@frenck.dev>
2023-11-27 14:38:59 +01:00
Jan Bouwhuis
1a5f093397 Uer hass.loop.create_future() for MQTT client () 2023-09-10 17:15:46 +02:00
Marc Mueller
a9ade1f84d Use asyncio.timeout [core] () 2023-08-15 08:36:05 -05:00
Jan Bouwhuis
0bcda9fe9c Make sure MQTT client is available when starting depending platforms ()
* Make sure MQTT is available starting mqtt_json

* Wait for mqtt client

* Sync client connect

* Simplify

* Addiitional tests async_wait_for_mqtt_client

* Improve comment waiting for mqtt

* Improve docstr

* Do not wait unless the MQTT client is in setup

* Handle entry errors during setup

* More comments - do not clear event

* Add snips and mqtt_room

* Add manual_mqtt

* Update homeassistant/components/mqtt/__init__.py

Co-authored-by: J. Nick Koston <nick@koston.org>

* Use a fixture, improve tests

* Simplify

---------

Co-authored-by: J. Nick Koston <nick@koston.org>
2023-04-20 08:07:35 +02:00
Jan Bouwhuis
4a0d3e881a Rework MQTT config merging and adding defaults ()
* Cleanup config merging and adding defaults

* Optimize and update tests

* Do not mix entry and yaml config

* Make sure hass.data is initilized

* remove check on get_mqtt_data

* Tweaks to MQTT client

* Remove None assigment mqtt client and fix mock
2023-04-04 18:12:18 +02:00
epenet
810367b757 Fix can not typo () 2023-02-03 11:37:16 +01:00
Franck Nijhof
baef267f33 String formatting and max line length - Part 3 () 2022-12-22 13:35:47 +01:00
Marc Mueller
9a97784168 Add types package for paho-mqtt () 2022-12-09 15:27:46 +01:00
Jan Bouwhuis
8a8732f0bc Strict type hints for MQTT integration ()
* Strict type hints for MQTT integration

* Fix errors

* Additional corrections

* Use cv.template to avoid untyped calls

* Enable strict typing policy for MQTT integration

* Use ignore[no-untyped-call]

* Use # type: ignore[unreachable]

* Correct cast

* Refactor getting discovery_payload

* Remove unused type ignore comments
2022-11-24 08:25:44 +01:00
Aarni Koskela
bbda122c99 Fix mqtt typo ()
mqtt: fix "certiticate" typo
2022-11-14 16:22:23 +01:00
Jan Bouwhuis
7500d0c61c Refactor MQTT_WILL_BIRTH_SCHEMA ()
* Refactor MQTT_WILL_BIRTH_SCHEMA

* Refactor and move birth/will validation to utils

* Simplify birth will validation
2022-11-10 15:24:56 +01:00
Jan Bouwhuis
2d9f39d406 Strict typing for shared MQTT modules ()
Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
2022-10-26 13:52:34 +02:00
Jan Bouwhuis
5e7f571f01 Move advanced MQTT options to entry ()
* Move advanced broker settings to entry

* Add repair issue for deprecated settings

* Split CONFIG_SCHEMA

* Do not store certificate UI flags in entry

* Keep entered password in next dialog

* Do not process yaml config in flow

* Correct typo
2022-10-24 09:58:23 +02:00
epenet
e58531f118 Add MqttData helper to mqtt ()
* Add MqttData helper to mqtt

* Adjust client for circular dependencies

* Move MqttData to models.py

* Move get_mqtt_data to util.py
2022-09-20 19:40:06 +02:00
Jan Bouwhuis
5930f056a8 Mqtt support config_entry unload ()
* squashed commits for rebase

* Flake

* Fix reloading issue manual legacy items

* Improve ACS sync for unsubscribe at disconnect

* Processed review comments

* Update homeassistant/components/mqtt/client.py

Co-authored-by: Erik Montnemery <erik@montnemery.com>

* No need to await entry setup

* Remove complication is_connected

* Update homeassistant/components/mqtt/__init__.py

Co-authored-by: Erik Montnemery <erik@montnemery.com>
2022-07-12 11:07:18 +02:00
Erik Montnemery
e9abfad361 Reject MQTT topics which include control- or non-characters () 2022-05-03 12:19:43 -07:00
Erik Montnemery
047f16772f Support templating MQTT triggers ()
* Add support for limited templates (no HASS access)

* Pass variables to automation triggers

* Support templates in MQTT triggers

* Spelling

* Handle trigger referenced by variables

* Raise on unsupported function in limited templates

* Validate MQTT trigger schema in MQTT device trigger

* Add trigger_variables to automation config schema

* Don't print stacktrace when setting up trigger throws

* Make pylint happy

* Add trigger_variables to variables

* Add debug prints, document limited template

* Add tests

* Validate MQTT trigger topic early when possible

* Improve valid_subscribe_topic_template
2021-02-08 10:50:38 +01:00
Ville Skyttä
b4bac0f7a0 Exception chaining and wrapping improvements ()
* Remove unnecessary exception re-wraps

* Preserve exception chains on re-raise

We slap "from cause" to almost all possible cases here. In some cases it
could conceivably be better to do "from None" if we really want to hide
the cause. However those should be in the minority, and "from cause"
should be an improvement over the corresponding raise without a "from"
in all cases anyway.

The only case where we raise from None here is in plex, where the
exception for an original invalid SSL cert is not the root cause for
failure to validate a newly fetched one.

Follow local convention on exception variable names if there is a
consistent one, otherwise `err` to match with majority of codebase.

* Fix mistaken re-wrap in homematicip_cloud/hap.py

Missed the difference between HmipConnectionError and
HmipcConnectionError.

* Do not hide original error on plex new cert validation error

Original is not the cause for the new one, but showing old in the
traceback is useful nevertheless.
2020-08-28 13:50:32 +02:00
Erik Montnemery
747490ab34 Support reconfiguring MQTT config entry () 2020-06-22 17:49:01 -07:00