-
• #2
Well, if you don't like security, you could just use Espruino as server and poke a hole in your router's firewall and set up port forwarding.
I'm planning to implement a 'magic mirror' in the cloud (smoke and mirrors?) for my own use, with a couple of PHP scripts that stores (non-persistently) the state of sensors in my network (being updated by an Espruino periodically calling a page iwth appropriate arguments), and allowing me to set flags that will be seen when the device within the network polls the magic mirror.
-
• #4
For receiving webhooks without messing with firewalls etc use a public webserver to receive the request then poll that server for the data? My example is PHP - maybe be better in Go or Node.js, depending on how realtime you needed the thing to feel?
<?php const PRIVATE_KEY = "my_private_key"; // Authenticate if(!@$_REQUEST["key"] || $_REQUEST["key"] !== PRIVATE_KEY) { header('HTTP/1.0 401 Unauthorized'); echo 'HTTP/1.0 401 Unauthorized'; die(); } // Handle request if($_POST) { // Update data and write to a file - validation maybe - but it should be data you expect file_put_contents('data.espruino', json_encode($_POST)); } else { // Get data from file, set headers and display header('Content-Type: application/json'); echo file_get_contents('data.espruino'); }
-
• #5
Yeah, I was thinking that a lot of people might not have a webserver. Wasn't sure if there was some other service (like pastebin?) that could be used..
-
• #6
Dweet.io if people can't host something themselves? Not used but looks the part.
-
• #7
You can get a free webserver for a year from AWS, your own VM. you can use it to build Espruino firmware too ;-)
I think working apache and php is like half a dozen console commands, and you can copy-paste them from amazon's docs.
It turns out IFTTT have a Maker Channel now, which means you can trigger loads of random stuff (tweeting, emails, etc) to happen on the net really easily (thanks for letting me know @Ollie!).
To use it:
IFTTTKEY
variable. Also set up your WiFi access point name and password, and then write the code to Espruino.this
and chooseMaker
, thenReceive a web request
button_pressed
as the event namethat
and choose whatever you want to happenThis code actually resets your ESP8266 and connects to the wireless network each time you press the button. It takes a bit longer, but it's much more reliable as the ESP8266 will start from the same state each time.
Going back the other way (using Espruino as the
that
) is a bit more painful at the moment, because IFTTT expects to send a request to a web server that's available from the net. Does anyone have any good solutions to that?