Shutdown Switch

This platform allows you to put your ESP8266/ESP32 to sleep until it is manually restarted by either pressing the reset button or toggling the power supply.

It is especially useful if you’re using esphomelib with battery cells that must not be discharged too much.

Example Usage

App.make_shutdown_switch("Livingroom Shutdown");

See Application::make_shutdown_switch().

API Reference

class ShutdownSwitch : public switch_::Switch

A simple switch that will put the node into deep sleep indefinitely.

Public Functions

ShutdownSwitch(const std::string &name)
std::string icon()

Override this to set the Home Assistant icon for this switch.

Return “” to disable this feature.

The icon of this switch, for example “mdi:fan”.

Protected Functions

void write_state(bool state)

Write the given state to hardware.

You should implement this abstract method if you want to create your own switch.

In the implementation of this method, you should also call publish_state to acknowledge that the state was written to the hardware.

  • state: The state to write. Inversion is already applied if user specified it.