Add Factory Reset button and switch (#2280)

This commit is contained in:
anatoly-savchenkov 2022-09-12 01:23:55 +03:00 committed by GitHub
parent e2a524bd5a
commit 6d9648aa2d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 119 additions and 1 deletions

View File

@ -0,0 +1,51 @@
Factory Reset Button
====================
.. seo::
:description: Instructions for setting up buttons that can remotely invalidate all ESPHome preferences stored in flash and reboot ESP.
:image: restart.svg
The ``factory_reset`` button allows you to remotely invalidate (reset) all ESPHome :ref:`preferences <preferences-flash_write_interval>` stored in flash memory and reboot your node.
After reboot all states, parameters and variables will be reinitialized with their default values. This is useful:
- for devices preflashed with ESPHome to reset behavior back to factory state
- in case of moving a device to a new environment or starting a new use-case (e.g. reset counters or state)
- for privacy concerns when giving away a device
.. note::
**USE WITH GREAT CAUTION!** All credentials, global variables, counters and saved states stored in non-volatile memory will be lost with no chance of recovering them.
Even raw reading of flash memory with ``esptool`` will not help, since data is physically erased from flash memory.
For devices configured using :doc:`captive portal </components/captive_portal>`, this will reset WiFi settings as well, thus making such devices offline.
You'll need to be in close proximity to your device to configure it again using a built-in WiFi access point and captive portal.
.. figure:: images/factory-rst-ui.png
:align: center
:width: 80.0%
.. code-block:: yaml
# Example configuration entry
button:
- platform: factory_reset
name: Restart with Factory Default Settings
Configuration variables:
------------------------
- **name** (**Required**, string): The name of the button.
- **id** (*Optional*, :ref:`config-id`): Manually specify the ID used for code generation.
- All other options from :ref:`Button <config-button>`.
See Also
--------
- :doc:`shutdown`
- :doc:`restart`
- :doc:`safe_mode`
- :doc:`/components/switch/factory_reset`
- :doc:`template`
- :apiref:`factory_reset/factory_reset_button.h`
- :ghedit:`Edit`

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

View File

@ -25,6 +25,9 @@ Configuration variables:
See Also
--------
- :doc:`shutdown`
- :doc:`safe_mode`
- :doc:`factory_reset`
- :doc:`/components/switch/restart`
- :doc:`template`
- :apiref:`restart/button/restart_button.h`

View File

@ -33,6 +33,8 @@ See Also
- :doc:`shutdown`
- :doc:`restart`
- :doc:`factory_reset`
- :doc:`/components/switch/safe_mode`
- :doc:`template`
- :apiref:`safe_mode/safe_mode_button.h`
- :ghedit:`Edit`

View File

@ -32,6 +32,9 @@ See Also
--------
- :doc:`restart`
- :doc:`safe_mode`
- :doc:`factory_reset`
- :doc:`/components/switch/shutdown`
- :doc:`template`
- :apiref:`shutdown/shutdown_button.h`
- :ghedit:`Edit`

View File

@ -0,0 +1,51 @@
Factory Reset Switch
====================
.. seo::
:description: Instructions for setting up switches that can remotely invalidate all ESPHome preferences stored in flash and reboot ESP.
:image: restart.svg
The ``factory_reset`` switch allows you to remotely invalidate (reset) all ESPHome :ref:`preferences <preferences-flash_write_interval>` stored in flash memory and reboot your node.
After reboot all states, parameters and variables will be reinitialized with their default values. This is useful:
- for devices preflashed with ESPHome to reset behavior back to factory state
- in case of moving a device to a new environment or starting a new use-case (e.g. reset counters or state)
- for privacy concerns when giving away a device
.. note::
**USE WITH GREAT CAUTION!** All credentials, global variables, counters and saved states stored in non-volatile memory will be lost with no chance of recovering them.
Even raw reading of flash memory with ``esptool`` will not help, since data is physically erased from flash memory.
For devices configured using :doc:`captive portal </components/captive_portal>`, this will reset WiFi settings as well, thus making such devices offline.
You'll need to be in close proximity to your device to configure it again using a built-in WiFi access point and captive portal.
.. figure:: images/factory-rst-ui.png
:align: center
:width: 80.0%
.. code-block:: yaml
# Example configuration entry
switch:
- platform: factory_reset
name: Restart with Factory Default Settings
Configuration variables:
------------------------
- **name** (**Required**, string): The name of the switch.
- **id** (*Optional*, :ref:`config-id`): Manually specify the ID used for code generation.
- All other options from :ref:`Switch <config-switch>`.
See Also
--------
- :doc:`shutdown`
- :doc:`restart`
- :doc:`safe_mode`
- :doc:`/components/button/factory_reset`
- :doc:`template`
- :apiref:`factory_reset/factory_reset_switch.h`
- :ghedit:`Edit`

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.1 KiB

View File

@ -29,9 +29,10 @@ Configuration variables:
See Also
--------
- :doc:`/components/button/restart`
- :doc:`shutdown`
- :doc:`safe_mode`
- :doc:`factory_reset`
- :doc:`/components/button/restart`
- :doc:`template`
- :apiref:`restart/switch/restart_switch.h`
- :ghedit:`Edit`

View File

@ -33,6 +33,8 @@ See Also
- :doc:`shutdown`
- :doc:`restart`
- :doc:`factory_reset`
- :doc:`/components/button/safe_mode`
- :doc:`template`
- :apiref:`safe_mode/safe_mode_switch.h`
- :ghedit:`Edit`

View File

@ -32,6 +32,9 @@ See Also
--------
- :doc:`restart`
- :doc:`safe_mode`
- :doc:`factory_reset`
- :doc:`/components/button/shutdown`
- :doc:`template`
- :apiref:`shutdown/shutdown_switch.h`
- :ghedit:`Edit`

View File

@ -495,6 +495,7 @@ Switch Components
Restart Switch, components/switch/restart, restart.svg
Safe Mode Switch, components/switch/safe_mode, restart-alert.svg
Shutdown Switch, components/switch/shutdown, power_settings.svg
Factory Reset Switch, components/switch/factory_reset, restart-alert.svg
Generic Output Switch, components/switch/output, upload.svg
Template Switch, components/switch/template, description.svg
UART Switch, components/switch/uart, uart.svg
@ -515,6 +516,7 @@ Button Components
Restart Button, components/button/restart, restart.svg
Safe Mode Button, components/button/safe_mode, restart-alert.svg
Shutdown Button, components/button/shutdown, power_settings.svg
Factory Reset Button, components/button/factory_reset, restart-alert.svg
Wake-on-LAN, components/button/wake_on_lan, power_settings.svg
Fan Components