Commit graph

57 commits

Author SHA1 Message Date
Jan Bouwhuis
39f5f30ca9
Revert "Allow MQTT device based auto discovery" ()
Revert "Allow MQTT device based auto discovery ()"

This reverts commit 585892f067.
2024-06-03 22:30:37 +02:00
Jan Bouwhuis
585892f067
Allow MQTT device based auto discovery ()
* 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
Jan Bouwhuis
bfc3194661
Fix mqtt not publishing null payload payload to remove discovery () 2024-05-27 12:53:22 -10:00
J. Nick Koston
ad638dbcc5
Speed up removing MQTT subscriptions () 2024-05-25 10:28:14 +02:00
epenet
ad84ff18eb
Use remove_device helper in tests (1/2) ()
* Use remove_device helper in tests

* Update test_tag.py

* Update test_tag.py
2024-04-30 12:52:33 +02:00
Sid
d5f883fbf0
Unignore Ruff PLR in tests ()
* Unignore Ruff PLR in tests

* Address review comments

* review comments

* fix import

* Update test_api.py

* Update test_api.py

* Update test_api.py
2024-04-01 11:11:59 +02:00
Jan Bouwhuis
caaa03536b
Cleanup mqtt PLATFORMS constant and CI-test platform filters () 2024-03-09 23:48:54 +01:00
Marc Mueller
32f3f46542
Add empty line after module docstring (2) [tests.components] () 2024-03-08 19:16:21 +01:00
Jan Bouwhuis
6ca002a6f4
Improve tests of mqtt device triggers ()
Improve tests on mqtt device triggers
2024-02-06 09:38:15 +01:00
Jan Bouwhuis
04f0128a1c
Simplify MQTT device triggers in automations ()
* Simplify MQTT device trigger

* Add test non unique trigger_id

* Adjust deprecation warning

* Make discovery_id optional

* refactor double if

* Improve validation, add tests and deprecation comments

* Avoid breaking change

* Inmprove error message

* Match on discovery_id instead of discovery_info

* Revert an unrelated change

* follow up comments

* Add comment and test on device update with non unique trigger

* Update homeassistant/components/mqtt/device_trigger.py

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

* Update homeassistant/components/mqtt/device_trigger.py

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

---------

Co-authored-by: Erik Montnemery <erik@montnemery.com>
2024-01-30 20:50:39 +01:00
Jan Bouwhuis
26058bf922
Add serial_number attribute to MQTT device properties () 2024-01-16 14:02:34 +01:00
Jan-Philipp Benecke
9326ea09a5
Update m* tests to use entity & device registry fixtures () 2023-11-15 10:33:11 +01:00
Erik Montnemery
7539cf25be
Don't require passing identifiers to DeviceRegistry.async_get_device ()
* Require keyword arguments to DeviceRegistry.async_get_device

* Update tests

* Update tests

* Don't enforce keyword arguments
2023-07-13 13:39:25 -04:00
Erik Montnemery
fd822bce56
Replace assert_lists_same with pytest_unordered in integrations h-m () 2023-06-20 20:16:25 +02:00
Jan Bouwhuis
ec98e22330
Add type hints for stub_blueprint_populate fixture ()
Add typehints for stub_blueprint_populate fixture
2023-05-26 08:13:13 +02:00
Erik Montnemery
3cca338c6e
Improve blueprint test fixtures () 2023-05-25 13:45:19 +02:00
Jan Bouwhuis
bb15923968
Rename MQTT entry mock and cleanup ()
Rename to mqtt_mock_entry and cleanup
2023-04-12 09:43:03 +02:00
Jan Bouwhuis
c81a38effb
Mqtt prepare test base part1 ()
* Refactor test_reloadable

* Refactor test_disabling_and_enabling_entry

* optimize test_unload_config_entry

* Cleanup help_test_unload_config_entry

* cleanup test_unload_entry

* Update test tls_version

* More tests to entry only

* Add validate and hassconfig patch

* Revert fixture changes patch_hass_config

* Follow up comments
2023-03-16 15:57:01 +01:00
Jan Bouwhuis
1a38b9f665
Improve coverage MQTT device_trigger ()
* Improve coverage MQTT device_trigger

* Use assert
2023-02-09 17:42:32 +01:00
Jan Bouwhuis
dc5f35a85e
Add missed type hints on MQTT platform tests () 2023-02-09 15:22:30 +01:00
epenet
bb174780b9
Apply registry type hints on mqtt platform tests ()
Apply registry fixture types on platform tests
2023-02-09 11:53:56 +01:00
Jan Bouwhuis
df76e31cdf
Apply MQTT fixture types on platform tests ()
* Apply MQTT fixture types on platform tests

* Add caplog type hint

* Add hass_ws_client type hint

* Add tmp_path type hint

* Add hass_client_no_auth type hint
2023-02-09 09:48:22 +01:00
Franck Nijhof
76bf6f164f
Clean up unnecessary registry mocks from mqtt tests ()
* Clean up unnecessary registry mocks from mqtt tests

* Fix helper methods
2023-02-09 08:19:06 +01:00
Jan Bouwhuis
1a414f1433
Add hass and None return type on MQTT platform tests ()
Add hass and `None` return type on MQTT tests
2023-02-08 18:08:03 +01:00
Jan Bouwhuis
a3e6abd396
Use hass.config_entries.async_setup in mqtt test ()
* Use hass.config_entries.async_setup

* The setup is awaited hence waiting is not needed
2022-09-03 15:44:50 +02:00
Jan Bouwhuis
2e34814d7a
Fix reload of MQTT config entries ()
* Wait for unsubscribes

* Spelling comment

* Remove notify_all() during _register_mid()

