From 4a4d0ae752edbfd13eda87cefbb715bb642d5aea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodrigo=20Mart=C3=ADn?= Date: Sun, 24 Nov 2024 23:06:23 +0100 Subject: [PATCH] feat(WiFi): Add wifi.configure action (#4186) --- components/wifi.rst | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/components/wifi.rst b/components/wifi.rst index 89ac82eed..a25a4dc06 100644 --- a/components/wifi.rst +++ b/components/wifi.rst @@ -327,6 +327,35 @@ This action turns on the WiFi interface on demand. The configuration option ``enable_on_boot`` can be set to ``false`` if you do not want wifi to be enabled on boot. +.. _wifi-configure: + +``wifi.configure`` Action +-------------------------------- + +This action connects to an SSID and password, optionally saving it in persistent memory so that the next time the WiFi interface is enabled, it will connect to the stored access point. + +.. code-block:: yaml + + on_...: + then: + - wifi.configure: + ssid: "MyHomeNetwork" + password: "VerySafePassword" + save: true + timeout: 30000ms + on_connect: + - logger.log: "Connected to WiFi!" + on_error: + - logger.log: "Failed to connect to WiFi!" + +Configuration variables: + +- **ssid** (*Required*, string, :ref:`templatable `): The name of the WiFi access point. +- **password** (*Required*, string, :ref:`templatable `): The password of the WiFi access point. Leave empty for no password. +- **save** (*Optional*, boolean, :ref:`templatable `): If set to ``true``, the SSID and password will be saved in persistent memory. Defaults to ``true``. +- **timeout** (*Optional*, :ref:`config-time`, :ref:`templatable `): The time to wait for the connection to be established. Defaults to 30 seconds. +- **on_connect** (*Optional*, :ref:`Automation `): An action to be performed when a connection is established. +- **on_error** (*Optional*, :ref:`Automation `): An action to be performed when the connection fails. .. _wifi-connected_condition: