Commit Graph

158 Commits (896dd1a36bffae2a4181a4bb24d3898f44de70f3)

Author SHA1 Message Date
Jan Bouwhuis 950ee34514
Correct typing on hass_storage fixure (#87986)
Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
2023-02-13 12:12:34 +01:00
Jan Bouwhuis 0bf4896c7f
Add type hints to MQTT init tests (#87402)
* Add hass type hint and `None` return type

* Add type hints on tmp_path

* Add registry hints

* Add caplog and hass_ws_client type hints

* Add type hints for MqttMockHAClientGenerator

* Add type hints MqttMockPahoClient

* Hints on fixtures `calls` and `record_calls`

* Other fixture type hints tweaks

* Add hints for mock_usename_password_set

* Update tests/components/mqtt/test_init.py

Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>

* correct domain

---------

Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
2023-02-10 18:38:37 +01:00
Franck Nijhof 76bf6f164f
Clean up unnecessary registry mocks from mqtt tests (#87728)
* Clean up unnecessary registry mocks from mqtt tests

* Fix helper methods
2023-02-09 08:19:06 +01:00
epenet 4142f0d15d
Add return type to tests without arguments (#87613)
* Add return type to tests without arguments

* Black

* Cancel fixture amends
2023-02-07 14:20:06 +01:00
Franck Nijhof ca1a12898c
Enable Ruff D212 (#87347) 2023-02-03 23:08:48 +01:00
Jan Bouwhuis 33ede351f0
Cleanup code for parsing yaml MQTT config (#86944)
* Cleanup code for parsing yaml configs

* Add abstractmethod decorator to async_update

* Replace get() with default-list ensured by schema
2023-01-31 08:24:33 +01:00
Michael 104f74054b
Replace the usage of unit constants by enumerations in Tests [m-n] (#85935)
* replace unit conts by enums m-n

* fix mqtt
2023-01-15 15:45:00 +01:00
Jan Bouwhuis ee66ffc8de
Do not depend MQTT CI tests on debug logs (#84783)
* Do not depend MQTT CI tests on debug logs

* Leave Clean up expire as debug message
2022-12-29 18:29:28 +01:00
Jan Bouwhuis 7ed1d4988b
Add QoS parameter to MQTT websocket_subscribe (#83241) 2022-12-06 09:31:19 +01:00
Jan Bouwhuis de77132a5a
Add the QoS in the MQTT debug log (#83195)
Logging the MQTT QoS in the debug log
2022-12-04 15:03:41 +01:00
Jan Bouwhuis 4335b0db25
Clean up or correct from removed deprecation for MQTT platform (#82684)
Clean up or correct from removed deprecation
2022-11-25 16:11:22 +01:00
Jan Bouwhuis 01b0f4d565
Announce a deprecated callback for MQTT subscribe will stop working (#82610)
* Announce a deprecated callback will stop working

* Use 2 months grace period

* Use 2 months grace period

* Use 2 months grace period

* Add deprecation comment to tests
2022-11-25 10:22:12 +01:00
Jan Bouwhuis 7c2e7863d2
Remove legacy YAML support from MQTT (#82102) 2022-11-17 22:55:31 +01:00
Jan Bouwhuis 5e7f571f01
Move advanced MQTT options to entry (#79351)
* 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
Jan Bouwhuis 354411feed
Link manually added MQTT entities the the MQTT config entry (#78547)
Co-authored-by: Erik <erik@montnemery.com>
2022-09-18 12:55:31 -04:00
Jan Bouwhuis 1f410e884a
Make hass.data["mqtt"] an instance of a DataClass (#77972)
* Use dataclass to reference hass.data globals

* Add discovery_registry_hooks to dataclass

* Move discovery registry hooks to dataclass

* Add device triggers to dataclass

* Cleanup DEVICE_TRIGGERS const

* Add last_discovery to data_class

* Simplify typing for class `Subscription`

* Follow up on comment

* Redo suggested typing change to sasisfy mypy

* Restore typing

* Add mypy version to CI check logging

* revert changes to ci.yaml

* Add docstr for protocol

Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com>

* Mypy update after merging #78399

* Remove mypy ignore

* Correct return type

Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
2022-09-17 21:43:42 +02:00
Jan Bouwhuis 9a4c8f5f0e
Refactor common MQTT tests to use modern schema (#77583)
* Common tests availability

* Common tests attributes

* Common tests unique id

* Common tests discovery

* Common tests encoding

* Common tests device info

* Common tests entity_id updated

* Common tests entity debug info

* Common test entity category

* Common tests setup reload unload+corrections

* Cleanup sweep

* Comments from curent change

* Cleanup

* Remove unused legacy config
2022-09-09 11:15:48 +02:00
Jan Bouwhuis a4792998a2
Refactor MQTT tests to use modern platform schema part 1 (#77387)
* Tests alarm_control_panel

* Tests binary_sensor

* Tests button

* Tests camera

* Tests Climate + corrections default config

* Tests cover

* Tests device_tracker

* Tests fan

* Tests humidifier

* Fix test_supported_features test fan

* Tests init

* Tests legacy vacuum

* Derive DEFAULT_CONFIG_LEGACY from DEFAULT_CONFIG

* Commit suggestion comment changes
2022-09-06 11:02:15 +02:00
Erik Montnemery c55505b47b
Use mock_restore_cache in mqtt tests (#77297) 2022-08-25 09:27:38 +02:00
Jan Bouwhuis be2366d773
Add `this` object to MQTT templates (#77142)
* Add `this` object to MQTT templates

* Only set once, remove hass guard

* Set once if there is a state

* Add tests TemplateStateFromEntityId calls once
2022-08-23 08:43:07 +02:00
uvjustin 9ad273a59f
Fix entity typo (#75767) 2022-07-26 16:27:16 +02:00
Erik Montnemery 9d0a252ca7
Improve handling of MQTT config entry data (#72691)
* Improve handling of MQTT config entry data

* Add test

* Add warning

* Adjust tests
2022-07-22 13:36:43 +02:00
Jan Bouwhuis 5ef92e5e95
Fix MQTT race awaiting an ACK when disconnecting (#75117)
Co-authored-by: Erik <erik@montnemery.com>
2022-07-20 11:58:54 +02:00
Jan Bouwhuis 5930f056a8
Mqtt support config_entry unload (#70149)
* 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 19b2b33037
Speed up subscribing to mqtt topics on connect (#73685)
* Speed up subscribing to mqtt topics

* update tests

* Remove extra function wrapper

* Recover debug logging for subscriptions

* Small changes and test

* Update homeassistant/components/mqtt/client.py

* Update client.py

Co-authored-by: jbouwh <jan@jbsoft.nl>
Co-authored-by: Erik Montnemery <erik@montnemery.com>
2022-06-22 16:03:18 +02:00
Jan Bouwhuis 57daeaa174
Fix MQTT config schema to ensure correct validation (#73619)
* Ensure config schema validation

* Use correct schema for device_tracker

* Remove schema validation from the platform setup

* Remove loop to build schema
2022-06-20 08:51:12 +02:00
J. Nick Koston 51b4d15c8c
Speed up mqtt tests (#73423)
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 657e7f9a4c
Simplify MQTT test for setup manual mqtt item from yaml (#72916)
simplify test setup manual mqtt item from yaml
2022-06-13 13:44:12 +02:00
Jan Bouwhuis 48e3d68b53
Clean up MQTT platform entry setup at discovery (#72371)
* Setup MQTT discovery with entry setup

* Wait for entry setup in test

* flake
2022-06-13 13:38:53 +02:00
Jan Bouwhuis 52561ce076
Update MQTT tests to use the config entry setup (#72373)
* 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 635d7085cf
Move MQTT config schemas and client to separate modules (#71995)
* Move MQTT config schemas and client to separate modules

* Update integrations depending on MQTT
2022-05-31 09:32:44 +02:00
Erik Montnemery 342ccb5bf1
Improve handling of MQTT overridden settings (#72698)
* Improve handling of MQTT overridden settings

* Don't warn unless config entry overrides yaml
2022-05-30 14:21:20 +02:00
Jan Bouwhuis ed1c2ea2b8
Move manual configuration of MQTT fan and light to the integration key (#71676)
* Processing yaml config through entry setup

* Setup all platforms

* Update homeassistant/components/mqtt/__init__.py

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

* adjust mock_mqtt - reference config from cache

* Fix test config entry override

* Add tests yaml setup

* additional tests

* Introduce PLATFORM_SCHEMA_MODERN

* recover temporary MQTT_BASE_PLATFORM_SCHEMA

* Allow extra key in light base schema, restore test

* Fix test for exception on platform key

* One deprecation message per platform

* Remove deprecation checks from modern schema

* Update homeassistant/components/mqtt/fan.py

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

* Update homeassistant/components/mqtt/fan.py

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

* Update homeassistant/components/mqtt/light/__init__.py

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

* Update homeassistant/components/mqtt/light/__init__.py

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

* Update homeassistant/components/mqtt/light/schema_json.py

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

* Update homeassistant/components/mqtt/light/schema_template.py

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

* Update homeassistant/components/mqtt/mixins.py

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

* rename validate_modern_schema

* Do not fail platform if a single config is broken

* Update homeassistant/components/mqtt/__init__.py

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

* Fix tests on asserting log

* Update log. Make helper transparant, remove patch

* Perform parallel processing

* Update tests/components/mqtt/test_init.py

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

* Apply suggestions from code review

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

* Update homeassistant/components/mqtt/mixins.py

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

* black

* Fix tests and add #new_format anchor

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
Co-authored-by: Erik Montnemery <erik@montnemery.com>
2022-05-19 15:04:53 +02:00
epenet 141688e210
Cleanup ServiceInfo compatibility (#60540)
Co-authored-by: epenet <epenet@users.noreply.github.com>
Co-authored-by: J. Nick Koston <nick@koston.org>
2022-05-09 14:17:48 +02:00
Erik Montnemery e9abfad361
Reject MQTT topics which include control- or non-characters (#71263) 2022-05-03 12:19:43 -07:00
Erik Montnemery 9b21a48048
Mend incorrectly imported MQTT config entries (#68987)
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2022-04-01 08:11:31 -07:00
Jan Bouwhuis 5ab4b5d15a
MQTT Improve warning override deprecated settings (#67609) 2022-03-04 12:39:29 +01:00
Jan Bouwhuis a97fe7aae0
Mqtt fix issue with displaying non UTF-8 payload (#67471)
* Mqtt fix issue with displaying non UTF-8 payload

* None or binary

* Casting and additional test

* casting
2022-03-02 17:01:47 +01:00
Erik Montnemery 5e4b16c69a
Remove custom WS command for removing MQTT devices (#67381)
* Remove custom WS command for removing MQTT devices

* Re-add removed test
2022-02-28 15:50:49 +01:00
Erik Montnemery c7d59bb272
Fix race when unsubscribing from MQTT topics (#67376)
* Fix race when unsubscribing from MQTT topics

* Improve test
2022-02-28 14:19:50 +01:00
Jan Bouwhuis 8dbb184ed5
Add MQTT publish ACK timeout test (#67062) 2022-02-23 12:30:13 +01:00
Jan Bouwhuis 845bf80e72
Mqtt improve test coverage (#66279)
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2022-02-23 12:29:32 +01:00
Erik Montnemery 98982c86e4
Add MQTT diagnostics (#66730)
* Add MQTT diagnostics

* Redact device tracker location

* Adjust tests

* Address comments from code review
2022-02-18 09:28:49 +01:00
Erik Montnemery fe38e6ba87
Drop MQTT import flow (#66160)
* Drop MQTT import flow

* Reload manually configured MQTT entities when config entry is setup

* Address review comments

* Actually remove the import flow
2022-02-10 21:09:57 +01:00
Erik Montnemery 55d8314093
Fix cleanup of MQTT debug info (#66104) 2022-02-08 12:49:25 -08:00
Erik Montnemery 8245ff7473
Log transmitted MQTT messages (#65550) 2022-02-04 17:35:32 +01:00
Erik Montnemery fda0fbd115
Stringify MQTT payload in mqtt/debug/info WS response (#65429) 2022-02-02 18:08:48 +01:00
Jan Bouwhuis 31a9d64572
Improve code coverage MQTT integration (#64546) 2022-01-20 13:51:19 +01:00
Jan Bouwhuis 3ca18922e6
Mqtt rework on value templates (#62105)
* add MqttValueTemplate class

* support variables at initiation

* pass MqttEntity instead of hass

* Use MqttValueTemplace class for value templates

* make hass en enitity parameters conditional

* remove unused property and remove None assignment

* rename self._attr_value_template
2022-01-03 16:07:40 +01:00
Jan Bouwhuis 457ce195dd
Add mqtt entity attributes command templates (#61937)
* Add entity variables to MqttCommandTemplate

* missing command template update

* make hass and entity conditional parameters

* Add encoding support for publishing

* Revert "Add encoding support for publishing"

This reverts commit b69b9c60ec.
2022-01-03 15:10:15 +01:00