Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(WiFi): Add wifi.configure action #4186

Merged
merged 6 commits into from
Nov 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions components/wifi.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <config-templatable>`): The name of the WiFi access point.
- **password** (*Required*, string, :ref:`templatable <config-templatable>`): The password of the WiFi access point. Leave empty for no password.
- **save** (*Optional*, boolean, :ref:`templatable <config-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 <config-templatable>`): The time to wait for the connection to be established. Defaults to 30 seconds.
- **on_connect** (*Optional*, :ref:`Automation <automation>`): An action to be performed when a connection is established.
- **on_error** (*Optional*, :ref:`Automation <automation>`): An action to be performed when the connection fails.

.. _wifi-connected_condition:

Expand Down