From d0b67689e06f6ecebcf79c8c84a315e25964f07a Mon Sep 17 00:00:00 2001 From: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Date: Wed, 25 Jan 2023 23:07:57 +1300 Subject: [PATCH] Add issue to ESPHome deprecating api password (#86606) Co-authored-by: Franck Nijhof --- homeassistant/components/esphome/__init__.py | 25 +++++++++++++++++++ homeassistant/components/esphome/strings.json | 4 +++ .../components/esphome/translations/en.json | 4 +++ 3 files changed, 33 insertions(+) diff --git a/homeassistant/components/esphome/__init__.py b/homeassistant/components/esphome/__init__.py index 826bf79260b..8cefac41859 100644 --- a/homeassistant/components/esphome/__init__.py +++ b/homeassistant/components/esphome/__init__.py @@ -107,6 +107,30 @@ def _async_check_firmware_version( ) +@callback +def _async_check_using_api_password( + hass: HomeAssistant, device_info: EsphomeDeviceInfo, has_password: bool +) -> None: + """Create or delete an the api_password_deprecated issue.""" + # ESPHome device_info.mac_address is the unique_id + issue = f"api_password_deprecated-{device_info.mac_address}" + if not has_password: + async_delete_issue(hass, DOMAIN, issue) + return + async_create_issue( + hass, + DOMAIN, + issue, + is_fixable=False, + severity=IssueSeverity.WARNING, + learn_more_url="https://esphome.io/components/api.html", + translation_key="api_password_deprecated", + translation_placeholders={ + "name": device_info.name, + }, + ) + + async def async_setup_entry( # noqa: C901 hass: HomeAssistant, entry: ConfigEntry ) -> bool: @@ -309,6 +333,7 @@ async def async_setup_entry( # noqa: C901 await cli.disconnect() else: _async_check_firmware_version(hass, device_info) + _async_check_using_api_password(hass, device_info, bool(password)) async def on_disconnect() -> None: """Run disconnect callbacks on API disconnect.""" diff --git a/homeassistant/components/esphome/strings.json b/homeassistant/components/esphome/strings.json index 49634fc830e..ebbc97374c2 100644 --- a/homeassistant/components/esphome/strings.json +++ b/homeassistant/components/esphome/strings.json @@ -50,6 +50,10 @@ "ble_firmware_outdated": { "title": "Update {name} with ESPHome {version} or later", "description": "To improve Bluetooth reliability and performance, we highly recommend updating {name} with ESPHome {version} or later. When updating the device to ESPHome {version}, it is recommended to use a serial cable instead of an over-the-air update to take advantage of the new partition scheme." + }, + "api_password_deprecated": { + "title": "API Password deprecated on {name}", + "description": "The API password for ESPHome is deprecated and the use of an API encryption key is recommended instead.\n\nRemove the API password and add an encryption key to your ESPHome device to resolve this issue." } } } diff --git a/homeassistant/components/esphome/translations/en.json b/homeassistant/components/esphome/translations/en.json index 76abe1d0dd8..b11792dcd78 100644 --- a/homeassistant/components/esphome/translations/en.json +++ b/homeassistant/components/esphome/translations/en.json @@ -47,6 +47,10 @@ } }, "issues": { + "api_password_deprecated": { + "description": "The API password for ESPHome is deprecated and the use of an API encryption key is recommended instead.\n\nRemove the API password and add an encryption key to your ESPHome device to resolve this issue.", + "title": "API Password deprecated on {name}" + }, "ble_firmware_outdated": { "description": "To improve Bluetooth reliability and performance, we highly recommend updating {name} with ESPHome {version} or later. When updating the device to ESPHome {version}, it is recommended to use a serial cable instead of an over-the-air update to take advantage of the new partition scheme.", "title": "Update {name} with ESPHome {version} or later"