Commit graph

607 commits

Author SHA1 Message Date
anotherthomas
179cc4d7f7
Improve warnings in mqtt light messages ()
* improved warnings in mqtt light messages.

* fixed tests.
2023-03-13 14:46:16 +01:00
Jan Bouwhuis
1a4b14c217
Fix MQTT rgb light brightness scaling ()
* Normalize received RGB colors to 100% brightness

* Assert on rgb_color attribute

* Use max for RGB to get brightness

* Avoid division and add clamp

* remove clamp

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

---------

Co-authored-by: Erik Montnemery <erik@montnemery.com>
2023-03-09 08:02:59 +01:00
Jan Bouwhuis
366baef7f6
Allow enum as MQTT sensor device_class () 2023-03-08 22:35:06 +01:00
Jan Bouwhuis
5ee383456f
Catch exceptions and add logging when writing states on MQTT entities ()
* Catch exceptions when writing states

* Do not use wrapper for logging and adjust tests

* Catch logging directly on async_write_ha_state()

* Update homeassistant/components/mqtt/models.py

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

* Fix test

---------

Co-authored-by: Erik Montnemery <erik@montnemery.com>
2023-03-06 15:34:47 +01:00
Jan Bouwhuis
a9becd8e0e
Raise ValueError on date parsing of MQTT sensor with invalid date format ()
* Suppress ValueError on date parsing of MQTT sensor

* Simplify, but not update state on invalid payload

* Still raise an an invalid date

* Make datetime state unknown on invalid format

* remove unrelated added new line
2023-03-05 17:06:48 +01:00
Jan Bouwhuis
ae04c5d773
Clean up unused and deprecated TLS version setting on MQTT client ()
* Cleanup CONF_TLS_VERSION remains

* Fix diagnostics tests
2023-03-01 18:42:34 +01:00
Jan Bouwhuis
3f79155df6
Remove deprecated callback support for MQTT subscribe ()
* Remove deprecated callback support and fix tests

* Add note with removal instruction
2023-02-21 22:21:00 +01:00
Jan Bouwhuis
57738fbb8c
Replace deprecated SSLContext constant PROTOCOL_TLS in mqtt ()
Replace deprecated SSLContext constants
2023-02-16 13:01:28 -05:00
J. Nick Koston
d2277fa6db
Fix restore of MQTT subscriptions from reload () 2023-02-16 11:14:26 -06:00
epenet
ba23816a0c
Inverse json import logic ()
* Fix helpers and util

* Adjust components

* Move back errors

* Add report

* mypy

* mypy

* Assert deprecation messages

* Move test_json_loads_object

* Adjust tests

* Fix rebase

* Adjust pylint plugin

* Fix plugin

* Adjust references

* Adjust backup tests
2023-02-16 11:37:57 +01:00
Jan Bouwhuis
03e9dff327
Allow resetting MQTT climate attributes and ignore empty values ()
Allow reseting MQTT climate attributes
2023-02-15 16:31:49 +01:00
Franck Nijhof
ed79265843
Enable Ruff PT006 ()
* Enable Ruff PT006

* Adjust existing cases

* Fix tests

* Remove unneeded parentheses
2023-02-15 14:09:50 +01:00
Franck Nijhof
9030ca05b1
Enable Ruff SIM118 () 2023-02-15 12:39:12 +01:00
epenet
50cbabb2d8
Add type hints to integration tests (part 15) () 2023-02-15 10:00:49 +01:00
Jan Bouwhuis
6c23d6abfe
Fix doc string in mqtt test ()
Fix docstr
2023-02-15 05:56:03 +01:00
J. Nick Koston
c54500cb1f
Fix invalid spec in mqtt tests for py3.11 ()
Fix invalid spec in mqtt tests

unittest.mock.InvalidSpecError: Cannot spec a Mock object.
2023-02-14 11:28:46 -05:00
Jan Bouwhuis
950ee34514
Correct typing on hass_storage fixure ()
Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
2023-02-13 12:12:34 +01:00
Jan Bouwhuis
41a92a872f
Add missed type hint on MQTT device tracker test () 2023-02-10 22:42:56 +01:00
Jan Bouwhuis
0bf4896c7f
Add type hints to MQTT init tests ()
* 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
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
a244f9b202
Add type hints tests MQTT config_flow () 2023-02-09 16:47:28 +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
Franck Nijhof
330e1c6cbb
Clean up unnecessary registry mocks from integration tests () 2023-02-09 10:43:45 +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
b93c135c8d
Add type hints for MQTT discovery tests ()
* Add type hints for MQTT discovery tests

* Remove more unused caplog instances

* rebase commit

* Small corrections

* Add event tye hint and correct string assignment

* Another Event type hint

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

* Correct test_complex_discovery_topic_prefix

* Import individual items from homeassistant.core

---------

Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
2023-02-08 20:56:27 +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
fc7e4b7664
Add type hints on common MQTT tests ()
* Add hints for hass and return type

* Fix MqttMockType add apply hints to test_common

* Add type hints for other arguments

* Merge changes

* Add missed annotation

