Commit Graph

418 Commits

Author SHA1 Message Date
J. Nick Koston df0dbadae7
Ensure scope_id is preserved from zeroconf resolution on python versions that support it (#664) 2023-11-23 07:48:34 -06:00
J. Nick Koston 00a6ce9f6a
Pass server name to zeroconf when known (#665) 2023-11-23 07:25:05 -06:00
J. Nick Koston 70a670f2b2
Rename internal client connection get function to _get_connection (#661) 2023-11-22 22:32:22 +01:00
J. Nick Koston ac43747196
Refactor connection checks to return APIConnection to avoid many asserts (#660) 2023-11-22 22:22:10 +01:00
J. Nick Koston 77a7c5eaf4
Guard client connection asserts with if TYPE_CHECKING (#659) 2023-11-22 21:54:01 +01:00
J. Nick Koston d8cace0b26
Reduce duplication in bluetooth gatt read code (#657) 2023-11-21 23:24:54 +01:00
J. Nick Koston 2501ea4275
Add additional coverage for starting noise connections (#653) 2023-11-21 16:42:23 +01:00
J. Nick Koston 0afa8c6832
Remove in_do_connect contextvar (#652) 2023-11-21 15:36:43 +01:00
J. Nick Koston f88b15e33b
Fix `eof_received` not raising SocketClosedAPIError (#651) 2023-11-21 14:56:31 +01:00
J. Nick Koston 298aa01b00
Small cleanups to connection (#648) 2023-11-21 13:08:48 +01:00
J. Nick Koston f783438a7d
Ensure expected_disconnect is True when sending DisconnectResponse fails (#646) 2023-11-20 19:08:29 +01:00
J. Nick Koston c76d741cb8
Refactor to reduce duplicate connection code (#644) 2023-11-18 15:10:40 -06:00
J. Nick Koston b12903e2e7
Refactor zeroconf code to avoid creating instances when one is unneeded (#643) 2023-11-17 13:11:36 -06:00
J. Nick Koston f94ddf8e6a
Fix handling incoming data from protractor event loop (#642) 2023-11-16 17:50:54 -06:00
J. Nick Koston 3ccb36b6fc
Refactor frame helper to avoid py conversions when processing packets (#641) 2023-11-16 12:24:50 -06:00
J. Nick Koston d6293d9177
Refactor frame helper to allow sending multiple packets at once (#640) 2023-11-16 10:31:02 -06:00
J. Nick Koston e6257a8627
Add the ability to pass the name the reconnect logic when running logs (#639) 2023-11-15 00:55:39 -06:00
dependabot[bot] f1956aa598
Bump mypy from 1.6.1 to 1.7.0 (#638)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: J. Nick Koston <nick@koston.org>
2023-11-13 22:22:43 -06:00
J. Nick Koston e70cbb8135
Increase cli tool logging timestamps to include nanoseconds (#637) 2023-11-13 13:56:52 -06:00
J. Nick Koston 634c739048
Fix host resolution when local dns does not resolve mdns (#636) 2023-11-11 14:48:12 -06:00
J. Nick Koston c1a0500ecb
Update some legacy python code to python 3.9 (#635) 2023-11-11 14:19:04 -06:00
J. Nick Koston 0202e00eae
Ensure zeroconf instance is closed when log runner ends (#632) 2023-11-11 13:43:31 -06:00
J. Nick Koston 3ffcca3bdd
Make log runner code reusable and add coverage (#630) 2023-11-11 13:06:27 -06:00
J. Nick Koston b227f79dad
Refactor bluetooth client functions to reduce duplicate code (#629) 2023-11-10 17:14:00 -06:00
J. Nick Koston a15b96c76b
Send hello and login asynchronously to speed up connecting (#628) 2023-11-09 19:17:53 -06:00
J. Nick Koston 8678fa9ebc
Small cleanups to noise write_packet (#627) 2023-11-09 11:28:18 -06:00
J. Nick Koston 419bf67e9b
Small readability improvements to the plain_text frame helper (#626) 2023-11-09 11:12:00 -06:00
J. Nick Koston 94157a8ac1
Small speed up to the plaintext frame helper (#625) 2023-11-09 10:20:42 -06:00
J. Nick Koston ef9f9bf136
Ensure an empty noise_psk or expected_name is treated as None (#623) 2023-11-08 18:00:28 -06:00
J. Nick Koston 7ac7742c91
Ensure passed params are always a str (#622) 2023-11-08 17:26:51 -06:00
J. Nick Koston 6458ebcf60
Allow the stop callback to be cancelled when already disconnected (#615) 2023-11-06 18:17:50 -06:00
J. Nick Koston 0683521839
Wait for handshake to finish to allow for clean disconnect when stopping reconnect logic (#614) 2023-11-06 16:46:32 -06:00
J. Nick Koston 2ef9ed9026
Fix zeroconf reconnect logic (#613) 2023-11-06 15:04:09 -06:00
J. Nick Koston 8357a3a0c6
Remove extra timeouts (#610) 2023-10-31 23:20:22 -05:00
J. Nick Koston 1d2682a76e
Improve logging on clean disconnect failure (#609) 2023-10-31 23:07:40 -05:00
Jesse Hills e91da7e301
Add suggested_area to device info (#607) 2023-10-26 18:01:43 +13:00
Daniel Dunn 5a8c0d8e23
Updated fork of PR for Text input components (#532)
Co-authored-by: Maurits <maurits@vloop.nl>
Co-authored-by: Daniel Dunn <dannydunn@eternityforest.com>
Co-authored-by: J. Nick Koston <nick@koston.org>
Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
2023-10-25 15:35:04 +13:00
J. Nick Koston e1c42e95bf
Ensure frame_helper is always closed before the underlying socket (#602) 2023-10-23 19:22:08 -05:00
J. Nick Koston 1630816dc8
Fix unhandled exception when handshake times out (#601) 2023-10-23 12:32:20 -05:00
J. Nick Koston 8c37f088d4
Refactor internal message handlers to use a single dispatch path (#598) 2023-10-22 07:05:53 -10:00
J. Nick Koston 000ff14ac0
Make reconnect logic state machine switches check locks (#597) 2023-10-21 17:46:45 -10:00
J. Nick Koston f34bfb5d1c
Simplify raw ble advertisements callbacks (#594) 2023-10-20 17:34:05 -10:00
J. Nick Koston 359ed510a2
Move mypy disable for async_timeout to mypy.ini (#593) 2023-10-20 06:25:20 -10:00
J. Nick Koston 741308c93f
Add basic pre-commit to handle eol space (#592) 2023-10-19 14:00:36 -10:00
J. Nick Koston f31b250fe2
Remove unless local variable in _connect_resolve_host (#588) 2023-10-17 14:05:39 -10:00
J. Nick Koston 63897ed680
Move varuint functions into plain_text frame_helper (#587) 2023-10-16 17:24:03 -10:00
Jesse Hills dbdb5b442f
Add TTS_STREAM_START/END events (#586) 2023-10-17 14:28:58 +13:00
J. Nick Koston 90f0901ded
Add function to build new format unique ids (#585) 2023-10-15 15:03:13 -10:00
J. Nick Koston cb5cea784e
Improve host resolver coverage (#583) 2023-10-15 13:05:23 -10:00
J. Nick Koston 2a78e9588e
Fix trying to convert hostnames to IP Addresses (#579) 2023-10-15 12:39:12 -10:00
J. Nick Koston c5f4bfa561
Small reduction in connect overhead (#578) 2023-10-15 12:01:00 -10:00
J. Nick Koston d950d90245
Improve consistency of name logging (#577) 2023-10-14 17:04:27 -10:00
J. Nick Koston b7449d4ded
Split connection process to enable faster reconnects (#576) 2023-10-14 16:03:12 -10:00
J. Nick Koston dc367b67bb
Narrow msg_types to only accept tuples (#574) 2023-10-13 18:25:27 -10:00
J. Nick Koston 74facc8fef
Improve performance of processing incoming packets (#573) 2023-10-13 18:01:34 -10:00
J. Nick Koston 20ddb972e7
Reduce memory copy when buffering is not required (#572) 2023-10-12 15:17:46 -10:00
J. Nick Koston f9fa36a89c
Remove async_timeout requirement on python 3.11+ (#570) 2023-10-12 10:03:30 -10:00
dependabot[bot] 749c2d0007
Bump pylint from 2.17.7 to 3.0.1 (#562)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: J. Nick Koston <nick@koston.org>
2023-10-12 09:14:56 -10:00
dependabot[bot] a9d93dcdf3
Bump mypy from 1.5.1 to 1.6.0 (#563)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: J. Nick Koston <nick@koston.org>
2023-10-12 09:14:14 -10:00
J. Nick Koston 2c6f3d40ed
Add optional basic cython implementation for frame_helper (#564) 2023-10-12 08:12:39 -10:00
J. Nick Koston 275ca3a660
Run tests on multiple python versions (#566) 2023-10-11 12:52:19 -10:00
J. Nick Koston 96a448b02c
Fix bad except clauses order (#565) 2023-10-11 12:22:50 -10:00
J. Nick Koston 1d465e3a8a
Switch host resolver to use modern zeroconf APIs (#559) 2023-10-01 18:31:50 +01:00
Jesse Hills a17dc3c380
Add voice assistant audio settings (#556) 2023-09-27 08:34:07 +13:00
J. Nick Koston aecade1e1b
Small cleanups to connection code (#554) 2023-09-24 23:26:52 +02:00
J. Nick Koston 223eb23c05
Increase expected disconnect cooldown to 5.0 seconds (#540) 2023-09-05 19:22:13 -05:00
J. Nick Koston e0c4530dd8
Add additional connection logging (#539) 2023-09-05 19:21:55 -05:00
J. Nick Koston ca254f150c
Fix zeroconf listener being removed from zeroconf callback (#538) 2023-09-05 18:22:00 -05:00
J. Nick Koston 11a19438cb
Avoid a few calls to fetch loop time (#533) 2023-09-04 12:56:23 -05:00
J. Nick Koston 4c992365e0
Increase default bluetooth disconnect timeout to 20s (#528) 2023-09-03 08:28:39 -05:00
J. Nick Koston fee26d5387
Speed up zeroconf reconnect logic (#531) 2023-08-29 08:02:53 -05:00
Jesse Hills 55d112c89e
Add new VA event types (#529) 2023-08-28 09:35:18 +12:00
J. Nick Koston 81dad013d5
Cache uuid conversions (#524) 2023-08-16 00:10:11 -05:00
J. Nick Koston eebc7d99f2
Make entity info and state mappings constants (#523) 2023-08-15 22:19:46 -05:00
Jesse Hills 2c7b2ed1a0
Add wake word capability to voice assistant (#519) 2023-08-10 16:03:15 +12:00
J. Nick Koston 3bb2c085e6
Increase SO_RCVBUF to 2MiB to reduce chance of ESP32 cam disconnects (#515) 2023-07-27 08:47:01 -05:00
J. Nick Koston 8acefd1d05
Fix BadNameAPIError to include the expected name (#514) 2023-07-27 08:37:31 -05:00
J. Nick Koston b9ec1d0bc5
Remove impossible check in send_message_await_response (#513) 2023-07-27 08:32:30 -05:00
J. Nick Koston 48b56ad25c
Fix not trying to disconnect cleanly on forced disconnect (#512) 2023-07-27 08:28:14 -05:00
J. Nick Koston 762d00faff
Fix failed disconnect requests not being logged (#511) 2023-07-27 08:25:46 -05:00
J. Nick Koston 90cb44224a
Reduce memory churn by avoiding reprocessing BluetoothLERawAdvertisement (#507) 2023-07-27 08:17:40 -05:00
J. Nick Koston 2df4effef3
Reduce overhead to process packets (#503) 2023-07-21 04:37:17 -05:00
J. Nick Koston 3432477c20
Avoid some data Bluetooth data conversions (#501) 2023-07-21 03:33:07 -05:00
J. Nick Koston 49d86f940e
Refactor frame helpers to share more code (#500) 2023-07-21 03:11:04 -05:00
J. Nick Koston 589235c79d
Fix api calls not raising until timeout when the ESPHome device disconnects while waiting for a response (#498) 2023-07-20 12:01:57 -05:00
J. Nick Koston 82ab7e489d
Add messages to all task cancels (#497) 2023-07-19 15:37:59 -05:00
J. Nick Koston d63b9bbf5d
Upgrade python code to 3.9 (#496) 2023-07-19 15:33:28 -05:00
J. Nick Koston 2d89b9e267
Cleanup bluetooth connection failure code (#495) 2023-07-19 14:25:32 -05:00
J. Nick Koston 541ce059c0
Add slots to all models when using py3.10 or later (#459) 2023-07-18 17:23:07 -05:00
J. Nick Koston 65e659e4a5
Split _frame_helper into plain_text and noise (#491) 2023-07-18 14:28:56 -05:00
J. Nick Koston 8060c3c99d
Small speed up to bluetooth message wrapper (#490) 2023-07-18 14:11:06 -05:00
J. Nick Koston 7b215038f7
Cleanup connection send_message from earlier refactoring (#488) 2023-07-18 13:15:56 -05:00
J. Nick Koston 401ff3b61a
Reduce ChaCha20CipherReuseable overhead (#489) 2023-07-18 13:06:19 -05:00
J. Nick Koston 7196ca6ee8
Speed up encrypted handshake (#487) 2023-07-17 14:51:47 -10:00
J. Nick Koston ab3c096c9b
Speed up noise handshake (#486) 2023-07-17 14:13:58 -10:00
J. Nick Koston 0c1f710869
Cleanups to connect process (#485) 2023-07-17 10:11:34 -10:00
J. Nick Koston 92ec96469d
Remove memoryview wrapping for cameras (#484) 2023-07-17 09:47:06 -10:00
J. Nick Koston e909891ebe
Fix pong timer warning when pending ping is skipped (#483) 2023-07-17 09:27:59 -10:00
J. Nick Koston 6aeea79884
Speed up BLE connections (#482) 2023-07-15 11:16:44 -10:00
J. Nick Koston ed0a611994
Improve error reporting for authenticated vs non-authenticated requests (#481) 2023-07-15 10:34:46 -10:00
J. Nick Koston 24cddc22a8
Reduce overhead to send and process a complex message (#480) 2023-07-15 10:12:29 -10:00
J. Nick Koston f8ffa6ae83
Reduce overhead to send messages that need to wait for responses (#479) 2023-07-15 09:58:45 -10:00
J. Nick Koston bbfa761aa0
Speed up timeout implementation in send_message_await_response_complex (#478) 2023-07-15 09:28:06 -10:00
J. Nick Koston 5dd12169f1
Speed up formatting the cipher nonce (#477) 2023-07-15 09:12:33 -10:00
J. Nick Koston 8306058703
Improve performance of processing incoming packets (#475) 2023-07-15 08:48:47 -10:00
J. Nick Koston 0dbab1ebac
Make do_append and do_stop optional in send_message_await_response_complex (#474) 2023-07-15 08:31:37 -10:00
J. Nick Koston 0a0172fa89
Reduce latancy when sending complex messages (#473) 2023-07-15 08:24:03 -10:00
J. Nick Koston ce07e11e93
Reduce overhead to handle read exceptions (#472) 2023-07-15 08:18:31 -10:00
J. Nick Koston 0dfaa58f07
Simplify logic in send_message_callback_response (#471) 2023-07-15 08:00:33 -10:00
J. Nick Koston 9112a68bf9
Guard a few frequently called instance checks with if TYPE_CHECKING (#469) 2023-07-15 07:55:07 -10:00
J. Nick Koston 5f82e90b70
Reduce lookups for noise in the frame helper (#465) 2023-07-10 21:49:34 -10:00
J. Nick Koston 7a80e3529b
Improve error reporting when encryption is disabled on device but client requests it (#464) 2023-07-10 21:15:14 -10:00
J. Nick Koston 6b0d84110e
Avoid sending pings when we have traffic (#463) 2023-07-10 21:00:24 -10:00
J. Nick Koston 8ac62a321f
Improve performance of converting raw BLE advertisements (#462) 2023-07-09 13:06:06 -10:00
J. Nick Koston b81fe760ba
Improve performance reassembling fragmented packets (#461) 2023-07-09 12:10:33 -10:00
J. Nick Koston 69b4c42cf3
Add checks for debug logging in the write path (#458) 2023-07-03 19:54:22 -05:00
J. Nick Koston d53ab5d5bb
Use memoryview for camera images (#456) 2023-07-03 18:26:52 -05:00
J. Nick Koston f3f5bd6b55
Reduce protocol overhead (#454) 2023-07-03 11:57:04 -05:00
J. Nick Koston 974b8e3ac1
Check if debug is enabled once per packet (#455) 2023-07-02 16:55:36 -05:00
J. Nick Koston 34f6badcde
Use slots for APIConnection and APIClient (#453) 2023-07-01 16:31:58 -05:00
J. Nick Koston 59a66ba870
Include the server name in the exception for invalid encryption key (#452) 2023-07-01 11:12:38 -05:00
J. Nick Koston a8e7d40874
Speed up noise by using chacha20poly1305-reuseable (#451) 2023-06-30 09:04:26 -05:00
J. Nick Koston 4fe46f5aa0
Propagate if disconnect was expected to disconnect callback (#448) 2023-06-25 21:45:36 -05:00
J. Nick Koston eaa5e295cf
Fix more cases where incorrect encryption keys were not detected (#447) 2023-06-24 10:47:24 -05:00
Graham Brown a79da42aaf
Add support for alarm_control_panel entities (#427) 2023-06-12 10:39:49 +12:00
Jesse Hills 44f0b8027d
Add raw ble advertisements support (#439)
Co-authored-by: J. Nick Koston <nick@koston.org>
2023-06-07 00:42:57 -05:00
Jesse Hills 8340d2a6b8
Add use_vad flag to VA start request (#438) 2023-05-30 14:17:55 +12:00
Jesse Hills b1bfabacc7
Add conversation_id to VA start request (#437) 2023-05-30 11:18:28 +12:00
J. Nick Koston 8a661bb673
Reduce overhead to process bluetooth advertisements (#435) 2023-05-15 12:59:33 -05:00
J. Nick Koston 6b32b7c5a3
Avoid one dict lookup when processing packets (#431) 2023-05-08 10:07:51 -05:00
J. Nick Koston 7b8ed9fd03
Fix BLE connection timing out on failure instead of raising (#429) 2023-05-07 09:05:51 -05:00
J. Nick Koston 8261700bdd
Fix disconnecting while handshake is in process (#428) 2023-05-04 12:47:03 -05:00
J. Nick Koston de9b7266f1
Refactor reconnect logic to reduce complexity (#426) 2023-04-25 16:11:40 -04:00
J. Nick Koston 3f29ac92ad
Hold strong references to voice assistant tasks (#424) 2023-04-20 14:30:28 -10:00
J. Nick Koston 032e921cb3
Use sloted dataclass for BluetoothLEAdvertisement (#422) 2023-04-19 20:50:10 -10:00
J. Nick Koston a539a6e950
Improve data throughput (#421) 2023-04-19 20:47:38 -10:00
J. Nick Koston d1951ebd90
Remove _convert_bluetooth_le_name as it did not need to be its own function (#423) 2023-04-19 20:47:26 -10:00
Jesse Hills 15846c5896
Add initial voice assistant support (#412) 2023-04-11 15:57:35 +12:00
J. Nick Koston 48792681f2
Reduce uuid conversion overhead (#417) 2023-04-04 16:21:52 -10:00
Jesse Hills d7ae431c59
Disable pylint too-many-lines (#413) 2023-04-03 16:53:43 +12:00
J. Nick Koston d6fd9b6cfd
Add the ability to clear the cache to the API (#410)
Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
2023-03-27 10:47:21 +13:00
richardhopton 4bb8fbbed1
feat: Unsubscribe from BLE advertisements fully on unsub (#409) 2023-03-27 09:35:11 +13:00
J. Nick Koston b188803f46
Remove unused lock from frame helper (#406) 2023-03-17 12:09:34 -10:00
J. Nick Koston eacf758900
Allow any message from the remote to cancel the pong timer (#401) 2023-03-13 09:56:36 -10:00
Fredrik Gustafsson 2041d747cb
add pairing methods (#390) 2023-03-07 07:07:58 +13:00
J. Nick Koston 0327f75414
Adjust ping timeout to prevent premature disconnections (#395) 2023-03-05 18:56:22 -10:00
J. Nick Koston 51d581dd9c
Cooldown before reconnecting on expected disconnect (#397) 2023-03-05 18:54:54 -10:00
J. Nick Koston 81f6e67038
Fix disconnect message not being sent when disconnecting during hello phase (#396) 2023-03-05 18:52:55 -10:00
Fredrik Gustafsson 3e60332a71
Fix bluetooth_device_connect returning prematurely from a disconnect (#391) 2023-02-24 08:31:24 -06:00
Jesse Hills 4860af1edf
Add current_temp step (#384) 2023-02-20 13:17:47 +13:00