Hacker News new | past | comments | ask | show | jobs | submit login
Raspberry Pi 3 based home automation with Node.js and React Native (github.com/deepsyx)
349 points by sconxu on Jan 26, 2017 | hide | past | favorite | 90 comments



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...


> and nothing depends on some company's servers.

Exactly my motivation. I have an mqtt broker at a heart of everything. homekit2mqtt for homekit/siri integration, lirc2mqtt so my harmony remote can join in, node-red providing some automation logic, etc.

But where it gets interesting is being able to support devices that won't otherwise. Homekit support for Philips Hue means €50 for a new hub - or mqtt-hue so I can support it myself. Belkin Wemo doesn't support homekit, and has no plans to - but I've done it via node-red regardless.

DIY looks messy from the outside. But once the ball is rolling, anywhere a vendor won't support the features I require, I'll support them myself. The ability to do so makes it all worth it.


> DIY looks messy from the outside. But once the ball is rolling, anywhere a vendor won't support the features I require, I'll support them myself. The ability to do so makes it all worth it.

Pretty sure the messy part isn't about writing code, it's about maintaining it. What happens if one of the APIs you're talking to changes? What happens if you want to add a new device into your ecosystem? If there's a power outage and one of your hubs doesn't come back up, how much time/energy does it take to figure out which one and to bring it back up?

Not saying that it's not a worthwhile project, just that it takes a lot of effort. That said, I have my own growing list of bots that helps me automate repetitive tasks in my life that I maintain...


I roll my own home automation with a combination of things. Once it is up I don't know that it I'm any worse off than anyone else. The worst I had was the weather API I was using dried up. 20 minutes later I had weather from somewhere else. I like that if I end up with a pile of useless junk it is my fault, not the decision of company that decided to stop supporting their hardware and shut down their cloud servers [1]. I don't need the cloud and I don't need a 3rd part to have control of my garage door opener. I'm still waiting for the hack that opens a half million garage doors around the country! (I have no idea how many doors these big companies control, but it would make great news.)

This may be the biggest reason I go DIY on my automation - it gives me a chance to learn things that I wouldn't get into at work.

[1] https://www.theguardian.com/technology/2016/apr/05/revolv-de...


If an API changes, I can catch up with it in a quiet afternoon - instead of buying whatever hardware they tell me their next update requires.

Catching dark hardware is really easy - just allow each component to die if it can't reach the hardware, and then catch their 'last will' messages in mqtt (mqttwarn is great for this, I can get an email whenever a 'last will' is published). Also a problem the vendors won't solve for me ..


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


For the integration side you should take a look at http://home-assistant.io - they support a huge variety of hardware already, and almost every type of device includes a configurable MQTT adapter if you're building your own.

Once your hardware is integrated with Home Assistant it can handle automating things. The whole system is a big state machine so most automations will involve reacting to state changes and sending commands to other devices in response.


If it is only for irrigation of anything not grass, why not use off the grid system like blumats (http://blumat.com/en/)? You only need to provide it with a water source.


What did you dislike about your Rainbird system ?


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.


1. It didn't work reliably

2. The UI was awful and buggy

3. It finally broke outright and replacements with halfway modern features were pricey


Having a pi cluster "feels" more like a datacenter with many servers. Using kubernetes to coordinate it all is pretty fun when you actually have several "servers" to coordinate across. That to me was the satisfying part. Not that I NEEDED miniature scale, but that the miniature scale felt like a valid downsizing of real scale.


I've been tempted to do something like this, what are you doing about shared storage?


I have a nas on the network as well. That isn't set up quite like it would be in a real datacenter, but it works for centralizing data


>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 //

Can you just make the folder it copies to a link to a mounted remote filesystem, mount your server folder over SSH, for example.


Controlling the sprinkler with the Pi is a cool idea!

> The second is a security camera for a vacation rental home, and is not quite done yet.

What is the purpose of the camera?


I run a script that takes a picture with an old Kinnect and pushes to dropbox. It is a dirty solution but it worked...until I ran out of space...


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://github.com/nfarina/homebridge

https://energenie4u.co.uk/catalogue/product/ENER314

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... )


I'm pretty much doing the exact same.

Home Assistant

Custom TX board to transmit to the Etekcity sockets

https://www.amazon.com/Etekcity-Wireless-Electrical-Househol...

Using Alexa to control those outlets via Home Assistant Emulated Hue component. Then I have a couple groups defined in Home Assistant for my living room lights, so I can say "Alexa, turn off living room lights" and it'll turn off my three outlets. I can also do "Alexa, turn off living room light one" to just turn off a particular light. One thing that I've noticed with Alexa and Home Assistant is that I have an outlet labeled "Xmas Light" and I can either say "Alexa, turn on Xmas Light" or "Alexa, turn on Christmas tree light" and it seems to discern between the two.

Overall I love this combo and is working pretty dang good.

Next goal is to use PIR sensors so when I go to the basement it'll automatically turn on the basement lights.


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!


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.


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


Why not distribute the image as a one-off rPi bootable?


That exists as one (of many) installation options:

https://home-assistant.io/getting-started/installation-raspb...


https://youtu.be/wh0OoLUTeM8 Just added a video :)


You've now posted links to your video four times in this thread. Perhaps that's enough?


Sorry! I just made and it and I'm still hyped about it. I though the people I replied to would be interested.


Home Assistant is awesome. So much cleaner than OpenHAB. I just wish it supported Insteon PLM natively. For now, I'm making REST calls been OpenHAB and home Assistant to support this.


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/


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!


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


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.


What type of AC / Heating does your home have? Are those two knobs in the photo the central climate control?