* Make tests types private and move to top
2023-02-08 11:20:27 +01:00
epenet
59ca7780fa
Add typing to tests with single hass argument () 2023-02-07 15:01:16 +01:00
epenet
4142f0d15d
Add return type to tests without arguments ()
* Add return type to tests without arguments

* Black

* Cancel fixture amends
2023-02-07 14:20:06 +01:00
Jan Bouwhuis
c78cae4483
Fix handling None or empty value for numeric MQTT sensor ()
* Allow `None` for numeric sensor, ignore empty val

* Add test case with omitting a value

* Use _numeric_state_expected property

* Only respect None if numeric state is expected
2023-02-07 11:23:23 +01:00
epenet
aa00114c2f
Add return type to async tests without arguments () 2023-02-07 10:26:56 +01:00
Jan Bouwhuis
73e3b30906
Add suggested_display_precision config option for MQTT sensor ()
* Add precision for MQTT sensor

* Correct tests

* Use _attr_suggested_display_precision

* Rename option and add abbreviation

* Make abbr more compact
2023-02-07 08:55:35 +01:00
Franck Nijhof
ca1a12898c
Enable Ruff D212 () 2023-02-03 23:08:48 +01:00
Franck Nijhof
5e81d28116
Update black to 23.1.0 () 2023-02-02 18:35:24 +01:00
Jan Bouwhuis
33ede351f0
Cleanup code for parsing yaml MQTT config ()
* 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
Jan Bouwhuis
e57dad79fc
Fix MQTT discovery failing after bad config update ()
* Fix MQTT discovery failing after bad config update

* Update last discovery payload after update success

* Improve test, correct update assignment

* send_discovery_done to finally-catch vol.Error

* Just use try..finally

* Remove extra line

* use elif to avoid log confusion
2023-01-30 19:15:11 +01:00
Franck Nijhof
57cf11f067
Enable Ruff PT015 () 2023-01-27 11:10:29 +01:00
Franck Nijhof
e50a531cd9
Code styling tweaks to the tests - Part 2 ()
Co-authored-by: jjlawren <jjlawren@users.noreply.github.com>
2023-01-26 01:23:53 +01:00
Jan Bouwhuis
f719ecf086
Add command template and code_format support for MQTT lock ()
* Add command template for MQTT lock

* Fix tests
2023-01-23 14:48:07 +01:00
Jan Bouwhuis
92742ae423
Add jammed state support for MQTT lock ()
* Add jammed state support for MQTT lock

* Correct payload jammed key

* Add tests - rename solved to ok

* Rename jammed state and template topics to motor

* Use state topic for handling motor state

* Follow up comments

* Change default behaviour `state_unjammed`

* Skip `state_unjammed`
2023-01-20 12:19:26 +01:00
epenet
bcef0d66ac
Remove invalid uom from mqtt tests () 2023-01-16 14:51:35 +01:00
Patrick ZAJDA
0b02abf708
Add locking and unlocking to MQTT lock ()
* Implement locking, unlocking and jammed on MQTT lock

Signed-off-by: Patrick ZAJDA <patrick@zajda.fr>

* Add tests

Signed-off-by: Patrick ZAJDA <patrick@zajda.fr>

* Refactor condition

Signed-off-by: Patrick ZAJDA <patrick@zajda.fr>

* Parametrize tests

Signed-off-by: Patrick ZAJDA <patrick@zajda.fr>

* Manage only locking and unlocking

Signed-off-by: Patrick ZAJDA <patrick@zajda.fr>

* Remove jammed from abbreviations

Co-authored-by: Jan Bouwhuis <jbouwh@users.noreply.github.com>

* set valid states in self._valid_states

Signed-off-by: Patrick ZAJDA <patrick@zajda.fr>

Signed-off-by: Patrick ZAJDA <patrick@zajda.fr>
Co-authored-by: Jan Bouwhuis <jbouwh@users.noreply.github.com>
2023-01-16 08:42:43 +01:00
Jan Bouwhuis
01e1e254e2
Use value of enum () 2023-01-15 19:30:29 +01:00
Michael
104f74054b
Replace the usage of unit constants by enumerations in Tests [m-n] ()
* replace unit conts by enums m-n

* fix mqtt
2023-01-15 15:45:00 +01:00
Jan Bouwhuis
64e235285d
Deprecate power_command_topic for MQTT climate ()
* Deprecate mode_command_topic for MQTT climate

* Correct deprecation and remove support release inf

* Do not use future tense for comment

* Extend deprecation period to 6 months
2023-01-12 09:49:14 +01:00
Jan Bouwhuis
ee21bc5d7f
Allow MQTT device_class or state_class to be set as None ()
* Allow MQTT device_class to be set as `None`

* Add test

* Also allow sensor state_class to be `None`
2023-01-04 15:21:07 +01:00
Jan Bouwhuis
9f24897814
Do not reset current selection on reconfig or MQTT select ()
* Do not reset current selection on reconfig

* Add a test
2023-01-04 10:29:53 +01:00
Jan Bouwhuis
b29c96639b
Correct initial config of MQTT climate ()
* Do not reset MQTT climate state on re-config

* More corrections

* Correct startup behavior in optimistic mode
2023-01-04 10:29:02 +01:00