Also, maybe I'm just crazy, but man I can't believe people are encouraging others to curl stuff from the internet right into a shell. Especially on Raspian where the default Pi user has NOPASSWD in sudoers, this seems like a bad practice that we shouldn't encourage.
given that this is the RethinkDB blog, I'm pretty sure that is the point: a nice little toy example to show what it can do.
That said, the node parts probably could have been done in Python as well and made the entire thing a bit easier.
I definitely wanted to do all parts in Python but am somewhat allergic to the `while True:` pattern necessary in Python for changfeeds. I haven't brought myself up-to-date on the more recent asyncio library to write the more Pythonic `yield from` for a changefeeds example.
Would you know how to do this in Python elegantly? Because I would love to rip out the Node/Javascript parts.
What I think RethinkDB adds here is the WebUI interface and an easy to way to come to grips with what information is being stored on the machine versus digging around in the home directory, or project folder, or /var/log/ for the right log file (I've come to a consensus with myself many times on where I should put it and definitely forget where). Also, spinning up and replicating the data over to another machine is click-easy and convenient.
As for having the entire functionality in one Python script, it was more of wanting to have à la carte functionality since I know projects like this coming in all shapes and sizes. I definitely agree that from a simplicity point of view, one Python script would be much easier. But, I wanted people to be able to just copypasta what they wanted and go from there with multiple sensors or multiple notification messages.
I also did not like the Node dependencies (why is installing Node on RBPi still so hard?). I felt though that I couldn't get behind doing the un-Pythonic `while True:` pattern necessary for RethinkDB changefeeds. In the near future we'll have better patterns with asyncio but Node felt like a better fit from an elegance/grok-ability standpoint in this case.
In this particular case a simple C program logging to a comma-delimited text file, or, if you want to splurge, JSON-formatted text file would have done the job.
But, I get it, proposing not everything requires OOP is heresy. What was I thinking?
[1] http://librato.com hardware guide I used: https://learn.adafruit.com/dht-humidity-sensing-on-raspberry...
I built a temperature sensor for a server rack [1], and went with an ATMega328 and an ENC28J60 ethernet module, and it just serves JSON of the four DHT11 sensors connected to it.