Commit Graph

924 Commits (2cd44567627c5e7ba44baf28191c76512d856b08)

Author SHA1 Message Date
J. Nick Koston 0ed56694b0
Migrate MQTT EnsureJobAfterCooldown to use eager start (#115977) 2024-04-22 20:09:45 +02:00
Sid 895f73d8e4
Enable Ruff A001 (#115654) 2024-04-21 23:25:27 +02:00
J. Nick Koston 423544401e
Convert MQTT to use asyncio (#115910) 2024-04-21 22:33:58 +02:00
Jan Bouwhuis 8275512130
Add mqtt notify platform (#115653)
* Add mqtt notify platform

* Stale docstring
2024-04-17 20:07:11 +02:00
Sid 3efee10b95
Enable Ruff RUF013 (#115333) 2024-04-10 08:55:59 +02:00
epenet 0b01326f9f
Use is in ConfigEntryState enum comparison in tests (A-M) (#114925) 2024-04-05 17:16:55 +02:00
Joost Lekkerkerker b9281327c4
Use FlowResultType enum in config flow tests A-M (#114681) 2024-04-03 09:21:17 +02:00
Joost Lekkerkerker 5d500cb74b
Use is in enum comparison in config flow tests K-O (#114672) 2024-04-02 11:21:42 -10:00
Sid d5f883fbf0
Unignore Ruff PLR in tests (#114470)
* 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 5e3ce80488
Remove stale test for mqtt climate (#114443) 2024-03-29 16:01:50 +01:00
Marc Mueller 443bfee16d
Replace partial annotations (#114177) 2024-03-28 18:33:39 +01:00
Jan-Philipp Benecke 22b14d83e8
Use `setup_test_component_platform` helper for sensor entity component tests instead of `hass.components` (#114316)
* Use `setup_test_component_platform` helper for sensor entity component tests instead of `hass.components`

* Missing file

* Fix import

* Remove invalid device class
2024-03-28 12:07:55 +01:00
Joost Lekkerkerker 6bb4e7d62c
Bump ruff to 0.3.4 (#112690)
Co-authored-by: Sid <27780930+autinerd@users.noreply.github.com>
Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
Co-authored-by: J. Nick Koston <nick@koston.org>
2024-03-26 00:02:16 +01:00
Jan Bouwhuis 18174ad47d
Improve test coverage mqtt discovery test (#114188) 2024-03-25 22:41:11 +01:00
Marc Mueller 9b7cc088be
Fix spelling [runtime] (#114169) 2024-03-25 11:32:50 +01:00
Erik Montnemery 426f73b1f4
Add State.last_reported (#113511)
* Add State.last_reported

* Update tests

* Update test snapshots

* Call state_reported listeners when firing state_changed event

* Add tests
2024-03-20 21:05:07 +01:00
Jan Bouwhuis 3dc8df2403
Get ServiceValidationError message from translation cache only (#113704)
* Get ServiceValidationError message from translation cache only

* Remove message for NotValidPresetModeError
2024-03-18 14:42:21 +01:00
Sid d5fd005db8
Add ruff rule PIE808 (#113621) 2024-03-17 09:56:26 +01:00
Sid b261f124d6
fix mqtt siren test asserts (#113550) 2024-03-15 21:59:30 +01:00
soonsouth cfc2f17f35
Remove repetitive words in comments and docstrings (#113529)
chore: remove repetitive words

Signed-off-by: soonsouth <cuibuwei@163.com>
2024-03-15 18:11:12 +01:00
J. Nick Koston c1f5c7c4b7
Remove usage of async_add_job in tests (#113259) 2024-03-13 19:33:33 -10:00
Joost Lekkerkerker 595d07f1c6
Improve lists in integrations [L-M] (#113227)
* Improve lists in integrations [L-M]

* Update homeassistant/components/mailbox/__init__.py

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

* Fix

---------

Co-authored-by: Jan Bouwhuis <jbouwh@users.noreply.github.com>
2024-03-13 21:28:21 +01:00
Jan Bouwhuis 488dae43d4
Improve lists for MQTT integration (#113184)
* Improve lists for MQTT integration

* Extra diagnostics tests

* Revert changes where the original version was probably faster

* Revert change to gather and await in series
2024-03-13 11:04:59 +01:00
Jan Bouwhuis e28d4f0eae
Validate state_class with last_reset_value_template for mqtt sensors (#113099) 2024-03-12 09:08:03 +01:00
Joost Lekkerkerker cddce0ce0d
Enable more SIM ruff rules (#113015)
* SIM101 SIM103

* SIM107 SIM109

* SIM110

* SIM112 SIM113

* SIM115

* SIM116

* Fix

* Fix

* Fix
2024-03-10 23:20:37 -04:00
Jan Bouwhuis 02ef7ba134
Remove not needed hass.async_block_till_done in test (#113002) 2024-03-10 09:46:25 -10:00
Jan Bouwhuis c608d1cb85
Fix mqtt platform setup race (#112888) 2024-03-10 08:36:17 -10:00
Jan Bouwhuis caaa03536b
Cleanup mqtt PLATFORMS constant and CI-test platform filters (#112847) 2024-03-09 23:48:54 +01:00
Jan Bouwhuis 3b0ea52167
Allow Just-in-Time platform setup for mqtt (#112720)
* 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
Jan Bouwhuis 6534943837
Revert "Cleanup mqtt discovery code" (#112818)
Revert "Cleanup mqtt discovery code (#112749)"

This reverts commit 87318c9111.
2024-03-09 12:54:10 +01:00
Jan Bouwhuis 87318c9111
Cleanup mqtt discovery code (#112749)
* Cleanup mqtt discovery code

* Cleanup mqtt discovery code
2024-03-09 11:54:27 +01:00
Marc Mueller 959826c4b4
Update byte string formatting (#112752) 2024-03-08 20:32:40 +01:00
Marc Mueller 32f3f46542
Add empty line after module docstring (2) [tests.components] (#112737) 2024-03-08 19:16:21 +01:00
Marc Mueller 1722e23df8
Add empty line after module docstring [tests l-p] (#112710) 2024-03-08 14:55:15 +01:00
Jan Bouwhuis 0c2cf881ac
Deprecate old config options for MQTT json light (#111676)
* add deprecaction

* Deprecate old config options for mqtt json light

* Do not deprecate brightness flag

* Enable brightness support by default

* Keep `false` as default for brightness flag

* Add warnings and register issue

* log warning and register on use of color_mode flag

* Remove redundant cv.deprecated logging + follow up comments
2024-03-05 08:49:05 +01:00
Jan Bouwhuis c13231fc00
Improve mqtt value template error logging (#110492)
* Refactor mqtt value template error logging

* Remove import
2024-03-04 08:49:12 +01:00
Jan Bouwhuis 1b2e669302
Improve handling mqtt command template exceptions (#110499)
* Improve handling mqtt command template exceptions

* Fix test

* Cleanup stale exception handler

* Throw on topic template exception
2024-02-26 11:04:55 +01:00
J. Nick Koston 5b8591ec7e
Avoid reschedule churn in Storage.async_delay_save (#111091)
* Avoid circular import in Storage.async_delay_save

We call Storage.async_delay_save for every entity being added or removed
from the registry. The late import took more time than everything else
in the function.

* Avoid reschedule churn in Storage.async_delay_save

When we are adding or removing entities we will call async_delay_save
quite often which has to add and remove a TimerHandle on the event loop
which can add up when there are a lot of registry items changing.

If the timer handle still has 80% of the time remaining on it
we will avoid resceduling and let it fire at the time the
original async_delay_save call was made. This ensures we
do not force the event loop to rebuild its heapq because
too many timer handlers were cancelled at once

* div0

* add coverage for 0 since we had none

* fix bad conflict

* tweaks

* tweaks

* tweaks

* tweaks

* tweaks

* tweaks

* more test fixes

* mqtt tests rely on event loop overhead
2024-02-24 08:46:00 +01:00
Jan Bouwhuis c048b840fc
Do not directly call async_setup_entry in MQTT tests (#111010) 2024-02-21 07:47:30 +01:00
Jan Bouwhuis f4fd3633b4
Improve timing mqtt integration discovery test (#110960)
* Improve timing mqtt integration discovery test

* Remove condition
2024-02-19 20:16:06 +01:00
J. Nick Koston b35d7a348b
Fix mqtt discovery subscribe unsubscribe test with one less task (#110914)
This test currently relies on event loop overhead and since #110899
will remove another task in the config entry init flow, it needs
another async_block_till_done. In the future it should be refactored
to have better synchronization without having to rely on iterations
of the event loop.
2024-02-19 07:36:32 +01:00
Artur Pragacz 3392660537
Add toggle service to climate (#100418)
* Add toggle service to climate

* Fix mqtt test

* Add comments

* Fix rebase

* Remove not needed properties

* Fix toggle service

* Fix test

* Test

* Mod mqtt test

---------

Co-authored-by: G Johansson <goran.johansson@shiftit.se>
2024-02-16 15:53:48 +01:00
Jan Bouwhuis 09f1ec78a5
Handle template errors on MQTT payload handling (#110180)
* Handle template errors on MQTT payload handling (alt)

* Handle mqtt event en image template errors correctly
2024-02-13 10:59:55 +01:00
J. Nick Koston 04dccc7ec6
Migrate mqtt to use async_update_entry to alter config entries (#110407) 2024-02-12 21:38:13 +01:00
Jan Bouwhuis 6ca002a6f4
Improve tests of mqtt device triggers (#108318)
Improve tests on mqtt device triggers
2024-02-06 09:38:15 +01:00
Jan Bouwhuis 00947b708f
Remove aux heat support from mqtt climate (#109513) 2024-02-06 09:37:39 +01:00
Marc Mueller a9147cf3dd
Use builtin TimeoutError [k-n] (#109681) 2024-02-05 12:08:18 +01:00
Jan Bouwhuis 04f0128a1c
Simplify MQTT device triggers in automations (#108309)
* 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 6023980c2e
Set TURN_ON and TURN_OFF feature on MQTT climate entities (#109146) 2024-01-30 19:35:46 +01:00
G Johansson bc720b48b4
Add TURN_OFF and TURN_ON to ClimateEntityFeature (#101673)
* Add ClimateEntityFeature.TURN_OFF

* Fixes

* Fixes

* wording

* Change to services

* Fixing

* Fixing

* Last bits

* Review comments

* Add hvac_modes checks

* Fixes

* Add tests

* Review comments

* Update snapshots

* balboa

* coolmaster

* ecobee

* mqtt

* nest

* plugwise

* smarttub

* whirlpool

* zwave_js

* fix test climate

* test climate

* zwave

* nexia

* nuheat

* venstar

* tado

* smartthings

* self.hvac_modes not None

* more tests

* homekit_controller

* homekit controller snapshot
2024-01-30 15:07:47 +01:00
Robert Resch 6fdad44941
Improve invalid error messages in the config flows (#108075) 2024-01-30 12:24:19 +01:00
Jan Bouwhuis 7bec5ef6bc
Use unknown color_mode for MQTT json lights if color mode is not set (#108909) 2024-01-26 14:42:47 +01:00
J. Nick Koston c399cab427
Small speed up to checking core state (#107845) 2024-01-18 08:41:32 -10:00
Jan Bouwhuis 26058bf922
Add serial_number attribute to MQTT device properties (#108105) 2024-01-16 14:02:34 +01:00
Jan Bouwhuis e0457590d1
Fix mqtt text text min max config params can not be equal (#107738)
Fix mqtt text text min max kan not be equal
2024-01-11 07:17:48 +01:00
Jan Bouwhuis 9ad3c8dbc9
Remove MQTT legacy vacuum support (#107274) 2024-01-08 09:22:43 +01:00
Jan Bouwhuis f0ec1235b1
Remove naming warnings and work-a-rounds for incorrectly configured MQTT entities (#107188)
* Remove naming warnings for MQTT entities

* Remove unused const
2024-01-05 09:32:22 +01:00
Jan Bouwhuis c7b6c9da31
Remove work-a-round for mqtt sensors with an entity_category set to `config` (#107199)
* Remove work-a-round for mqtt sensors with an entity_category set to `config`

* Cleanup strings
2024-01-05 09:24:52 +01:00
G Johansson 83f4d3af5c
Implement mode validation in Climate entity component (#105745)
* Implement mode validation in Climate entity component

* Fix some tests

* more tests

* Fix translations

* fix deconz tests

* Fix switcher_kis tests

* not None

* Fix homematicip_cloud test

* Always validate

* Fix shelly

* reverse logic in validation

* modes_str

---------

Co-authored-by: J. Nick Koston <nick@koston.org>
2023-12-27 14:51:39 +01:00
Jan Bouwhuis dae8c0fc38
Fix MQTT retained event messages should be discarded (#106425) 2023-12-27 12:48:53 +01:00
Jan Bouwhuis 6da2f98d34
Fix mqtt valve is not resetting opening or closing state (#106240)
* Fix mqtt valve is not resetting opening or closing state

* Require state or position attr in JSON state update

* Do not change `_attr_is_closed` if valve reports a position

* Add comment, use tuple

* Call _update_state
2023-12-23 15:18:44 +01:00
Jan Bouwhuis f8f31627ce
Refactor ranging utils for mqtt cover (#105739)
* Refactor ranging utils for mqtt cover

* Use literals for default min and max percentage
2023-12-21 11:54:05 +01:00
Jan Bouwhuis 65d3f7e1c7
Improve error mqtt valve error logging (#106129)
* Improve error mqtt valve error logging

* Update homeassistant/components/mqtt/valve.py

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

* Update homeassistant/components/mqtt/valve.py

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

* Update homeassistant/components/mqtt/valve.py

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

---------

Co-authored-by: Erik Montnemery <erik@montnemery.com>
2023-12-20 21:18:30 +01:00
Jan Bouwhuis c7f6ab2457
Add MQTT valve platform (#105766)
* Add mqtt valve platform

* No stop topic-reports_position and validation

* Do not allow state_open, state_closed with position reporing valve

* Allow open/close feature to be disabled

* Follow up comments

* Rename

* Apply defaults in validator

* Update docstr
2023-12-20 07:49:49 +01:00
Jan Bouwhuis 3f2fc2fce9
Fix mqtt tests modifying globals (#105774) 2023-12-15 08:15:10 +01:00
Jan-Philipp Benecke ff85d0c290
Migrate mqtt tests to use freezegun (#105414) 2023-12-10 09:25:16 +01:00
Jan Bouwhuis e5a115ce1f
Fix mqtt json light state updates using deprecated color handling (#105283) 2023-12-08 16:54:02 +01:00
Jan Bouwhuis 4bf88b1690
Improve MQTT json light brightness scaling (#104510)
* Improve MQTT json light brightness scaling

* Revert unrelated changes

* Format
2023-11-29 16:42:10 +01:00
Jan Bouwhuis 82264a0d6b
Fix mqtt cover state is open after receiving stopped payload (#104726) 2023-11-29 16:29:42 +01:00
Jan Bouwhuis 953a212dd6
Use ServiceValidationError for invalid fan preset_mode and move check to fan entity component (#104560)
* Use ServiceValidationError for fan preset_mode

* Use _valid_preset_mode_or_raise to raise

* Move preset_mode validation to entity component

* Fix bond fan and comments

* Fixes baf, fjaraskupan and template

* More integration adjustments

* Add custom components mock and test code

* Make NotValidPresetModeError subclass

* Update homeassistant/components/fan/strings.json

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

* Keep bond has_action validation

* Move demo test asserts outside context block

* Follow up comment

* Update homeassistant/components/fan/strings.json

Co-authored-by: G Johansson <goran.johansson@shiftit.se>

* Fix demo tests

* Remove pylint disable

* Remove unreachable code

* Update homeassistant/components/fan/__init__.py

Co-authored-by: G Johansson <goran.johansson@shiftit.se>

* Use NotValidPresetModeError, Final methods

* Address comments

* Correct docst

* Follow up comments

* Update homeassistant/components/fan/__init__.py

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

---------

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
Co-authored-by: G Johansson <goran.johansson@shiftit.se>
Co-authored-by: Erik Montnemery <erik@montnemery.com>
2023-11-29 13:56:51 +01:00
Martin Hjelmare b3211fa5ee
Clean mqtt patch.dict config entries (#104449) 2023-11-24 10:56:17 +01:00
Jan Bouwhuis 68f8b2cab5
Fix mqtt json light allows to set brightness value >255 (#104220) 2023-11-19 19:50:25 +01:00
Erik Montnemery 4536fb3541
Remove mock_entity_platform test helper (#104073) 2023-11-16 16:55:08 +01:00
Jan-Philipp Benecke 9326ea09a5
Update m* tests to use entity & device registry fixtures (#103980) 2023-11-15 10:33:11 +01:00
Jan Bouwhuis db97e7588b
Fix entity category for binary_sensor fails setup (#103511) 2023-11-08 14:10:24 +01:00
Jan Bouwhuis cbccdbc6fa
Fix entity category for sensor fails mqtt sensor platform setup (#103449) 2023-11-08 00:03:47 +01:00
Jan Bouwhuis 4a4d2ad743
Fix mqtt config validation error handling (#103210)
* Fix MQTT config check

* Fix handling invalid enity_category for sensors

* Improve docstr

* Update comment

* Use correct util for yaml dump
2023-11-02 10:57:00 +01:00
Jan Bouwhuis daee5baef6
Fix mqtt is not reloading without yaml config (#103159) 2023-11-01 09:25:56 +01:00
Jan Bouwhuis d6a0f9b5a0
Give mqtt test more time to process subscriptions (#103006) 2023-10-30 06:02:03 +01:00
Jan Bouwhuis 485c52568d
Fix error handling on subscribe when mqtt is not initialized (#101832) 2023-10-20 15:16:45 +02:00
Jan Bouwhuis fe8fb8928c
Improve test creating mqtt certificate files (#102380)
* Improve test creating mqtt certificate files

* Split tests

* Cleanup and de-duplicate

* Update tests/components/mqtt/test_util.py
2023-10-20 14:49:33 +02:00
Jan Bouwhuis 7d9014ae41
Do not fail MQTT setup if events or sensors configured via yaml can't be validated (#102309)
* Add event and sensor

* Cleanup unused code

* Schema cannot be None for supported platform
2023-10-20 12:09:52 +02:00
Jan Bouwhuis 1efbba2631
Do not fail MQTT setup if covers configured via yaml can't be validated (#102304)
Add cover
2023-10-20 10:51:42 +02:00
Jan Bouwhuis 12c4a10cfc
Do not fail MQTT setup if numbers configured via yaml can't be validated (#102316)
Add number
2023-10-20 10:51:14 +02:00
Jan Bouwhuis 04fdcbe5fa
Do not fail MQTT setup if buttons configured via yaml can't be validated (#102301) 2023-10-20 08:13:59 +02:00
Jan Bouwhuis f4e7c5aed3
Do not fail MQTT setup if humidifiers configured via yaml can't be validated (#102312)
Add humidifier
2023-10-19 23:29:49 +02:00
Jan Bouwhuis e26a2596af
Do not fail MQTT setup if climate's configured via yaml can't be validated (#102303)
Add climate
2023-10-19 21:14:45 +02:00
Jan Bouwhuis 22c21fdc18
Do not fail MQTT setup if vacuum's configured via yaml can't be validated (#102325)
Add vacuum
2023-10-19 20:11:09 +02:00
Jan Bouwhuis 5eb0a33795
Do not fail MQTT setup if text's configured via yaml can't be validated (#102322)
Add text
2023-10-19 18:51:47 +02:00
Jan Bouwhuis d0341c9754
Do not fail MQTT setup if images configured via yaml can't be validated (#102313)
Add image
2023-10-19 18:50:02 +02:00
Jan Bouwhuis 3853214496
Do not fail MQTT setup if fans configured via yaml can't be validated (#102310)
Add fan
2023-10-19 18:48:35 +02:00
Jan Bouwhuis 651b725cc0
Do not fail MQTT setup if binary sensors configured via yaml can't be validated (#102300)
Add binary_sensor
2023-10-19 18:15:21 +02:00
Jan Bouwhuis d149bffb07
Do not fail MQTT setup if lights configured via yaml can't be validated (#101649)
* Add light

* Deduplicate code

* Follow up comment
2023-10-19 17:34:43 +02:00
Jan Bouwhuis c377cf1ce0
Do not fail mqtt entry on single platform config schema error (#101373)
* Do not fail mqtt entry on platform config

* Raise on reload with invalid config

* Do not store issues

* Follow up
2023-10-19 12:06:33 +02:00
Paul Bottein c98c18f25e
Return 'None' for light attributes when off instead of removing them (#101946) 2023-10-19 01:08:08 +02:00
Robert Resch f7292d5b00
Add check that sensors don't have EntityCategory.CONFIG set (#101471) 2023-10-09 13:37:52 +02:00
Jan Bouwhuis db0c5bbbea
Fix mqtt sensor or binary_sensor state not saved after expiry (#101670)
Fix mqtt sensor state not saved after expire
2023-10-08 20:57:14 +02:00
Jan Bouwhuis 74464fd94e
Ensure coverage mqtt entry disabled test (#101617) 2023-10-07 23:08:34 +02:00
Jan Bouwhuis 55bf309d2f
Add mqtt discovery schema error tests for all platforms (#101583)
Add mqtt discovery schema error tests
2023-10-07 21:00:33 +02:00
Jan Bouwhuis 2bfb1e75d3
Correct device_class test for mqtt button (#101500) 2023-10-06 09:11:50 +02:00
Jan Bouwhuis a3fe120457
Raise vol.Invalid for invalid mqtt device_tracker config (#101399)
Raise vol.Invalid for invalid mqtt device_tracker
2023-10-04 19:36:34 +02:00
Jan Bouwhuis 0ded0ef4ee
Use dataclass instead of attr slots for mqtt PublishMessage and ReceiveMessage (#101062)
Use dataclass instead of attr slots
2023-09-28 20:36:30 +02:00
Jan Bouwhuis dc1d3f727b
Fix handling reload with invalid mqtt config (#101015)
Fix handling reload whith invalid mqtt config
2023-09-27 20:59:19 -04:00
Jan Bouwhuis 0f38cd5794
Allow to reset an mqtt lock to an unknown state (#100985) 2023-09-27 09:50:01 +02:00
Jan Bouwhuis 20a2e129fb
Intialize mqtt lock in an unknown state in pessimistic mode (#100943)
Intialize mqtt lock as unknown in pessimistic mode
2023-09-26 19:53:45 +02:00
Jan Bouwhuis a4f7f3ba7e
Make sure time is changed in mqtt event test (#100889) 2023-09-26 00:32:12 +02:00
Jan Bouwhuis 60b8775f4a
Avoid redundant calls to async_write_ha_state in mqtt siren (#100813)
* Avoid redundant calls to async_write_ha_state

* Add comment
2023-09-25 22:36:13 +02:00
Jan Bouwhuis a242a1c107
Add tests for mqtt image (#100793)
* Rework mqtt image writing state

* Revert mixin changes, add attr

* Revert code changes
2023-09-25 22:20:32 +02:00
Jan Bouwhuis 7258bc6457
Avoid redundant calls to async_write_ha_state in mqtt vacuum (#100799)
* Avoid redundant calls to async_write_ha_state

* Add comment

* Rephrase
2023-09-25 22:17:29 +02:00
Jan Bouwhuis ea1108503d
Rework and fix mqtt siren writing state and attributes (#100871)
Rework mqtt siren writing state and attributes
2023-09-25 21:08:14 +02:00
Jan Bouwhuis 30c7e7fbdf
Avoid redundant calls to async_ha_write_state mqtt update platform (#100819)
Avoid redundant calls to async_ha_write_state
2023-09-25 18:08:02 +02:00
Jan Bouwhuis cd3d3b76a3
Avoid redundant calls to async_ha_write_state in mqtt text (#100816)
Avoid redundant calls to async_ha_write_state
2023-09-25 18:07:24 +02:00
Jan Bouwhuis 8d10cdce4e
Avoid redundant calls to async_ha_write_state in mqtt switch (#100815)
Avoid redundant calls to async_ha_write_state
2023-09-25 18:06:19 +02:00
Jan Bouwhuis 33d45b3454
Avoid redundant calls to async_write_ha_state in mqtt select (#100809)
Avoid redundant calls to async_write_ha_state
2023-09-25 18:05:42 +02:00
Jan Bouwhuis 180f248370
Avoid redundant calls to async_write_ha_state in mqtt number (#100808)
Avoid redundant calls to async_write_ha_state
2023-09-25 18:05:14 +02:00
Jan Bouwhuis 98cc2e8098
Avoid redundant calls to async_write_ha_state in mqtt lock (#100802)
Avoid redundant calls to async_write_ha_state
2023-09-25 18:04:33 +02:00
Jan Bouwhuis ce02cbefc9
Avoid redundant calls to async_write_ha_state in mqtt lawn_mower (#100795)
Avoid redundant calls to async_write_ha_state
2023-09-25 18:03:52 +02:00
Jan Bouwhuis 002be37257
Rework and added tests for mqtt event (#100769)
Use write_state_on_attr_change and add tests
2023-09-25 18:02:17 +02:00
Jan Bouwhuis f83a597603
Avoid redundant calls to async_write_ha_state in mqtt humidifier (#100781)
Avoid redundant calls to async_write_ha_state
2023-09-25 18:00:08 +02:00
Jan Bouwhuis 3da4815522
Avoid redundant calls to async_write_ha_state for mqtt fan (#100777)
Avoid redundant calls to async_write_ha_state
2023-09-25 17:59:33 +02:00
Jan Bouwhuis edb28be964
Avoid redundant calls to async_write_ha_state in mqtt device_tracker (#100767)
Avoid redundant calls to async_ha_write_state
2023-09-24 12:52:13 +02:00
Jan Bouwhuis c6d62faff3
Avoid redundant calls to async_write_ha_state in mqtt cover (#100720)
Avoid redundant calls to async_write_ha_state
2023-09-22 22:47:07 +02:00
Jan Bouwhuis 5b422daf36
Avoid redundant calls to `async_write_ha_state` in MQTT light (#100690)
* Limit state writes for mqtt light

* Additional tests and review follow up
2023-09-22 13:32:30 +02:00
Jan Bouwhuis 87ae5add8a
Fix mqtt light rgbww update without state topic (#100707)
* Fix mqtt light rgbww update without state topic

* Add @callback decprator and correct mired conv
2023-09-22 13:31:29 +02:00
Jan Bouwhuis a66ad39c4e
Assign color_mode for mqtt light as ColorMode (#100709) 2023-09-22 12:09:37 +02:00
Jan Bouwhuis 384adb1c87
Avoid redundant calls to `async_write_ha_state` in MQTT climate & water_heater (#100696)
Limit state writes for mqtt climate & water_heater
2023-09-22 11:22:57 +02:00
Jan Bouwhuis 1041610a70
Avoid redundant calls to `async_write_ha_state` in MQTT mqtt alarm_control_panel (#100691)
Limit state writes for mqtt alarm_control_panel
2023-09-22 11:22:09 +02:00
Jan Bouwhuis aed3ba3acd
Avoid redundant calls to `async_ha_write_state` in MQTT (binary) sensor (#100438)
* Only call `async_ha_write_state` on changes.

* Make helper class

* Use UndefinedType

* Remove del

* Integrate monitor into MqttEntity

* Track extra state attributes and availability

* Add `__slots__`

* Add monitor to MqttAttributes and MqttAvailability

* Write out loop

* Add test

* Make common test and parameterize

* Add test for last_reset attribute

* MqttMonitorEntity base class

* Rename attr and update docstr `track` method.

* correction doct

* Implement as a decorator

* Move tracking functions into decorator

* Rename decorator

* Follow up comment
2023-09-21 13:33:26 +02:00
Jan Bouwhuis 6b265120b3
Fix entity name attribute on mqtt entity is not removed on update (#100187)
Fix entity name attribute is not remove on update
2023-09-12 15:22:37 +02:00
Jan Bouwhuis c3841f8734
Rework on mqtt certificate tests (#99503)
* Shared fixture on TEMP_DIR_NAME mock in MQTT tests

* Improve mqtt certificate file tests

* Update tests/components/mqtt/test_util.py

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

* Update tests/components/mqtt/conftest.py

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

* Avoid blocking code

* typo in sub function

---------

Co-authored-by: J. Nick Koston <nick@koston.org>
2023-09-02 19:26:11 +02:00
Jan Bouwhuis 3d1efaa4ad
Freeze time for MQTT sensor expire tests (#99496) 2023-09-02 04:10:57 -05:00
Jan Bouwhuis 49897341ba
Add lawn_mower platform to MQTT (#98831)
* Add MQTT lawn_mower platform

* Use separate command topics and templates

* Remove unrelated change
2023-08-25 17:56:22 +02:00
Jan Bouwhuis 948b34b045
Do not force update mqtt device_tracker (#98838) 2023-08-24 20:09:14 +02:00
Jan Bouwhuis 8b232047c4
Add origin info support for MQTT discovered items (#98782)
* Add integration info support for MQTT discovery.

* Moving logs to discovery

* Revert adding class property

* Rename to origin

* Follow up comments
2023-08-24 09:50:39 +02:00
Jan Bouwhuis 0f58007e97
Deprecate aux heat for mqtt climate (#98666) 2023-08-22 22:39:55 +02:00
Jan Bouwhuis 5ef6c03610
Log entity_id payload and template on MQTT value template error (#98353)
* Log entity_id payload and template on error

* Also handle cases with default values.

* Do not log payload twice

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

* Tweak test to assert without payload

* black

---------

Co-authored-by: Erik Montnemery <erik@montnemery.com>
2023-08-18 13:05:53 +02:00
Faidon Liambotis 9fdad592c2
Add option to disable MQTT Alarm Control Panel supported features (#98363)
* Make MQTT Alarm Control Panel features conditional

The MQTT Alarm Control Panel currently enables all features (arm home,
arm away, arm night, arm vacation, arm custom bypass) unconditionally.
This clutters the interface and can even be potentially dangerous, by
enabling modes that the remote alarm may not support.

Make all the features conditional, by adding a new "supported_features"
configuration option, comprising a list of the supported features as
options. Feature enablement seems inconsistent across the MQTT
component; this implementation is most alike to the Humidifier modes
option, but using a generic "supported_features" name that other
implementations may reuse in the future.

The default value of this new setting remains to be all features, which
while it may be overly expansive, is necessary to maintain backwards
compatibility.

* Apply suggestions from code review

* Use vol.Optional() instead of vol.Required() for "supported_features".
* Move the initialization of _attr_supported_features to _setup_from_config.

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

* Apply suggestions from emontnemery's code review

* Use vol.In() instead of cv.multi_seelct()
* Remove superfluous _attr_supported_features initializers, already
  present in the base class.

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

* Add invalid config tests for the MQTT Alarm Control Panel

* Set expected_features to None in the invalid MQTT Alarm Control Panel tests

* Add another expected_features=None in the invalid tests

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

---------

Co-authored-by: Jan Bouwhuis <jbouwh@users.noreply.github.com>
Co-authored-by: Erik Montnemery <erik@montnemery.com>
2023-08-18 08:23:48 +02:00
Jan Bouwhuis c010b97abf
Improve test recovery MQTT certificate files (#98223)
* Improve test recovery MQTT certificate files

* Spelling
2023-08-16 09:07:14 +02:00
Erik Montnemery 2e1a5ddf2b
Don't allow creating device if config entry does not exist (#98157)
* Don't allow creating device if config entry does not exist

* Fix test

* Update test
2023-08-10 22:09:13 -04:00
Erik Montnemery 13a9b83ed3
Adjust mqtt tests which create devices (#98202) 2023-08-10 18:23:55 +02:00
Franck Nijhof 868a5f377f
Ruff: isort don't split imports based on trailing comma (#98162) 2023-08-10 14:27:03 +02:00
Jan Bouwhuis 5c9bce9eac
Allow float for inital MQTT climate temperature (#97995)
* Allow float for inital MQTT climate temperature

* Update tests/components/mqtt/test_climate.py

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

---------

Co-authored-by: Erik Montnemery <erik@montnemery.com>
2023-08-08 23:44:49 +02:00
Marc Mueller 37885400c9
Fix mqtt test DeprecationWarnings (#97734) 2023-08-04 09:21:36 +02:00
Jan Bouwhuis 9c6c391eea
Offer work- a-round for MQTT entity names that start with the device name (#97495)
Co-authored-by: SukramJ <sukramj@icloud.com>
Co-authored-by: Franck Nijhof <git@frenck.dev>
2023-08-01 10:03:08 +02:00
Jan Bouwhuis 3fcfe7d0c6
Set mqtt entity name to `null` when it is a duplicate of the device name (#97304) 2023-07-27 09:23:23 +02:00
Jan Bouwhuis fb00cd8963
Add turn on/off support for mqtt water_heater (#97197) 2023-07-25 13:33:02 +02:00
Franck Nijhof 86708b5590
Update ruff to v0.0.280 (#97102) 2023-07-23 22:00:26 +02:00
Jan Bouwhuis 1b8e03bb66
Add MQTT event entity platform (#96876)
Co-authored-by: Franck Nijhof <frenck@frenck.nl>
2023-07-23 14:42:14 +02:00
Jan Bouwhuis 9a5774a95d
Apply common entity schema for MQTT Scene (#96949) 2023-07-22 18:00:27 +02:00
Jan Bouwhuis 447fbf58c9
Change naming of MQTT entities to correspond with HA guidelines (#95159)
* Set has_entity_name if device_name is set

* revert unneeded formatting change

* Add image platform

* Follow up comment

* Don't set `has_entity_name` without device name

* Only set has_entity_name if a valid name is set

* Follow device_class name and add tests

* Follow up comments add extra tests

* Move to helper - Log a warning

* fix test

* Allow to assign None as name explictly

* Refactor

* Log info messages when device name is not set

* Revert scene schema change - no device link

* Always set has_entity_name with device mapping

* Always set `_attr_has_entity_name`

* Cleanup
2023-07-21 12:52:10 +02:00