Post your best Lua script examples here

User avatar
By devlab
#36987 At first I needed something simple with a web interface for reliably turning on/off a couple of mains sockets. A year after, the idea evolved into this: IoT Power Strip.
The NodeMCU based software implemented to fit the minimal set of requirements I visualized for such kind of thing:
    * Wi-Fi shall be configurable through Web Interface (both Access Point (AP) and connection to another Wi-Fi network); Wi-Fi re-configuration shall not influence on mains sockets state; such a trivial thing like moving power strip from one place (with one Wi-Fi network) to another (with another Wi-Fi network or without it) shall not prevent re-configuring of it with the Web UI;
    * The device shall work even without Wi-Fi network available (detect it during start up, and turn on AP where a smartphone can connect);
    * Some functions of UI shall be accessible to admin only, some - to user (2 security roles); the credentials shall be configurable through Web UI;
    * Controls for turning on/off shall be configurable through Web interface;
    * Web IDE shall exist for quick fixing / small enhancements. Web IDE shall work without Internet access (intranet created by ESP8266 AP shall be enough).
To satisfy the requirements, I have built the device using both ESP8266 (ESP-01) module and Arduino Pro module; the functionality reqired above are split among them.
So, if you have the similar list of requirements, welcome to my GitHub repositories: