
Raspberry Pi 3 based home automation with Node.js and React Native - sconxu
https://github.com/deepsyx/home-automation
======
pjungwir
This looks like a lot of fun! Using a RaspPi is really attractive to me
because you can make everything interoperate, and nothing depends on some
company's servers.

I've done two Pi projects now that I keep meaning to blog about. One was a
sprinkler control system. My old system was dying, and not very flexible, so I
decided to run everything off a Pi. The tricky part was driving 13 sprinkler
lines with 24V AC current. I bought a 16-relay board and eventually got it
wired up. For someone with little electronics experience, there was a lot to
learn. [1] is an attempt before I realized I had to use the relays. Eventually
I got it working and used it all summer. With cron, I can schedule things
however I want!

The second is a security camera for a vacation rental home, and is not quite
done yet. The hardware side was not challenging at all, but I still need to
work out how to copy the images up to S3 or a Linode. I'm using MotionEyeOS
and it doesn't seem to know how to do that itself. One of the big reasons I
went with a Pi is I didn't want to pay or rely on someone else's servers. Also
I wanted to avoid the security problems that have been in the news lately. I
don't want inbound traffic to my LAN; I'd rather push the video somewhere
else.

It took me a long time to figure out worthwhile uses for a Pi. A friend of
mine loves using these things for media servers and CI servers and whatnot,
but to me it's only satisfying if it's something where you actually _need_ the
miniature scale. Also a Pi really hits the sweet spot for me in terms of
hardware-vs-software. I'm sure I could have done the first project with an
Arduino, but using ssh, cron, and python was really nice.

[1]
[http://raspberrypi.stackexchange.com/questions/50435/driving...](http://raspberrypi.stackexchange.com/questions/50435/driving-24vac-
sprinkler-solenoids-through-uln2003a)

~~~
haroldp
I too replaced my dying PoS Rainbird irrigation controller with a raspberry pi
and a relay board.

> With cron, I can schedule things however I want!

Wait, are you not using sprinklers_pi[1]? I highly recommend it.

I have more home pi/arduino/IoT projects coming up, but I am thinking it's
going to be a lot of work _integrating_ them. I'd like one home app/page that
integrates them all.

1\.
[https://github.com/rszimm/sprinklers_pi/wiki](https://github.com/rszimm/sprinklers_pi/wiki)

~~~
kzisme
What did you dislike about your Rainbird system ?

~~~
twothamendment
I installed my own sprinklers and drip - 22 zones of it. A Rainbird controller
was going to be nearly $300. I went with a pi and loved it. Then came the real
problem - I put the home on the market and ended up replacing my pi with a
rainbird for the next people. Why? I kinda wanted to keep my setup and buyers
didn't know what to think of it.

After I swapped it out I missed quite a few things - controlling it from my
phone, from home or remote, being able to pull up a graph and see how long
each zone ran. I wasn't in the mood to get up at 3am to see if the rainbird
was working so I crossed my fingers and hoped it would work at least until the
house sold. Setting up all my zones was a lot faster on the pi than it was
with cranky dials and buttons on the rainbird. I won't miss it.

------
redsummer
I managed to get bilingual voice activation (Alexa and Siri/HomeKit - maybe
Google Home in future) working with Home Assistant, homebridge, pi-mote,
raspberry pi 3 and four energenie sockets. (In the US I guess you could use
etekcity sockets)

[https://home-assistant.io](https://home-assistant.io)

[https://github.com/nfarina/homebridge](https://github.com/nfarina/homebridge)

[https://energenie4u.co.uk/catalogue/product/ENER314](https://energenie4u.co.uk/catalogue/product/ENER314)

[https://energenie4u.co.uk/catalogue/product/ENER002-4](https://energenie4u.co.uk/catalogue/product/ENER002-4)

I wouldn't call it simple to set up, but it was cheap - about £70 (not
including Alexa device, which could even be the same pi -
[https://github.com/alexa/alexa-avs-sample-
app/wiki/Raspberry...](https://github.com/alexa/alexa-avs-sample-
app/wiki/Raspberry-Pi) )

~~~
SEJeff
I literally clicked into the comments here to mention how awesome Home
Assistant is at things exactly like this. Glad to see I am not the only happy
user / occasional contributor!

~~~
JshWright
Home Assistant has a staggeringly large base of contributors. I think that's
in part because there are a ton of individual use cases that spark a
contribution, but I think it also speaks to how well Paulus handles
contributions.

~~~
SEJeff
Couldn't agree more. Also, thanks for fixing the timing attack issues wrt HASS
:)

------
linker3000
There's some really useful stuff going on there - nice write-up.

Anyone getting into this field should take a look at Peter Scargill's Tech
Blog - he has published details and code for a home control system centered
around a Pi using MQTT with a range of modules (mostly ESP8266). The most
interesting recent stuff is on control, monitoring and dashboard design for
phone and Web apps - his work on the dials and gauges is very good.

Pete also takes a regular look at other non-Pi platforms from an IoT control
perspective.

[http://tech.scargill.net/](http://tech.scargill.net/)

------
deepsyx
Hello and thanks for the post! I'm the author of this repo. I would be happy
to answer any questions :) Also any feedback/ideas are greatly appreciated!

~~~
ohitsdom
Nice work! Did you consider building this on top of Home Assistant?

~~~
deepsy
Thank you! Actually I did. However I wanted to try out new technologies and
since I haven't used React Native, I decided to try it out. I really like
doing things from scratch, the whole networking and the bare bones. I could
probably buy cheaper ready solutions, but electronics/software are some of my
hobbies.

------
dnadler
Cool! I'm doing something similar, but more from the data-analysis side of
things for my condo's efficiency.

I've been trying to keep a blog of my progress, if anyone is interested,
though please forgive the poor grammar / stream-of-consciousness in the
posts... I've been writing quickly to get caught up.

[https://dan-nadler.github.io/](https://dan-nadler.github.io/)

~~~
deepsy
Looks interesting, bookmarked it for later reading :) I noticed that you have
sensor in all parts of the house from the images. I wonder how did you solve
the wiring issue? I mean I'm looking for a cheap way to connect all sensors,
but avoid putting wires everywhere.

~~~
dnadler
Yeah, that's a problem I'm still working on solving.

Initially, I had planned to wire through the basement, but getting through the
floor turned out to be a littler more difficult than I had hoped.

At the moment, the wires are run under carpet and behind furniture. I just
ordered another Pi (and am looking at cheaper boards) to set up another 'base
station' to reduce the amount of wires I need to get full coverage.

------
tete
Hope that doesn't sound bad, it's not meant to be, but am I the only one who
doesn't see a lot of "automation" there?

Looks more like monitoring and control, on which you could of course build
automation, but I personally am also not sure where to head on that one.

Nevertheless: Cool project! :)

------
Freestyler_3
Ok, Here is what I have been thinking of:

a PI, many sensors and controls. the pi to do the things the pi always does.
the sensors to sense room temp. in each room. And this is the hardest one,
flow control per radiator.

I want that I can set room temp schedules, and can go off schedule using the
app (manual intervention) When the current temp in any room is below the set
temp for that room the heater system turns on The rooms that are already above
their set temp have the radiators turned down.

Why? Because I don't like to waste heat to a room I don't enter 90% of the
day. And when my living room has reached the target temp there is always a
room that is either still stone cold or feels like sauna.

The hardest part about this is the controllable radiator valves, the rest
already exists.

~~~
bloaf
I have a lot of similar ideas. The one constant problem I keep running into is
the amount of work it would be to get power to all those devices. I'd
absolutely love if it were possible to power + network all the devices via
PoE, but those adapters are so expensive.

If anyone knows of a good Pi-like board that runs off PoE out of the box, let
me know.

~~~
Freestyler_3
Yeah you always need some cables if you don't want to change batteries all the
time, and wifi is convenient but its better to use wired.

I think there are 2 options,

1 you run everything on the network.

2 you use PI's io to directly control/sense.

The power either comes from pi, poe or a separate adapter (either at pi
running with other wires or near radiator)

------
geomark
Nice project. Mine isn't quite so ambitious (yet). I just need to monitor
water pumps. Does anyone have a suggestion for a water flow sensor? I need to
detect if there is water present at the pump input. So far the only thing I've
been able to get my hands on is a water flow meter [1]. But it's overkill
because I don't need to measure flow rate, only presence of water.

[1] [https://www.aliexpress.com/item/Black-G1-Inch-Water-Flow-
Hal...](https://www.aliexpress.com/item/Black-G1-Inch-Water-Flow-Hall-Effect-
Sensor-Switch-Flow-Meter-Counter-1-60L-min-Waterproof/32674346412.html)

~~~
Herodotus38
Could you use something to measure resistance? Like two wires, so when
immersed resistance drops?

~~~
geomark
I'm sure that would work, at least initially. I'm concerned about reliability.
My water has very high levels of calcium carbonate which quickly scales up
everything. I think the electrodes wouldn't last long. A nonintrusive solution
would be great. I've seen nonintrusive water flow sensors that use ultrasound
to detect the flow of water. They are industrial devices and their price makes
them unsuitable for my use.

~~~
JohnHenrySDM
There are cheaper optical water level sensors in the aquarium trade that might
work for you. Check out the Tunze Osmolator as an example. It could easily be
connected to a GPIO on the pi.

~~~
geomark
That's a very interesting idea. Thanks for the suggestion. It is still
invasive since I have to cut the intake pipe and insert a section with the
sensor installed in it. But it is more flexible since I can install it in any
size pipe. And for my use case of a 1 inch input pipe it can be cheaper than
my current solution. For example
[https://www.aliexpress.com/item/15mA-5V-Optical-Infrared-
Wat...](https://www.aliexpress.com/item/15mA-5V-Optical-Infrared-Water-Liquid-
Level-Sensor-Liquid-Water-Level-Control-Switch-Favorable-Level-
Sensors/32752456624.html)

Although, I wonder if scaling (as in hard water scale) is still going to be an
issue.

------
ryfm
Cool, working on a similar project, but having a different stack

1\. Z-wave switches/outlets/locks - all lamps, receptacles and locks
controlled by Vera Edge; 2\. DSC alarm system - door/flood sensors, integrated
with Vera; 3\. Nest cameras - not integrated; 4\. Nest thermostat - integrated
with Vera and Alexa;

Currently trying to integrate Vera and Alexa to have fully voice- controlled
home.

~~~
Klathmon
If you are somewhat of a "programmer" you can complete that integration using
a RPI and a software package called "Home Assistant".

They have links between Vera and the Echo along with a TON of other things.

~~~
ryfm
Yes, that's what I'm going to do.

------
deepsy
I just added a video!
[https://youtu.be/wh0OoLUTeM8](https://youtu.be/wh0OoLUTeM8)

------
wiradikusuma
anyone know good but cheap WiFi/Bluetooth-enabled adapter(?) for lightbulbs?
e.g. so I can use any machine (not just Pi) that supports WiFi/Bluetooth to
control (at least on/off) the bulb.

so: wall --> adapter --> lightbulb

~~~
luma
The Sonoff is a $5 WiFi relay with an embedded ESP8266 that is programmable
via Arduino (and several other dev platforms), allowing you to control the
relay via HTTP/REST/MQTT/etc.

[https://www.itead.cc/sonoff-wifi-wireless-
switch.html](https://www.itead.cc/sonoff-wifi-wireless-switch.html)

~~~
gm-conspiracy
What about something like that for dimmable lamps, bulbs (triac instead of
relay)?

------
z3t4
any ideas how to run cables ? im currently using radio but it can be noisy
with many units.

~~~
deepsy
This is one of my main issues as well! At this point the whole hardware is
located close to each other, so the cable management is fine, but I would like
to put sensors in other parts of my flat. One of my thoughts is to use UTP/FTP
cable, as it has 8 wires and it's pretty thin (and not that ugly).

------
nialv7
Why is everyone trying to write everything in JS nowadays...?

~~~
detaro
For the specific project, the question is answered in the readme.

~~~
j_s
Specifically:

 _Since I 'm pretty familiar with javascript and its ecosystem_

------
aarondf
FYI: This was submitted two other times in the past 19 hours, making this the
third.

[https://news.ycombinator.com/item?id=13491012](https://news.ycombinator.com/item?id=13491012)
[https://news.ycombinator.com/item?id=13485444](https://news.ycombinator.com/item?id=13485444)

~~~
dang
A small number of reposts are ok if an article hasn't had significant
attention yet:
[https://news.ycombinator.com/newsfaq.html](https://news.ycombinator.com/newsfaq.html).
This helps give good articles more than one chance at getting on the front
page. Otherwise it's too much of a lottery.

It's too bad that the author's Show HN wasn't the one that made it, but at
least the project is getting attention now.

------
brian_herman
RRRRR GGGGG BBBBBB this is awesome!

