* recorder: Apply filter in the outer query too
Function _get_start_time_state_for_entities_stmt() produced a query which
is dead-slow in my installation. On analysis, the outer query produced
millions of rows which had to be joined to the subquery. The subquery has
a filter which would eliminate almost all of the outer rows.
To speed up the query, apply the same filter to the outer query, so way
less rows have to be joined.
This reduced the query time on my system from more than half an hour to
mere milliseconds.
* lint
* merge filter
---------
Co-authored-by: J. Nick Koston <nick@koston.org>
* Bump aioesphomeapi to 19.1.5
changelog: https://github.com/esphome/aioesphomeapi/compare/v19.1.4...v19.1.5
- Removes the need to watch for BLE connection drops with a seperate
future as the library now raises BluetoothConnectionDroppedError when
the connection drops during a BLE operation
* reduce stack
* .6
* tweak
* 19.1.7
* Add tag name to tag scanned event data
* Make name in event data optional, add test cases for events
* Simplify sanity None check of tag data
Co-authored-by: Robert Resch <robert@resch.dev>
* Apply suggestions from code review
---------
Co-authored-by: Robert Resch <robert@resch.dev>
Co-authored-by: Erik Montnemery <erik@montnemery.com>
* Add To-do due date and description fields
* Fix due date schema
* Revert devcontainer change
* Split due date and due date time
* Add tests for config validation function
* Add timezone converstion tests
* Add local todo due date/time and description implementation
* Revert configuration
* Revert test changes
* Add comments for the todo item field description
* Rename function _validate_supported_features
* Fix issues in items factory
* Readability improvements
* Apply suggestions from code review
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
* Rename CONF to ATTR usages
* Simplify local time validator
* Rename TodoListEntityFeature fields for setting extended fields
* Remove duplicate validations
* Update subscribe test
* Fix local_todo tests
---------
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
* Do not use a persistent connection to MPD
In other words, don't rely on the connection management provided by
"python-mpd2". Instead of keeping the connection to MPD open, we
explicitly connect before and disconnect after each command.
There is probably a bit of overhead to this, but as the integration
uses a local-polling approach to begin with, no functionality is lost or
degraded.
This change greatly hardens the MPD integration against both network
issues and problems with the daemon itself. All connection-related
failure modes have effectively been removed.
* Update state retrieval methods
Only "async_get_media_image" attempts to connect, all others are either
called from there, or from the main "async_update" method (see previous
commit) which also attempts to connect.
So, this commit mainly revolves around gracefully handling situations
where no connection is available when trying to retrieve MPD state.
Finally, note the removal of "self._commands". This property is only
used at the start of "_async_get_file_image_response" and was thus
changed into a local variable.
* Update media-player control methods
These all need to explicitly connect to MPD as part of their flow.
* Correct ruff failure (auto-fixed)
* Use "async_timeout.timeout" context manager
* Minor changes
* Replace "async_timeout" with "asyncio.timeout"
* Initialise "self._status" to empty dictionary
Used to be initialised as None, which caused "NoneType is not iterable"
type of issues in case of an unexpected disconnect (at which point
status gets set to None again). Instead of guarding against None
everywhere, using an empty dictionary seemed more prudent...
Furthermore, more cautiously access its members to prevent potential
KeyError-s in similar cases.
* Fix livelock in "async_mute_volume()"
This method doesn't need a connection; it calls into two other methods
that actually connect to MPD – attempting to connect from here resulted
in a livelock.
* Support HTTPS connections to Huawei LTE devices
Not all devices support HTTPS, so we default to plain HTTP still.
Ones that do are very likely to have certificates that do not pass
hostname verification, and are either self signed or issued by an
untrusted CA. Add option to use unverified HTTPS to make it possible to
connect to these, and when in effect, filter urllib3's related warnings
about insecure connections to the hostname in question.
* Use common config key and strings for certificate verification settings
Even though the wording might be slightly suboptimal here, it's better
to be consistent across the codebase than to finetune on this level.
This also switches the default the other way around: verification is
now disabled by default. This is not a good general default, but for
this particular case setups where the verification would succeed would
be so rare and require considerable local setup that it's very
unlikely to happen in practice.
* Add config flow tests
* Mock logout for better test coverage
* Set up custom requests session only when using unverified https
* Add https config flow test case
* Make better use of verify SSL default
* Repair duplicate devices added to the rainbird integration
* Apply suggestions from code review
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
* Update tests/components/rainbird/test_init.py
* Remove use of config_entry.async_setup
---------
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
* optionally decouple `EntityDescription.key` from API response key
this makes it possible to have multiple entities for a single API response field
* Add optional `value_fn` to EntityDescriptions
eg. to be able to map a API response value to a different value (status_code -> message)
* Add inverter `status_message` entity
* Add meter `meter_location_description` entity
* add external battery state
* Make Ohmpilot entity state translateable
* use built-in StrEnum
* test coverage
* remove unnecessary checks
None is handled before