* 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
* Make sure MQTT is available starting mqtt_json
* Wait for mqtt client
* Sync client connect
* Simplify
* Addiitional tests async_wait_for_mqtt_client
* Improve comment waiting for mqtt
* Improve docstr
* Do not wait unless the MQTT client is in setup
* Handle entry errors during setup
* More comments - do not clear event
* Add snips and mqtt_room
* Add manual_mqtt
* Update homeassistant/components/mqtt/__init__.py
Co-authored-by: J. Nick Koston <nick@koston.org>
* Use a fixture, improve tests
* Simplify
---------
Co-authored-by: J. Nick Koston <nick@koston.org>
* Reduce creation of MQTT related discovery tasks
Most of the branching can avoid creating a task as it
did not need to await for the majority of cases. We
fallback to creating a task for the cases were we do
need to await.
* comment
* revert
* Cleanup config merging and adding defaults
* Optimize and update tests
* Do not mix entry and yaml config
* Make sure hass.data is initilized
* remove check on get_mqtt_data
* Tweaks to MQTT client
* Remove None assigment mqtt client and fix mock
* Remove async_setup from mqtt integration
* Final update common tests
* Related tests init
* Related tests diagnostics
* Related tests config_flow
* Cleanup and correct test
* Keep websockets_api commands in async_setup
* 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>
* 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>
* 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>
* 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
* Add JSON type definitions
* Sample use
* Keep mutable for a follo-up PR (avoid dead code)
* Use list/dict
* Remove JsonObjectType
* Remove reference to Union
* Cleanup
* Improve rest
* Rename json_dict => json_data
* Add docstring
* Add type hint to json_loads
* Add cast
* Move type alias to json helpers
* Cleanup
* Create and use json_loads_object
* Make error more explicit and add tests
* Use JsonObjectType in conversation
* Remove quotes
* 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