Commit graph

1654 commits

Author SHA1 Message Date
Jan Bouwhuis
f99b7d8b78
Start mqtt integration discovery config flow only once if config has not changed (#126966)
* Start mqtt integration config flow only once

* Remember last config message

* Filter out instead of unsubscribing the intehration discovery topic

* Follow up comments from code review
2024-09-30 12:44:40 +02:00
Jan Bouwhuis
b573e5a2b3
Allow null / None value for non numeric mqtt sensor without warnings (#127032)
Allow `null` / `None` value for mqtt sensor without warnings
2024-09-30 07:05:12 +02:00
Jan Bouwhuis
7fde2e2fe0
Do not unsubscribe mqtt integration discovery if entry is already configured (#126907)
* Do not unsubscribe mqtt integration discovery if entry is already configured

* Test cases without unsubscribe
2024-09-27 17:28:51 +02:00
c0ffeeca7
866ffcf639
Use bold to markup UI strings (#126748)
* Use bold to markup UI strings

* Use bold to markup UI strings
2024-09-25 15:33:23 +02:00
Erik Montnemery
c638537731
Use 'select' instead of 'click' or 'press' when guiding users in flows (#126731) 2024-09-25 13:37:43 +02:00
epenet
c099f4f50f
Use vol.Coerce for SourceType in mqtt device_tracker (#126594) 2024-09-24 19:09:19 +02:00
G Johansson
939f2e41e9
Change valve state to an enum (#126428) 2024-09-23 14:20:18 +02:00
Jan Bouwhuis
bafc42c8f1
Cleanup unused protocol class for mqtt entity setup (#126276) 2024-09-19 21:29:14 +02:00
Jan Bouwhuis
21affac571
Rename mqtt mixins module to entity.py (#126279) 2024-09-19 20:50:33 +02:00
epenet
6bc2d11c5e
Add base Entity class to enforce-class-module pylint plugin (#126026)
* Add base Entity class to enforcé-class-module pylint plugin

* Ignore bluetooth

* Ignore hue

* Ignore dominos

* Ignore ffmpeg

* Ignore mqtt

* Ignore microsoft_face

* Ignore plant

* Ignore point

* Ignore rfxtrx

* Ignore template

* Ignore tag

* Ignore deconz
2024-09-18 20:38:45 +02:00
epenet
47a9dda3b8
Use root import in components (#125858) 2024-09-12 22:21:21 +02:00
epenet
ba9dae10c3
Simplify imports in mqtt (#125749) 2024-09-11 18:14:00 +02:00
Jan Bouwhuis
4c27bfbf7f
Cleanup removed options for mqtt climate (#125083) 2024-09-02 20:35:36 +02:00
Erik Montnemery
1a2d013c97
Update icons.json to new service schema part 3 (#124770) 2024-08-28 13:48:01 +02:00
Jan Bouwhuis
e720a14dc4
Cleanup removed schema option from mqtt vacuum platform (#124722) 2024-08-28 07:49:05 +02:00
Jan Bouwhuis
ff029e5efc
Cleanup not used data field for mqtt hassio config flow confirm step (#124486) 2024-08-26 17:33:47 +02:00
Jan Bouwhuis
65216df3a5
Auto recover mqtt config entry secret if Mosquitto add-on was re-installed (#124514)
Auto recover mqtt config entry secret if Mosquitto add-on is re-installed
2024-08-26 09:40:25 +02:00
Jan Bouwhuis
e13f8996f2
Fix Import ReceivePayloadType (#124431)
* Fix Import ReceivePayloadType

* Do not assert export `ReceivePayloadType` on mqtt integration level as helper should be used.
2024-08-22 20:13:30 +02:00
Jan Bouwhuis
7887bcba89
Allow to set options for an MQTT enum sensor (#123248)
* Add options attribute support for MQTT sensor

* Add comment
2024-08-22 19:16:08 +02:00
Jan Bouwhuis
61114d8328
Install and start Mosquitto MQTT broker add on from MQTT config flow (#124106)
* Opt in to install Mosquitto broker add-on in MQTT config flow

* rephrase

* Tests with supervisor and running add-on

* Complete tests for success flows

* Also set up entry in success flow

* Use realistic names for addon and broker

* Finetuning and fail test cases

* Spelling

* Improve translation strings

* Update addon docstr

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

* Raise AddonError if add-on does not start

* Only show the option to use the add-on

* Simplify flow, rework and cleanup

* Revert unrelated cleanup, process suggestion

* Move ADDON_SLUG const to addon module

* Move fixture to component level

* Move back supervisor fixture

* Move addon_setup_time_fixture and superfixe to config flow model tests

* Refactor hassio fixture

* Rename helpers as they are no fixtures, remove fixture from their names

---------

Co-authored-by: Erik Montnemery <erik@montnemery.com>
2024-08-22 09:07:45 +02:00
Jan Bouwhuis
b74aced6f3
Subscribe per component for MQTT discovery (#119974)
* Subscribe per component for MQTT discovery

* Use single assignment

* Handle wildcard subscriptions first

* Split subsRecription handling, update helper

* Fix help_all_subscribe_calls

* Fix import

* Fix test

* Update import order

* Undo move self._last_subscribe

* Recover removed test

* Revert not needed changes to binary_sensor platform tests

* Revert line removal

* Rework interation of discovery topics

* Reduce

* Add comment

* Move comment

* Chain subscriptions
2024-08-20 17:02:48 +02:00
Jan Bouwhuis
183c191d63
Allow raw mqtt payload to be in mqtt publish action (#123900)
* Publish raw rendered mqtt payload as raw for mqtt publish action

* Move check out of try block

* Only try to eval `bytes` is payload starts with supported string

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

* Improve docst

* Add `evaluate_bytes` option to publish action

* Rename to `evaluate_payload`

* Update homeassistant/components/mqtt/strings.json

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

* Extend test to assert literal_eval is called or not

---------

Co-authored-by: Erik Montnemery <erik@montnemery.com>
2024-08-16 13:34:14 +02:00
Jan Bouwhuis
21987a67e7
Cleanup unneeded assignment of hass property on MQTT Template objects (#123706)
* Cleanup unneeded assignment of hass property on MQTT Template objects

* Commented out code and unneeded checks

* Consistent assign hass to Template in mqtt tests

* Remove unused hass attribute

* Missed line
2024-08-12 19:20:21 +02:00
epenet
0bb8c4832d
Enable raise-within-try (TRY301) rule in ruff (#123351) 2024-08-12 09:16:33 +02:00
Maciej Bieniek
a9d8e47979
Support DeviceInfo.model_id in MQTT integration (#123152)
Add support for model_id
2024-08-04 23:02:41 +02:00
Jan Bouwhuis
87e377cf84
Ensure mqtt subscriptions are in a set (#122201) 2024-07-21 12:36:06 +02:00
Jan Bouwhuis
16434b5306
Add command_template option to mqtt switch schema (#122103) 2024-07-19 12:10:49 +02:00
G Johansson
ca4c617d4b
Add TURN_OFF/TURN_ON feature flags for fan (#121447) 2024-07-19 11:35:24 +02:00
Jan Bouwhuis
5b4dd07189
Deprecate topic_template and payload_template for mqtt publish action (#122098)
Co-authored-by: Franck Nijhof <git@frenck.dev>
2024-07-19 10:10:38 +02:00
Jan Bouwhuis
843fae825f
Revert "Remove stale template_topic code for mqtt publish service" (#121758)
Revert "Remove stale `template_topic` code for mqtt publish service (#121604)"

This reverts commit 5b25c24539.
2024-07-17 17:56:34 +02:00
epenet
e812b0e02f
Cleanup unnecessary returns (#121652) 2024-07-10 15:11:56 +02:00
Jan Bouwhuis
5b25c24539
Remove stale template_topic code for mqtt publish service (#121604) 2024-07-09 18:22:08 +02:00
Jan Bouwhuis
2040c285b1
Remove schema option for mqtt vacuum configs (#121093) 2024-07-03 21:35:20 +02:00
Marc Mueller
ca55986057
Import Generator from collections.abc (1) (#120914) 2024-07-01 11:51:51 +02:00
J. Nick Koston
8f98fb2ec4
Fix publish cancellation handling in MQTT (#120826) 2024-06-29 11:06:56 -05:00
J. Nick Koston
0ea1677f51
Increase mqtt availablity timeout to 50s (#120760) 2024-06-28 10:50:55 -05:00
Jan Bouwhuis
e567f8f3d5
Fix issue where an MQTT device is removed linked to two config entries (#120430)
* Fix issue where an MQTT device is removed linked to two config entries

* Update homeassistant/components/mqtt/discovery.py

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

* Update homeassistant/components/mqtt/debug_info.py

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

---------

Co-authored-by: J. Nick Koston <nick@koston.org>
2024-06-26 09:14:33 +02:00
Marc Mueller
0bc597f8c7
Improve vol.Invalid handling (#120480) 2024-06-26 02:13:09 +02:00
Marc Mueller
7453b7df63
Improve mqtt schema typing (#120407) 2024-06-25 13:03:18 +02:00
Jan Bouwhuis
1d16cbec96
Move mqtt debouncer to mqtt utils (#120392) 2024-06-25 10:33:58 +02:00
Marc Mueller
f0452e9ba0
Update mypy dev 1.11.0a8 (#120032) 2024-06-21 13:15:18 +02:00
Jan Bouwhuis
60ba80a28d
Only (re)subscribe MQTT topics using the debouncer (#119995)
* Only (re)subscribe using the debouncer

* Update test

* Fix test

* Reset mock
2024-06-19 23:57:18 +02:00
Jan Bouwhuis
6eb9d1e01d
Gracefully disconnect MQTT entry if entry is reloaded (#119753) 2024-06-18 09:29:22 +02:00
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