* Update homeassistant/components/mqtt/client.py

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

* Correct handling reload manual set up MQTT items

* Save and restore device trigger subscriptions

* Clarify we are storing all remaining subscriptions

Co-authored-by: Erik Montnemery <erik@montnemery.com>
2022-09-02 18:54:20 +02:00
Franck Nijhof
5f0cca9b26
Raise repairs issue if automation calls unknown service () 2022-08-25 20:56:26 -04:00
Maciej Bieniek
ad6beac535
Add hw_version to MQTT device info ()
* Add hw_version

* Add abbreviation for hw_version

* Update tests

* Update discovery tests
2022-08-25 11:55:33 +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
J. Nick Koston
51b4d15c8c
Speed up mqtt tests ()
Co-authored-by: jbouwh <jan@jbsoft.nl>
Co-authored-by: Jan Bouwhuis <jbouwh@users.noreply.github.com>
2022-06-13 10:17:10 -10:00
Jan Bouwhuis
52561ce076
Update MQTT tests to use the config entry setup ()
* New testframework and tests for fan platform

* Merge test_common_new to test_common

* Add alarm_control_panel

* Add binary_sensor

* Add button

* Add camera

* Add climate

* Add config_flow

* Add cover

* Add device_tracker_disovery

* Add device_trigger

* Add diagnostics

* Add discovery

* Add humidifier

* Add init

* Add lecacy_vacuum

* Add light_json

* Add light_template

* Add light

* Add lock

* Add number

* Add scene

* Add select

* Add sensor

* Add siren

* Add state_vacuum

* Add subscription

* Add switch

* Add tag

* Add trigger

* Add missed tests

* Add another missed test

* Add device_tracker

* Remove commented out code

* Correct tests according comments

* Improve mqtt_mock_entry and recover tests

* Split fixtures with and without yaml setup

* Update fixtures manual_mqtt

* Update fixtures mqtt_json

* Fix test tasmota

* Update fixture mqtt_room

* Revert fixture changes, improve test

* re-add test
2022-06-02 14:24:46 +02:00
Erik Montnemery
5e50a8abd5
Mark device triggers from hidden or auxiliary entities as secondary ()
* Mark device triggers from hidden or auxiliary entities as secondary

* Update tests
2022-04-21 08:01:32 +02:00
Erik Montnemery
5e4b16c69a
Remove custom WS command for removing MQTT devices ()
* Remove custom WS command for removing MQTT devices

* Re-add removed test
2022-02-28 15:50:49 +01:00
Erik Montnemery
ba6d1976df
Improve MQTT device removal ()
* Improve MQTT device removal

* Update homeassistant/components/mqtt/mixins.py

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* Adjust tests

* Improve test coverage

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2022-02-18 13:45:25 +01:00
Erik Montnemery
8245ff7473
Log transmitted MQTT messages () 2022-02-04 17:35:32 +01:00
Ville Skyttä
f913961d63
Use DeviceAutomationType in tests/components/[m-r]* () 2021-12-20 22:29:22 +01:00
Erik Montnemery
640a7fee9d
Allow extra keys in MQTT discovery messages ()
* Allow extra keys in MQTT discovery messages

* Remove extra keys
2021-10-25 13:47:06 +02:00
Ville Skyttä
b10fc89a6b
Automation trigger info type hint improvements ()
* Make automation trigger info a TypedDict

* zwave_js trigger type hint fixes

* Remove redundant automation trigger info field presence checks

* Use async_initialize_triggers in mqtt and tasmota device_trigger tests
2021-09-04 02:25:51 +02:00
Erik Montnemery
d4d335fb9c
Fix MQTT debug info for removed triggers () 2021-05-20 10:27:38 +03:00
Ville Skyttä
77d5244577
Use device registry CONNECTION_* constants () 2021-04-30 23:58:50 +02:00
Erik Montnemery
84226da404
Update tests i-o to use async_get() instead of async_get_registry() () 2021-03-09 14:32:08 +01:00
Ville Skyttä
dc880118a4
Lint suppression cleanups ()
* Unused pylint suppression cleanups

* Remove outdated pylint bug references

* Add flake8-noqa config and note to run it every now and then

* Add codes to noqa's

* Unused noqa cleanups
2021-03-02 09:02:04 +01:00
Erik Montnemery
19cd29affa
Fix MQTT trigger where wanted payload may be parsed as an integer () 2021-02-28 12:19:27 -08:00
Ville Skyttä
2fb3be50ab
Make DeviceRegistry.async_get_device connections arg optional ()
* Make async_get_device connections Optional, default None

* Remove unnecessary async_get_device connections arg usages

Some of these were using an incorrect collection type, which didn't
cause issues mostly just due to luck.
2021-01-07 13:49:45 +01:00
Paulus Schoutsen
b3be708db6
Add default config if not there ()
Co-authored-by: Bram Kragten <mail@bramkragten.nl>
2020-11-25 15:10:04 +01:00
Erik Montnemery
306ee30574
Enable MQTT discovery by default () 2020-10-07 14:51:06 +02:00
Erik Montnemery
280f49540e
Drop use of async_mock_mqtt_component () 2020-06-22 23:59:50 +02:00
Erik Montnemery
16cf16e418
Update MQTT tests to not create duplicated config entries () 2020-06-15 15:38:56 -07:00
Erik Montnemery
35cd6b9abf
Remove unused parameter for MQTT discovery ()
* Remove unused parameter for MQTT discovery

* Fix tests
2020-06-07 19:35:35 +02:00
Erik Montnemery
f1af5b71e2
Correct MQTT device trigger reconfiguration with same topic () 2020-05-28 15:50:23 -07:00