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>
* 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
* 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
* 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
* 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
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.
* 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>
* 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>
* 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
* 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
* 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>
* 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
* 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>
* 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>
* 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>
* 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>
* 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