Hello. I have a Panasonic AC, that I'm controlling via IR LED Diode (see schematics in repo), here is the actual picture of the AC: http://imgur.com/lXHxvWt. I'm also using similar heater: http://gazifikaciya-otoplenie.uslugi.catalog.bg/images/produ..., which I'm controlling via Servo (thermostat) and a central on/off relay. Going to add a video later tonight :)


In your pics I saw what looked like a servo turning your dial. Is that what you mean?

It's a great solution. Most houses in the US have central heating/cooling so the IR remote isn't an option. Although I have seen that style before.

What I want to do is integrate it directly with the system. Here's an example of a Honeywell connector similar to mine.

http://diyhousehelp.com/how-to/honeywell-4-and-5-wire-thermo...


https://youtu.be/wh0OoLUTeM8 Just added a video :)


Yes, that's what I meant. Unfortunately, I did not want to disassemble the unit as it would void the warranty.


I'm a bit confused here; looking at the video and pics of your water heater/boiler, the knob the servo is turning looks like it sets the temperature the boiler heats the water to for the central heating loop. This is generally not the thermostat, and once set to a value you are happy with shouldn't need to be adjusted.


Yes, it is not a thermostat, I have similar heater (also Vaillant) and it just sets the temperature of the water in the pipes (generally you set it higher when the outside temperature gets lower, and all the way up when it reaches the minimum at your location).


Is the relay for your heater controlling the main voltage input or is it controlling at the thermostat connection?

I've been wanting to do something similar with the units in my apartment (they're similar to what you'd see in a hotel window unit). The thermostat and controls are integrated and I can't disassemble to access them, so I either need to build a rig to push the buttons (hard) and turn the temperature dial or just put a relay at the mains and manually set them for AC\Heat depending on season. Adding a relay to the mains seems straightforward, but it's 220v and I don't want to mess up.


The relay is controlling the main voltage input and it's similar to http://i.ebayimg.com/00/s/NTAwWDUwMA==/z/ZS0AAOSwr81UNgc9/$_.... The relay's function is to act like a central switch. I have also a servo attached to the thermostat and it's only role is to spin the thermostat controller. The servo is similar to http://www.conrad.com/medias/global/ce/2000_2999/2000/2060/2...


You could also look at SSRs, which tend to be easily controllable with logic level outputs on a microcontroller.


Solid State Relays (SSR) do work great. Internally they use an LED to close the switch rather than the mechanical coil mechanism used in the classic click relays; these are totally silent.

I am using one to turn on/off the mains power of a 12VDC transformer. The nice thing about an SSR with an input range of 3–30V (a common type) is that you can drive it directly (and safely!) from a Raspberry Pi GPIO pin (3.3V).


Thanks! Will definitely look into them :)


Thanks!


How did you attach the servo? I have almost the same heater and was wondering if go with 7-8-9 or servo, but I haven't work with servos before, so do you have any pages that could help with those?


Wow, I'd never considered using a servo, but I might try it for automating the heating in my rented house where I can't change the thermostat itself, but could mount something above it to spin the dial.


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/


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.


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.


Nice little blog you have.

I'll be doing some similar. Couple things that I'll likely do different is push to InflexDB host in my homelab and using Pandas to help me analysis data.

Keep up the good work, it's inspiring.


Thanks! I'm using pandas as well, though haven't got too far into the quantitative analysis just yet.

I hadn't heard of InfluxDB before, looks interesting.


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! :)


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.


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.


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)


For radiator valves look into actuators like this, there are a few different manufacturers:

http://www.vesternet.com/smart-home/technologies/z-wave/heat...


Actually, this is on top on my to-do list. I've been thinking about it for some time. Currently I'm planning to do it via motor and a reductor with ~1:1000 rate. The other issue is to find a cheap way to connect all radiators without putting cables everywhere. I'm open for suggestions :)


Data can go over the air, the power either has to be battery or cable.

The other commenter has a link to a product that works on battery. (though that has the temp sensor inside the device, which I don't consider reliable, being so close to the heat source)

It would be an amazing project when redoing a house, as at that point I could just run a special circuit.

So yeah check out that link, for your convenience copied here: http://www.vesternet.com/smart-home/technologies/z-wave/heat...


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...


If you don't care about precision (and depending on what your pipes are made out of), you could make a DIY version of that sensor (that you could wrap around the pipe, rather than having to cut it to put it inline).

https://www.youtube.com/watch?v=TR0baWuB6v4


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


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.


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.


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...

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



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.


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.


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


I just added a video! https://youtu.be/wh0OoLUTeM8


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


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


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


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


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).


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


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


Specifically:

Since I'm pretty familiar with javascript and its ecosystem


[flagged]


What does that have to do with the link?


The phrase "IoT" when used by techies refers to things like the link. The phrase "IoT" in a business content refers to things like Amazon Dash; the purpose is not related to helping the user in ways other than monetisation.


Eh, IoT just means devices not typically considered (having) a computer are now computers (though they likely had embedded systems in them for ages now), and more importantly--they are connected to the internet.

That it's being used for monetization (fridge ordering more milk, dash buttons, etc.) is just a symptom.

And further: "The S in IoT stands for security" [1].

[1] - https://twitter.com/shelajev/status/796685986365325312


I understand that. The link doesn't present itself as being internet of things.

(It's even about leaving the internet out of connected devices)


Big corporations are not responsible enough to do IOT. We all know what would happen. Tracking, analytics and ads.


So a bunch of small and medium companies with zero accountability are pushing out Baby Cameras, DVRs, etc. by the thousands that are all drafted into the next botnet shortly after purchase by their blissfully unaware owners.


Do you have any examples?



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=13485444


A small number of reposts are ok if an article hasn't had significant attention yet: https://news.ycombinator.com/newsfaq.html. This helps give good submissions 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.


But these go to 11.


RRRRR GGGGG BBBBBB this is awesome!




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: