* Only publish mqtt_statestream when ha is started
* also catch startup states and use event filter
* Add check for MQTT to be available first
* Make sure MQTT is available and started
* Fix test
* Improve test
* Reset mock before assertung not called
* Adds base code for matter lock
* Adds basic matter door lock support
* Adds matter lock fixture
* Adds tests for matter lock
* Addresses feedback
* Added logic to handle inter states of matter lock
* Addesses feedback
* Introduce a delay between update entity calls
* Update homeassistant/components/zwave_js/update.py
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
* move delay to constant and patch
* rename constant
* Switch to async_call_later
* Remove failing test
* Reimplement to solve task problem
* comment
* pass count directly so that value doesn't mutate before we store it
* lines
* Fix logic and tests
* Comments
* Readd missed coverage
* Add test for delays
* cleanup
* Fix async_added_to_hass logic
* flip conditional
* Store firmware info in extra data so we can restore it along with latest version
* Comment
* comment
* Add test for is_running check and fix bugs
* comment
* Add tests for various restore state scenarios
* move comment so it's less confusing
* improve typing
* consolidate into constant and remove unused one
* Update update.py
* update test to unknown state during partial restore
* fix elif check
* Fix type
* clean up test docstrings and function names
---------
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
If a user manually migrated their database to MySQL or PostgresSQL
and incorrectly created the timestamp columns as float we would
fail to correct them to double because when we migrated to use
timestamps for the columns I missed that we needed to change the
columns and types for µs precision
- If the user had previously duplicated data we could end up
picking the next metadata_id and there could be stale rows
in the database that have that metadata_id. This can only happen
from bad manual migrations (which is what this is function
is validating in the first place). To solve this we now insert
data with a future date and look at the latest inserted row
instead of the first.
Example
```
['stored_statistics',
defaultdict(<class 'list'>,
{'recorder.db_test_schema': [{'end': 948589200.0,
'last_reset': None,
'max': None,
'mean': 2021.0,
'min': None,
'start': 948585600.0,
'state': None,
'sum': 394.5068},
{'end': 1601946000.000001,
'last_reset': 1601942400.000001,
'max': 1.000000000000001,
'mean': 1.000000000000001,
'min': 1.000000000000001,
'start': 1601942400.000001,
'state': 1.000000000000001,
'sum': 1.000000000000001}]})]
```
Update the calander event trigger logic to have more exhaustive coverage. The
trigger will now use a timespan to create an explicit window for considering
upcoming events. The start/end of the time span is now more explicit, rather
than getting it from the alarm time.
The trigger is now broken into composable pieces:
- A timespan object for more explicitly managing the time window
- A function to get events during a time span
- A function to process upcoming events and determine the trigger times
The existing listener is now just responsible for scheduling alarms and glue.
This fixes bug with DST handling where the conversion back and forth between
UTC and timezone ends up dropping events during the jump forward. In practice,
an event was returned from the scanning, but it was never fired by the trigger
because (1) it was filtered out of the interval and (2) the event list was
previously cleared every iteration so it would get dropped.
Future improvements can bake more invariant checking into this structure.
* Fix cpu thrashing during purge after all legacy events were removed
We now remove the the index of of event ids on the states table when its
all NULLs to save space. The purge path needs to avoid checking for legacy
rows to purge if the index has been removed since it will result in a full
table scan each purge cycle that will always find no legacy rows to purge
* one more place
* drop the key constraint as well
* fixes
* more sqlite
* Avoid database executor job to fetch statistic metadata on cache hit
Since we will almost always have a cache hit fetching
statistic meta data we can avoid an executor job
* Avoid database executor job to fetch statistic metadata on cache hit
Since we will almost always have a cache hit fetching
statistic meta data we can avoid an executor job
* Avoid database executor job to fetch statistic metadata on cache hit
Since we will almost always have a cache hit fetching
statistic meta data we can avoid an executor job
* remove exception catch since the threading.excepthook will actually catch this in production
* fix a few missed ones
* threadsafe
* Update homeassistant/components/recorder/table_managers/statistics_meta.py
* coverage and optimistic caching
* Add local calendar diagnostics platform
* Use redaction from ical
* Update diagnostics for new ical version
* Apply suggestions from code review
Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
* Use snapshot tests for local calendar diagnostics
* Setup diagnostics directly in tests rather than via dependencies
---------
Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
* Initial commit
* Add websocket test tool
* Small tweak
* Tiny cleanup
* Make pipeline work with frontend branch
* Add some more info to start event
* Fixes
* First voice assistant tests
* Remove run_task
* Clean up for PR
* Add config_flow.py
* Remove CLI tool
* Simplify by removing stt/tts for now
* Clean up and fix tests
* More clean up and API changes
* Add quality_scale
* Remove data from run-finish
* Use StrEnum backport
---------
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
* Add filters to climate and light service descriptions
* Allow specifying enums directly
* Update service descriptions
* Adjust test
* Cache entity features
* Lint
* Improve error handling, add list of known base components
* Don't allow specifying an entity feature as int
* refactor to make StatesMetaManager threadsafe
* refactor to make StatesMetaManager threadsafe
* refactor to make StatesMetaManager threadsafe
* refactor to make StatesMetaManager threadsafe
* reduce
* comments
* 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>
* Adds a loader to enable jinja imports.
* Switch to in-memory
* Move loading custom_jinja off of the event loop
* Raise TemplateNotFound if template doesn't exist
* Fix docstring
* Adds a service to reload custom jinja
* Remove IO from test setup
* Improve coverage and small refactor
* Incorporate feedback and use .jinja extension
* Check the loaded sources in test.
* Incorporate PR feedback.
* Update homeassistant/helpers/template.py
Co-authored-by: Erik Montnemery <erik@montnemery.com>
---------
Co-authored-by: Erik Montnemery <erik@montnemery.com>
* Split context id migration into states and events tasks
Since events can finish much earlier than states we
would keep looking at the table because states as not
done. Make them seperate tasks
* add retry dec
* fix migration happening twice
* another case
* Deduplicate event_types in the events table
* Deduplicate event_types in the events table
* more fixes
* adjust
* adjust
* fix product
* fix tests
* adjust
* migrate
* migrate
* migrate
* more test fixes
* more test fixes
* fix
* migration test
* adjust
* speed up
* fix index
* fix more tests
* handle db failure
* preload
* tweak
* adjust
* fix stale docs strings, remove dead code
* refactor
* fix slow tests
* coverage
* self join to resolve query performance
* fix typo
* no need for quiet
* no need to drop index already dropped
* remove index that will never be used
* drop index sooner as we no longer use it
* Revert "remove index that will never be used"
This reverts commit 461aad2c52.
* typo
* Make client tracker use common UniFi entity class
* Fix tests
* Fix mypy
* Remove legacy data
* Fix comment: skip else use return
* Minor change
* Remove missed stuff from previous rebase
* Import async_device_available_fn from entities.py rather than specifying it in device_tracker
* Avoid using asserts
* Keep explicit parenthesis for readability
* Allow loading entities on option changes
* Move coordinator to own file and add test cases
* Apply typing improvements from review
* Remove testcase for exception during setup
* Simplify unittest for failing serial connection
* Readd checks in serial connection test after review
* Add Hardkernel ODROID-M1
Add Hardkernel ODROID-M1 machine. ODROID-M1 is a Rockchip RK3568B2 SoC
based single board computer with 4xCortex-A55, NVMe support and up to
8GB of RAM.
* Update homeassistant/components/hardkernel/hardware.py
Co-authored-by: Franck Nijhof <frenck@frenck.nl>
* Fix tests
Co-authored-by: Franck Nijhof <frenck@frenck.nl>
* 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>
* Migrate integration_platform helper to use async_get_integrations
We were fetching integrations inside the gather one
at a time. This is inefficent.
* cleanup
* cleanup
* add task name
* small tweaks
* gather only if we have tasks