76 Commits

Author SHA1 Message Date
J. Nick Koston
3aa1c60fe3
ESPHome quality improvements round 2 (#143613)
Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
2025-04-24 09:51:33 -10:00
J. Nick Koston
01e2c3272b
Improve error message when ESPHome reconfigure selects an unexpected device (#143608) 2025-04-24 08:44:02 -10:00
J. Nick Koston
65db3c1164
Fix display issues with ESPHome encryption key steps (#143483) 2025-04-23 18:39:32 +02:00
J. Nick Koston
849121a124
Improve human-readable name for new/reauth/reconfig in ESPHome (#143302)
* Improve human-readable prompt when requesting ESPHome credentials

Users reported difficulty identifying which device needs reauthentication, especially when names are similar (e.g., `power-meter` vs `power-meter-EEFF`). Previously, only the hostname was shown, which led to confusion. This change includes the config entry title or friendly name—when available—in the prompt to make device identification easier.

* Update homeassistant/components/esphome/config_flow.py

* add missing cover

* tweaks

* one more

* one more

* cover

* some are ``, some are not, make them all ``

* Apply suggestions from code review

---------

Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2025-04-21 10:25:14 -04:00
J. Nick Koston
6698b3a1dc
Improve ESPHome abort messages for already-configured devices (#143289)
* Improve ESPHome abort messages for already-configured devices

Users often struggle to identify which ESPHome device is already configured—especially when replacing a device or renaming an existing one.
This PR improves the abort messages to include more helpful details, so users can pinpoint the conflicting device without needing to dig through the `core.config_entries` file manually.

* Update homeassistant/components/esphome/strings.json
2025-04-21 09:41:15 -04:00
J. Nick Koston
3e3697dc7a
Add reconfigure support to ESPHome (#143132) 2025-04-19 12:40:07 +02:00
J. Nick Koston
ae306893ff
Handle name conflicts in ESPHome config flow (#142966) 2025-04-15 08:09:51 -10:00
J. Nick Koston
8767599ad4
Validate ESPHome mac address before updating IP on discovery (#142878)
* Bump aioesphomeapi to 29.10.0

changelog: https://github.com/esphome/aioesphomeapi/compare/v29.9.0...v29.10.0

* Validate ESPHome mac address before updating IP on discovery

In some cases the data coming in from discovery may be
stale since there is a small race window if devices
get new IP allocations. Since some routers do not update
their names right away and zeroconf has a non-zero TTL
there is a small window where the discovery data can be
stale. This is a rare condition but it does happen. With
aioesphomeapi 29.10.0+ and ESPHome 2025.4.x+ we can validate
the mac address even without the correct encryption key
which allows us to be able to always validate the MAC
before updating the IP from any discovery method.

* tweaks

* fix test
2025-04-14 10:02:46 +02:00
J. Nick Koston
1639163c2e
Handle encryption being disabled on an ESPHome device (#141887)
fixes #121442
2025-03-30 21:25:24 -04:00
J. Nick Koston
81db3dea41
Add option to ESPHome to subscribe to logs (#139073) 2025-02-25 21:56:39 +01:00
epenet
af40b6524e
Use new ServiceInfo location in component tests (part 3) (#136064) 2025-01-20 13:16:59 +01:00
Markus
ee30520b57
Fix esphome mqtt discovery by handling case where payload is a empty string (#129969)
Co-authored-by: J. Nick Koston <nick@koston.org>
2024-11-07 11:16:01 -06:00
Robert Resch
380974eed4
Remove hassio from ALLOWED_USED_COMPONENTS and move some functions to helper (#127228)
* Remove hassio from ALLOWED_USED_COMPONENTS

* Move HassioServiceInfo to helpers.service_info

* Deprecate moved functions

* Add note about deprecation

* Fix tests

* Implement suggestion

* Typo

* Update pyproject.toml

Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>

---------

Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
2024-10-30 12:43:41 +01:00
epenet
99335a07e5
Use start_reauth helper method in integration tests (e-g) (#124785)
* Use start_reauth helper method in integration tests (e-g)

* Include fireservicerota
2024-08-28 15:47:57 +02:00
epenet
e446875c7e
Improve type hints in esphome tests (#120674) 2024-06-27 09:33:14 -05:00
J. Nick Koston
edaa5c60a7
Small cleanups to ESPHome (#120414) 2024-06-25 17:00:03 +02:00
epenet
b2a54c50e2
Move mock_zeroconf to decorator in tests (#119061) 2024-06-07 20:55:20 +02:00
epenet
2e155f4de5
Move esphome coordinator to separate module (#117427) 2024-05-14 15:16:47 +02:00
Markus
ed4c3196ab
Add ESPhome discovery via MQTT (#116499)
Co-authored-by: J. Nick Koston <nick@koston.org>
2024-05-10 13:32:42 +02:00
Joost Lekkerkerker
9b41e3d124
Use is in enum comparison in config flow tests A-E (#114669) 2024-04-02 11:22:05 -10:00
Marc Mueller
38adfbf1a3
Add empty line after module docstring [tests a-e] (#112708) 2024-03-08 08:50:25 -05:00
J. Nick Koston
730e8ab5f3
Fix formatting of mac addresses from dhcp discovery mocking in esphome (#110567)
dhcp returns addresses in lowercase without :
2024-02-14 20:57:37 +01:00
Marc Mueller
7a89e58873
Use builtin TimeoutError [e-i] (#109679) 2024-02-05 12:00:37 +01:00
J. Nick Koston
e2314565bb
Fix ESPHome Bluetooth diagnostics (#106151) 2023-12-20 18:33:43 -10:00
J. Nick Koston
0eca433004
Update zeroconf discovery to use IPAddress objects to avoid conversions (#100567) 2023-09-19 18:58:46 +02:00
Franck Nijhof
868a5f377f
Ruff: isort don't split imports based on trailing comma (#98162) 2023-08-10 14:27:03 +02:00
J. Nick Koston
b106ca7983
Fix race fetching ESPHome dashboard when there are no devices set up (#96196)
* Fix fetching ESPHome dashboard when there are no devices setup

fixes #96194

* coverage

* fix
2023-07-11 14:11:51 -04:00
J. Nick Koston
995fb993e6
Avoid probing ESPHome devices when we do not have the encryption key (#95820) 2023-07-09 12:57:04 -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
J. Nick Koston
7bdd64a3f7
Handle invalid utf-8 from the ESPHome dashboard (#95743)
If the yaml file has invalid utf-8, the config flow would raise an
unhandled exception. Allow the encryption key to be entered manually
in this case instead of a hard failure

fixes #92772
2023-07-02 22:47:25 -04:00
J. Nick Koston
f0cb03e631
Handle missing or incorrect device name and unique id for ESPHome during manual add (#95678)
* Handle incorrect or missing device name for ESPHome noise encryption

If we did not have the device name during setup we could never
get the key from the dashboard. The device will send us
its name if we try encryption which allows us to find the
right key from the dashboard.

This should help get users unstuck when they change the key
and cannot get the device back online after deleting and
trying to set it up again manually

* bump lib to get name

* tweak

* reduce number of connections

* less connections when we know we will fail

* coverage shows it works but it does not

* add more coverage

* fix test

* bump again
2023-07-02 10:29:45 -04:00
J. Nick Koston
85d6e03dd3
Require newly configured esphome device to allow Home Assistant service calls (#95143)
* Require esphome service calls to be enabled

For existing devices, calling Home Assistant services continues
to be allowed.

For newly configured devices, it must now be enabled in the options
flow

* fix

* adjust

* coverage

* adjust

* fix test

* Update homeassistant/components/esphome/strings.json

Co-authored-by: Paulus Schoutsen <balloob@gmail.com>

* Update homeassistant/components/esphome/strings.json

Co-authored-by: Paulus Schoutsen <balloob@gmail.com>

* Update homeassistant/components/esphome/strings.json

Co-authored-by: Paulus Schoutsen <balloob@gmail.com>

* Update homeassistant/components/esphome/__init__.py

Co-authored-by: Paulus Schoutsen <balloob@gmail.com>

* Update homeassistant/components/esphome/__init__.py

Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>

* Update homeassistant/components/esphome/__init__.py

Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>

---------

Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
2023-06-25 21:18:21 -04:00
Erik Montnemery
63f3767a29
Include UUID in hassio discovery data (#91970) 2023-04-25 09:48:47 +02:00
epenet
b94dffb7d3
Add missing mock in esphome tests (#88923) 2023-03-01 16:11:21 +01:00
epenet
b9beed4624
Add type hints to integration tests (part 6) (#87979) 2023-02-13 09:45:11 +01:00
epenet
3052de3e8e
Add type hints to integration tests (d-e) (#87699) 2023-02-08 13:01:44 +01:00
Paulus Schoutsen
d88849fb04
ESPHome handle remove password and no encryption (#86995)
* ESPHome handle remove password and no encryption

* Start reauth for invalid api password

---------

Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
2023-01-30 23:05:48 -05:00
Paulus Schoutsen
98b4a412f7
ESPHome discovered dashboard checks reauth flows (#86993) 2023-01-30 21:32:52 -05:00
Paulus Schoutsen
2cdeb6f1cd
Check dashboard when showing reauth form (#86980) 2023-01-30 22:46:42 +01:00
Jesse Hills
78207121c0
Remove esphome password from config flow data if not needed (#86763)
* Remove esphome password if not needed

* Add test

Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2023-01-26 21:45:51 -05:00
Paulus Schoutsen
a83318f373
ESPHome dashboard tweaks (#86176) 2023-01-18 21:15:37 +01:00
Paulus Schoutsen
29337bc6eb
Reload ESPHome config entries when dashboard info received (#86174) 2023-01-18 17:59:55 +01:00
Paulus Schoutsen
06bc9c7b22
Automatically fetch the encryption key from the ESPHome dashboard (#85709)
* Automatically fetch the encryption key from the ESPHome dashboard

* Also use encryption key during reauth

* Typo

* Clean up tests
2023-01-11 15:28:31 -05:00
Paulus Schoutsen
82ec769ec5
Handle ESPHome dashboard discovery (#85662) 2023-01-11 08:30:52 -05:00
Paulus Schoutsen
d3df4dd3c1
ESPHome: Use MAC as unique ID (#83741)
* ESPHome: Use MAC as unique ID

* Normalize incoming zeroconf/dhcp macs

* Update comment

* Test ESPHome without mac in zeroconf

* Use format_mac

* Remove unique ID index from DomainData
2022-12-10 22:26:42 -05:00
J. Nick Koston
4a56461d3c
Fix reauth with esphome when adding noise encryption (#83164)
* Fix reauth with esphome when adding noise encryption

fixes #80813

* fix with unique id
2022-12-02 19:49:13 -05:00
J. Nick Koston
9a5bdaf87e
Ensure unique id is set for esphome when setup via user flow (#77677) 2022-09-01 14:10:20 -04:00
Franck Nijhof
a6244eea28
Search/replace RESULT_TYPE_* by FlowResultType enum (#74656) 2022-07-07 21:28:18 +02:00
Jesse Hills
f311d53c60
ESPHome use dhcp responses to update connection host of known devices (#74206)
* ESPHome use dhcp responses to update connection host of known devices

* Add test for dhcp

* Add another test to cover when there are no changes required
2022-06-30 10:07:03 -07:00
Joshua Roys
9134e5c844
Get discovered zeroconf IPv6 addresses (#65462) 2022-02-11 16:46:17 -06:00