Commit graph

46 commits

Author SHA1 Message Date
J. Nick Koston
c4b277b6ab
Small cleanups to ESPHome manager reconnect shutdown (#120401) 2024-06-25 19:40:04 +02:00
J. Nick Koston
edaa5c60a7
Small cleanups to ESPHome (#120414) 2024-06-25 17:00:03 +02:00
J. Nick Koston
fccb7ea1f9
Migrate ESPHome to use entry.runtime_data (#120402) 2024-06-25 13:10:09 +02:00
J. Nick Koston
dbd3147c9b
Remove async_late_forward_entry_setups and instead implicitly hold the lock (#119088)
* Refactor config entry forwards to implictly obtain the lock instead of explictly

This is a bit of a tradeoff to not need async_late_forward_entry_setups

The downside is we can no longer detect non-awaited plastform setups
as we will always implicitly obtain the lock instead of explictly.

Note, this PR is incomplete and is only for discussion purposes
at this point

* preen

* cover

* cover

* restore check for non-awaited platform setup

* cleanup

* fix missing word

* make non-awaited test safer
2024-06-12 21:06:11 -04:00
J. Nick Koston
ed0568c655
Ensure config entries are not unloaded while their platforms are setting up (#118767)
* Report non-awaited/non-locked config entry platform forwards

Its currently possible for config entries to be reloaded while their platforms
are being forwarded if platform forwards are not awaited or done after the
config entry is setup since the lock will not be held in this case.

In https://developers.home-assistant.io/blog/2022/07/08/config_entry_forwards
we advised to await platform forwards to ensure this does not happen, however
for sleeping devices and late discovered devices, platform forwards may happen
later.

If config platform forwards are happening during setup, they should be awaited

If config entry platform forwards are not happening during setup, instead
async_late_forward_entry_setups should be used which will hold the lock to
prevent the config entry from being unloaded while its platforms are being
setup

* Report non-awaited/non-locked config entry platform forwards

Its currently possible for config entries to be reloaded while their platforms
are being forwarded if platform forwards are not awaited or done after the
config entry is setup since the lock will not be held in this case.

In https://developers.home-assistant.io/blog/2022/07/08/config_entry_forwards
we advised to await platform forwards to ensure this does not happen, however
for sleeping devices and late discovered devices, platform forwards may happen
later.

If config platform forwards are happening during setup, they should be awaited

If config entry platform forwards are not happening during setup, instead
async_late_forward_entry_setups should be used which will hold the lock to
prevent the config entry from being unloaded while its platforms are being
setup

* run with error on to find them

* cert_exp, hold lock

* cert_exp, hold lock

* shelly async_late_forward_entry_setups

* compact

* compact

* found another

* patch up mobileapp

* patch up hue tests

* patch up smartthings

* fix mqtt

* fix esphome

* zwave_js

* mqtt

* rework

* fixes

* fix mocking

* fix mocking

* do not call async_forward_entry_setup directly

* docstrings

* docstrings

* docstrings

* add comments

* doc strings

* fixed all in core, turn off strict

* coverage

* coverage

* missing

* coverage
2024-06-04 21:34:39 -04:00
Jesse Hills
7f530ee0e4
[esphome] Assist timers (#118275)
* [esphome] Assist timers

* Add intent to manifest dependencies

* Add test

---------

Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2024-05-28 14:57:58 -04:00
Jesse Hills
68384bba67
Send/receive Voice Assistant audio via ESPHome native API (#114800)
* Protobuf audio test

* Remove extraneous code

* Rework voice assistant pipeline

* Move variables

* Fix reading flags

* Dont directly put to queue

* Bump aioesphomeapi to 24.0.0

* Update tests

- Add more tests for API pipeline
- Convert some udp tests to use api pipeline
- Update fixtures for new device info flags

* Fix bad merge

---------

Co-authored-by: Michael Hansen <mike@rhasspy.org>
2024-04-09 10:55:59 -04:00
J. Nick Koston
ca5ed274cb
Deprecate calling async_listen and async_listen_once with run_immediately (#115169) 2024-04-08 10:07:54 -10:00
Marc Mueller
3c5089bc3f
Update import for EventStateChangedData [a-h] (#114899) 2024-04-04 11:48:36 -10:00
J. Nick Koston
bec45dacf0
Add additional coverage to the ESPHome manager (#114265) 2024-03-27 20:52:45 -10:00
J. Nick Koston
dbbd6fff01
Move ESPHome disconnects to the close event (#113652) 2024-03-17 08:15:28 -10:00
J. Nick Koston
4c82196fc8
Avoid some event loop overhead for ESPHome listeners (#113173) 2024-03-12 21:49:31 +01:00
Joost Lekkerkerker
643e6096da
Improve lists in integrations [E-F] (#113075) 2024-03-12 18:42:43 +01:00
J. Nick Koston
f1b5dcdd1b
Refactor handling of device updates in ESPHome (#112864) 2024-03-09 20:30:17 -10:00
Marc Mueller
25237e0377
Replace EventType with Event [a-g] (#112739) 2024-03-08 19:35:17 +01:00
Marc Mueller
0e3945ca6c
Add empty line after module docstring [d-f] (#112698) 2024-03-08 14:15:26 +01:00
J. Nick Koston
4249d17c1b
Reduce ESPHome reconnect time (#112001)
Use eager tasks to request device_info and entities which avoids
waiting one event loop to send the requests to the device
2024-03-01 22:16:01 -05:00
Jesse Hills
e1dade69e1
ESPHome: Pass through wake_word_phrase from on-device microWakeWord (#111585)
* ESPHome: Pass through wake_word_phrase from on-device microWakeWord

* Bump aioesphomeapi to 23.0.0
2024-02-26 23:29:03 -05:00
J. Nick Koston
fd1f712d67
Bump esphome dependencies (#110892) 2024-02-19 10:38:28 +01:00
J. Nick Koston
5bda4be88f
Remove useless _handle_pipeline_event function in ESPHome (#109484) 2024-02-03 14:15:56 +01:00
Michael Hansen
3347a3f8a6
More thorough checks in ESPHome voice assistant UDP server (#109394)
* More thorough checks in UDP server

* Simplify and change to stop_requested

* Check transport
2024-02-02 21:26:44 -05:00
J. Nick Koston
d609344f40
Reduce duplicate code in ESPHome connection callback (#107338) 2024-01-08 09:10:58 +01:00
J. Nick Koston
81458dbf6f
Add test coverage for ESPHome state subscription (#107045) 2024-01-05 19:51:49 +01:00
J. Nick Koston
9c69212ad5
Add test coverage for ESPHome service calls (#107042) 2024-01-04 09:37:56 +01:00
J. Nick Koston
01d0031e09
Fix ESPHome service removal when the device name contains a dash (#107015)
* Fix ESPHome service removal when the device name contains a dash

If the device name contains a dash the service name is mutated to
replace the dash with an underscore, but the remove function did
not do the same mutation so it would fail to remove the service

* add more coverage

* more cover
2024-01-03 19:47:49 -05:00
J. Nick Koston
89513efd8d
Refactor ESPHome Bluetooth connection logic to prepare for esphome-bleak (#105747) 2023-12-17 04:42:28 -10:00
J. Nick Koston
fc5ae50e06
Bump aioesphomeapi to 19.0.0 (#104512) 2023-11-25 14:00:04 -06:00
J. Nick Koston
a59076d140
Speed up ESPHome connection setup (#104304) 2023-11-22 23:27:17 +01:00
J. Nick Koston
29ac3a8f66
Fix memory leak in ESPHome disconnect callbacks (#104149) 2023-11-21 07:58:22 +01:00
J. Nick Koston
3f11bb5f62
Speed up connecting to ESPHome devices (#104018) 2023-11-15 10:28:49 +01:00
Jesse Hills
4838b2dee6
ESPHome: Add suggested_area from device info (#102834) 2023-10-26 09:19:31 +02:00
J. Nick Koston
88296c1998
Migrate ESPHome unique ids to new format (#99451) 2023-10-15 17:05:20 -10:00
J. Nick Koston
5b8da03596
Bump aioesphomeapi to 18.0.1 (#102028)
Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
2023-10-14 23:42:22 -10:00
Michael Hansen
f0317f0d59
Close existing UDP server for ESPHome voice assistant (#101845) 2023-10-12 07:32:00 +13:00
Jesse Hills
63946175ea
Fix manual stopping of the voice assistant pipeline (#101351) 2023-10-03 19:15:56 -04:00
Jesse Hills
4c21aa18db
Add audio_settings for pipeline from ESPHome device (#100894)
* Add audio_settings for pipeline from ESPHome device

* ruff fixes

* Bump aioesphomeapi 17.0.0

* Mypy

* Fix tests

---------

Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2023-09-26 16:27:26 -05:00
J. Nick Koston
49d73441bf
Abort ESPHome connection when both name and mac address do not match (#98787) 2023-08-22 23:02:23 +02:00
Jesse Hills
57bc8ae68e
Set assist pipeline binary sensor to true only when stt-start is received (#98844) 2023-08-23 08:00:38 +12:00
Jesse Hills
a42d975c49
ESPHome Wake Word support (#98544)
* ESPHome Wake Word support

* Remove all vad code from esphome integration

* Catch exception when no wake word provider found

* Remove import

* Remove esphome vad tests

* Add tests

* More tests
2023-08-21 12:13:02 -04:00
J. Nick Koston
3e14e5acba
Bump aioesphomeapi to 16.0.1 (#98536) 2023-08-17 17:46:21 +02:00
Franck Nijhof
868a5f377f
Ruff: isort don't split imports based on trailing comma (#98162) 2023-08-10 14:27:03 +02:00
Marc Mueller
0cc396b863
Use EventType for state changed [a-h] (#97116) 2023-07-24 08:04:13 +02:00
J. Nick Koston
095146b163
Fix has_entity_name not always being set in ESPHome (#97055) 2023-07-23 10:45:48 +02:00
J. Nick Koston
2c4e4428e9
Decouple more of ESPHome Bluetooth support (#96502)
* Decouple more of ESPHome Bluetooth support

The goal is to be able to move more of this into an external library

* Decouple more of ESPHome Bluetooth support

The goal is to be able to move more of this into an external library

* Decouple more of ESPHome Bluetooth support

The goal is to be able to move more of this into an external library

* Decouple more of ESPHome Bluetooth support

The goal is to be able to move more of this into an external library

* Decouple more of ESPHome Bluetooth support

The goal is to be able to move more of this into an external library

* fix diag

* remove need for hass in the client

* refactor

* decouple more

* decouple more

* decouple more

* decouple more

* decouple more

* remove unreachable code

* remove unreachable code
2023-07-21 16:41:50 -04:00
J. Nick Koston
5d5c58338f
Fix ESPHome deep sleep devices staying unavailable after unexpected disconnect (#96353) 2023-07-11 11:12:24 -10:00
J. Nick Koston
e38f55fdb6
Move ESPHomeManager into its own file (#95870)
* Move ESPHomeManager into its own file

This is not a functional change. This is only a reorganization
ahead of some more test coverage being added so moving tests
around can be avoided later.

* relos

* fixes

* merge a portion of new cover since its small and allows us to remove the __init__ from .coveragerc
2023-07-08 09:19:44 +02:00