From 4b560a3f62e1be5cdedf7aff7e564a1aea7a0380 Mon Sep 17 00:00:00 2001 From: generalmat82 <110256073+generalmat82@users.noreply.github.com> Date: Tue, 7 Oct 2025 00:18:27 -0400 Subject: [PATCH 1/7] Update README.rst Since API passwords are deprecated, I added information about using API encryption keys, instead of API Passwords to the readme file. --- README.rst | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index ac8e263a5..47cdbea91 100644 --- a/README.rst +++ b/README.rst @@ -35,11 +35,15 @@ Usage It's required that you enable the `Native API `_ component for the device. +The use of passwords for APIs in ESPHome is deprecated. Using an encryption key is the recomended method. + .. code:: yaml # Example configuration entry api: password: 'MyPassword' + encryption: + key: 'aaaaaaaaaaaaaaaaa/aaaaaaaaaaaaaaaaaaaaaaaaa=' # A key can be obtain at https://next.esphome.io/components/api/ Check the output to get the local address of the device or use the ``name:``under ``esphome:`` from the device configuration. @@ -60,7 +64,13 @@ The sample code below will connect to the device and retrieve details. """Connect to an ESPHome device and get details.""" # Establish connection - api = aioesphomeapi.APIClient("api_test.local", 6053, "MyPassword") + + # If a password is used in the ESP configuration use the following line: + api = aioesphomeapi.APIClient("api_test.local", 6053, "MyPassword",noise_psk='aaaaaaaaaaaaaaaaa/aaaaaaaaaaaaaaaaaaaaaaaaa=') + # OR + #If there is no password used in the ESP configuration: + api = aioesphomeapi.APIClient("api_test.local", 6053, None,noise_psk='aaaaaaaaaaaaaaaaa/aaaaaaaaaaaaaaaaaaaaaaaaa=') + await api.connect(login=True) # Get API version of the device's firmware @@ -86,7 +96,11 @@ Subscribe to state changes of an ESPHome device. async def main(): """Connect to an ESPHome device and wait for state changes.""" - cli = aioesphomeapi.APIClient("api_test.local", 6053, "MyPassword") + # If a password is used in the ESP configuration use the following line: + cli = aioesphomeapi.APIClient("api_test.local", 6053, "MyPassword",noise_psk='aaaaaaaaaaaaaaaaa/aaaaaaaaaaaaaaaaaaaaaaaaa=') + # OR + #If there is no password used in the ESP configuration: + cli = aioesphomeapi.APIClient("api_test.local", 6053, None, noise_psk='aaaaaaaaaaaaaaaaa/aaaaaaaaaaaaaaaaaaaaaaaaa=') await cli.connect(login=True) From c7f8a6f1869e998a5b7bf799fde891037ca9e022 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 7 Oct 2025 04:20:34 +0000 Subject: [PATCH 2/7] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 47cdbea91..22487b755 100644 --- a/README.rst +++ b/README.rst @@ -64,7 +64,7 @@ The sample code below will connect to the device and retrieve details. """Connect to an ESPHome device and get details.""" # Establish connection - + # If a password is used in the ESP configuration use the following line: api = aioesphomeapi.APIClient("api_test.local", 6053, "MyPassword",noise_psk='aaaaaaaaaaaaaaaaa/aaaaaaaaaaaaaaaaaaaaaaaaa=') # OR From f135d74bdc958adfa0c784d9de8cad151fc52f45 Mon Sep 17 00:00:00 2001 From: generalmat82 <110256073+generalmat82@users.noreply.github.com> Date: Tue, 7 Oct 2025 13:09:13 -0400 Subject: [PATCH 3/7] Update README.rst Fixed typos mentioned by @coderabbitai --- README.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index 22487b755..ce30ab886 100644 --- a/README.rst +++ b/README.rst @@ -35,7 +35,7 @@ Usage It's required that you enable the `Native API `_ component for the device. -The use of passwords for APIs in ESPHome is deprecated. Using an encryption key is the recomended method. +The use of passwords for APIs in ESPHome is deprecated. Using an encryption key is the recommended method. .. code:: yaml @@ -43,7 +43,7 @@ The use of passwords for APIs in ESPHome is deprecated. Using an encryption key api: password: 'MyPassword' encryption: - key: 'aaaaaaaaaaaaaaaaa/aaaaaaaaaaaaaaaaaaaaaaaaa=' # A key can be obtain at https://next.esphome.io/components/api/ + key: 'aaaaaaaaaaaaaaaaa/aaaaaaaaaaaaaaaaaaaaaaaaa=' # A key can be obtained at https://next.esphome.io/components/api/ Check the output to get the local address of the device or use the ``name:``under ``esphome:`` from the device configuration. From 848b3f89662465a6f32111c6d8064bf44dfc43b1 Mon Sep 17 00:00:00 2001 From: generalmat82 <110256073+generalmat82@users.noreply.github.com> Date: Tue, 7 Oct 2025 13:41:21 -0400 Subject: [PATCH 4/7] Update README.rst Applying deprecation message in ESPHome api config as proposed by @coderabbitai Also added info about the usage of the `noise_psk` option. --- README.rst | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/README.rst b/README.rst index ce30ab886..172e3e287 100644 --- a/README.rst +++ b/README.rst @@ -41,7 +41,7 @@ The use of passwords for APIs in ESPHome is deprecated. Using an encryption key # Example configuration entry api: - password: 'MyPassword' + password: 'MyPassword' # DEPRECATED: Use encryption key instead encryption: key: 'aaaaaaaaaaaaaaaaa/aaaaaaaaaaaaaaaaaaaaaaaaa=' # A key can be obtained at https://next.esphome.io/components/api/ @@ -65,11 +65,11 @@ The sample code below will connect to the device and retrieve details. # Establish connection - # If a password is used in the ESP configuration use the following line: - api = aioesphomeapi.APIClient("api_test.local", 6053, "MyPassword",noise_psk='aaaaaaaaaaaaaaaaa/aaaaaaaaaaaaaaaaaaaaaaaaa=') + # If a password is used in the ESP configuration, use the following line: + api = aioesphomeapi.APIClient("api_test.local", 6053, "MyPassword", noise_psk='aaaaaaaaaaaaaaaaa/aaaaaaaaaaaaaaaaaaaaaaaaa=') # noise_psk is optional and to be used only if an encryption key is configured. # OR - #If there is no password used in the ESP configuration: - api = aioesphomeapi.APIClient("api_test.local", 6053, None,noise_psk='aaaaaaaaaaaaaaaaa/aaaaaaaaaaaaaaaaaaaaaaaaa=') + # If there is no password used in the ESP configuration: + api = aioesphomeapi.APIClient("api_test.local", 6053, None, noise_psk='aaaaaaaaaaaaaaaaa/aaaaaaaaaaaaaaaaaaaaaaaaa=') # noise_psk is optional and to be used only if an encryption key is configured. await api.connect(login=True) @@ -96,11 +96,11 @@ Subscribe to state changes of an ESPHome device. async def main(): """Connect to an ESPHome device and wait for state changes.""" - # If a password is used in the ESP configuration use the following line: - cli = aioesphomeapi.APIClient("api_test.local", 6053, "MyPassword",noise_psk='aaaaaaaaaaaaaaaaa/aaaaaaaaaaaaaaaaaaaaaaaaa=') + # If a password is used in the ESP configuration, use the following line: + cli = aioesphomeapi.APIClient("api_test.local", 6053, "MyPassword", noise_psk='aaaaaaaaaaaaaaaaa/aaaaaaaaaaaaaaaaaaaaaaaaa=') # noise_psk is optional and to be used only if an encryption key is configured. # OR - #If there is no password used in the ESP configuration: - cli = aioesphomeapi.APIClient("api_test.local", 6053, None, noise_psk='aaaaaaaaaaaaaaaaa/aaaaaaaaaaaaaaaaaaaaaaaaa=') + # If there is no password used in the ESP configuration: + cli = aioesphomeapi.APIClient("api_test.local", 6053, None, noise_psk='aaaaaaaaaaaaaaaaa/aaaaaaaaaaaaaaaaaaaaaaaaa=') # noise_psk is optional and to be used only if an encryption key is configured. await cli.connect(login=True) From 41320b6bcdc7bb003b0a84bb6cfb02a0626127d1 Mon Sep 17 00:00:00 2001 From: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Date: Tue, 2 Dec 2025 12:13:41 +1300 Subject: [PATCH 5/7] Update README.rst Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 172e3e287..282e34506 100644 --- a/README.rst +++ b/README.rst @@ -43,7 +43,7 @@ The use of passwords for APIs in ESPHome is deprecated. Using an encryption key api: password: 'MyPassword' # DEPRECATED: Use encryption key instead encryption: - key: 'aaaaaaaaaaaaaaaaa/aaaaaaaaaaaaaaaaaaaaaaaaa=' # A key can be obtained at https://next.esphome.io/components/api/ + key: 'aaaaaaaaaaaaaaaaa/aaaaaaaaaaaaaaaaaaaaaaaaa=' # A key can be obtained at https://esphome.io/components/api/ Check the output to get the local address of the device or use the ``name:``under ``esphome:`` from the device configuration. From 620d9206a45329d10bfdc9586059a9c63be2d57c Mon Sep 17 00:00:00 2001 From: generalmat82 <110256073+generalmat82@users.noreply.github.com> Date: Mon, 1 Dec 2025 18:44:26 -0500 Subject: [PATCH 6/7] Applied Copilots comment at line 68 applied fixed for the 2nd comment by copilot about instantiation. --- README.rst | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/README.rst b/README.rst index 282e34506..61e8842a9 100644 --- a/README.rst +++ b/README.rst @@ -64,12 +64,13 @@ The sample code below will connect to the device and retrieve details. """Connect to an ESPHome device and get details.""" # Establish connection - - # If a password is used in the ESP configuration, use the following line: - api = aioesphomeapi.APIClient("api_test.local", 6053, "MyPassword", noise_psk='aaaaaaaaaaaaaaaaa/aaaaaaaaaaaaaaaaaaaaaaaaa=') # noise_psk is optional and to be used only if an encryption key is configured. - # OR - # If there is no password used in the ESP configuration: - api = aioesphomeapi.APIClient("api_test.local", 6053, None, noise_psk='aaaaaaaaaaaaaaaaa/aaaaaaaaaaaaaaaaaaaaaaaaa=') # noise_psk is optional and to be used only if an encryption key is configured. + # Choose ONE of the following options depending on your configuration: + # Option 1 - If both a password and an encryption key are in use: + #api = aioesphomeapi.APIClient("api_test.local", 6053, "MyPassword", noise_psk='aaaaaaaaaaaaaaaaa/aaaaaaaaaaaaaaaaaaaaaaaaa=') + # Option 2 - If only an encryption key is in use: + api = aioesphomeapi.APIClient("api_test.local", 6053, None, noise_psk='aaaaaaaaaaaaaaaaa/aaaaaaaaaaaaaaaaaaaaaaaaa=') + # Option 3 - If you only have a password: (Not recommended) + #api = aioesphomeapi.APIClient("api_test.local", 6053, "MyPassword") await api.connect(login=True) From f24d3b3254118152a7dc1d30c42a9a42c30caa71 Mon Sep 17 00:00:00 2001 From: generalmat82 <110256073+generalmat82@users.noreply.github.com> Date: Mon, 1 Dec 2025 18:54:39 -0500 Subject: [PATCH 7/7] Update connection options in README Clarified options for connecting to ESPHome device based on configuration. --- README.rst | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/README.rst b/README.rst index 61e8842a9..032299189 100644 --- a/README.rst +++ b/README.rst @@ -97,11 +97,13 @@ Subscribe to state changes of an ESPHome device. async def main(): """Connect to an ESPHome device and wait for state changes.""" - # If a password is used in the ESP configuration, use the following line: - cli = aioesphomeapi.APIClient("api_test.local", 6053, "MyPassword", noise_psk='aaaaaaaaaaaaaaaaa/aaaaaaaaaaaaaaaaaaaaaaaaa=') # noise_psk is optional and to be used only if an encryption key is configured. - # OR - # If there is no password used in the ESP configuration: - cli = aioesphomeapi.APIClient("api_test.local", 6053, None, noise_psk='aaaaaaaaaaaaaaaaa/aaaaaaaaaaaaaaaaaaaaaaaaa=') # noise_psk is optional and to be used only if an encryption key is configured. + # Choose ONE of the following options depending on your configuration: + # Option 1 - If both a password and an encryption key are in use: + #api = aioesphomeapi.APIClient("api_test.local", 6053, "MyPassword", noise_psk='aaaaaaaaaaaaaaaaa/aaaaaaaaaaaaaaaaaaaaaaaaa=') + # Option 2 - If only an encryption key is in use: + api = aioesphomeapi.APIClient("api_test.local", 6053, None, noise_psk='aaaaaaaaaaaaaaaaa/aaaaaaaaaaaaaaaaaaaaaaaaa=') + # Option 3 - If you only have a password: (Not recommended) + #api = aioesphomeapi.APIClient("api_test.local", 6053, "MyPassword") await cli.connect(login=True)