* Debounce MQTT unsubscribes and merge to one call
* Make _async_unsubscribe a callback
* Make sure unsubscribes are processed
* Move debug log out of lock
* Reduce calls and raise outside lock
* Cancel any unsubscribe when queing
* Copy pending unsubscribes
* Only convert topics to list once
* No copy needed
* Typo in comment
* Debounce and group mqtt subscriptions
* Cleanup
* Do not cooldown on resubscribe
* Remove lock from task
Co-authored-by: Erik Montnemery <erik@montnemery.com>
* ruff
* Longer initial cool down. Manages unsubscribes
* Own lock for access to self._pending_subscriptions
* adjust
* Subscribe to highest QoS when sharing subscription
* do not block _pending_subscriptions_lock with io
* Test the highest qos is subscribed at
* Cleanup max qos
* Follow up comments part 1
* Make docstr more generic
* Make max qos update thread safe
* Add lock on clearing _max_qos when resubscribing
* Wait for linger task
* User copy
* Check for key before cleaning up
* Fix lingering task
* Do not use a lock
* do not await _async_queue_subscriptions
* Replace copy with assignment
* Update max qos before returning
* Do not iterate if max_qos == 0
* Do not ieterate subs if max qos == 0
* Set initial cooldown correctly
* Ensure discovery cooldown ends after subscribing
* plan last subscribe with debouncer timeout
* cooldown if self._pending_subscriptions is set
* Revert format changes
* Remove stale assingnment self._last_subscribe
* Remove not used property
* Also check while for pending subscriptions
* revert first added sleep()
* Optimize
---------
Co-authored-by: Erik Montnemery <erik@montnemery.com>
Co-authored-by: J. Nick Koston <nick@koston.org>
* 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>
* 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
* Add Mqtt WebSockets support
* Fix tests
* Add testing websockets options
* Add tests transport settings
* Do not use templates for ws_headers
* Use json helper - small corrections
* 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>
* Cleanup discovery on entity removal
* Add test
* Cleanup and test
* Test with clearing payload not unique id
* Address comments
* Tests cover and typing
* Just pass hass
* reuse code
* Follow up comments revert changes to cover tests
* Add test unique_id has priority over disabled
* Update homeassistant/components/mqtt/__init__.py
Co-authored-by: Erik Montnemery <erik@montnemery.com>
Co-authored-by: Erik Montnemery <erik@montnemery.com>
* Mqtt switch allow unkown state
* correct type
* Update discovery tests
* Optimistic mode if not state_topic is configured.
* Default state UNKNOWN in optimistic mode
* fix discovery test
* replace base in availability topic
* add tests for availability shortcuts - fix import
* group constants
* simplified loop
* Moving constants to .const
* rename value to topic
* move CONF_TOPIC to .const
* move CONF_AVAILABILITY to .const
* remove check for string
* Silently ignore if no config topic is found.
* CONF_TOPIC should be required
* Add suggested_area to MQTT Discovery
This adds suggested_area to MQTT discovery, so that the discovered devices could be automatically added to the proper area.
* Add abbreviation for MQTT suggested_area
* Remove extra whitespace
* Remove extra whitespace #2
* Added tests for MQTT Dicovery of suggested_area
* Fix test for MQTT suggested_area
* Better tests of MQTT suggested_area
Changes made as per feedback from @emontnemery
* 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.