From f5197b64725a79958fda170530010795fbf29c33 Mon Sep 17 00:00:00 2001 From: Denis Stepanov <22733222+denis-stepanov@users.noreply.github.com> Date: Sun, 28 Nov 2021 02:55:57 +0100 Subject: [PATCH] Add scripting examples --- README.md | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 93ce419..ff935c7 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,40 @@ The LED is constantly lit during Wi-Fi reconfiguration process. * Action log, showing bulb manipulations via a button, web page or timer event: ![log](data/images/screenshot-log.jpg) - + +## Scripting (Linux) +* Flip the lights with `curl`: +``` +$ curl -s ybutton1.local/?flip | grep Lights +Lights are ON +$ +``` + +* Flip the lights with `wget`: +``` +$ wget -qO - ybutton1.local/?flip | grep Lights +Lights are ON +$ +``` + +* Flip the lights with pure `bash`: +``` +$ ./flip.sh +Lights are ON +$ cat flip.sh +#!/bin/bash + +exec {ybutton}<>/dev/tcp/ybutton1.local/80 +echo -e "GET /?flip HTTP/1.0\r\n\r\n" >&$ybutton +while read -u $ybutton +do + [[ $REPLY == Lights* ]] && echo $REPLY && break +done +exec {ybutton}>&- +$ +``` +Support for mDNS (`*.local` addresses) is usually enabled by default; if it is not the case, check your Linux distro docs on how to enable it. + ## Prerequisites 1. Hardware: ESP8266. Tested with: 1. [ESP-12E Witty Cloud](https://www.instructables.com/Witty-Cloud-Module-Adapter-Board/), Arduino IDE board setting: "LOLIN(WEMOS) D1 R2 and mini";