I would use a few arduino mega with serial or ethernet shields + mqtt library that talk to a raspberry pi. The pi can then interface with the vera or provide a simple ui.
I’ve done thinks a bit more complicated: arduino → 5v relay → mechanical relay → light and attached a normal button in paralel with the 5v relay. So the whole electronic system can go down and the lights still work. A simple demo here Arduino Ethernet UDP Controll a light in paralel with normal switches - YouTube - it’s missing the current sensor that reads state but that was added in series with the light. Another side-effect is that it keeps the light state if power goes down which might be a good thing, depending on what you
I’ve looked on ebay for things and bought in bulk when i found great deals: 8-9$ per arduino mega, 7$ per 5 pieces of motion sensors, 8$ per ethernet shield.
The servers are two raspberry pi running nodejs with data synchronized between them (will add 4 more in the future in different parts of the house for redundancy and load balancing), storing data in leveldb and in another server i have at home with raid mysql. Mysql is a last line of backup, all data stored there is sent asynchronous so it does not impact performance.
Each device-attached value is a stored variable that can be used in a simple rules engine. A rule has at least 1 comparions: <variable_name> <value or variable. Comparions can be all mathematical comparisons and history function (each value holds in ram as many previus values with timestamps as possible, having a global limit for all values. if the history function tries to get more values than there are in memory it gets the information from mysql wich is alot slower but still fast enough from a user’s perspective). This supports 512 conditions per rule. I am now working on distributing the rules processing evenly to the servers automatically to increase speed. Right now one pi can process around 9000 events / second while processing an absurd number of rule checks (on a variable change, it gets the list of rules that have that variable and compares only those, storing a few things in memory so it eats up 100 mb of ram with alot of rules but the speed is the most important facture). Generating 9000 value changes per second for 1024 values leaves enough room to process 2-3 thousand rules.
Servers have a mesh vpn with tincd and are on a different vlan.
How the system works
- arduino boots up and it sends a broadcast udp to find servers
- a server sends it’s ip and port for mqtt connection
if arduino is on first boot
3. ask for a unique id from server and store it in eeprom, generates a connection key and reconnects with the new id+key
if it’s nth boot
3. arduino connects and sends identification information
- arduino sends a setup request
if request is not fulfilled by server it
5. load last data from eeprom
otherwise
5. get a list of pins and library to use with those pins (like pin5 - simple relay, pin 6+7 - relay + current sensor, 20 - temperature sensor, 32 - motion sensor)
-
sends boot finished update and enters normal running state
-
Server sends a list of watch commands, each contains
- pin to watch
- priority
- minimum delay between checks
- minimum delay between data send to browser
- minimum value difference since last check that triggers sending value back to server
-
Server can send a get value request or a reconfigure pin request at any time
-
Arduino monitors pins and when a watched pin changes value and it matches the rules sent by server it sends a short data packet over mqtt to the server
I’m trying to clean up code and post parts of it here for arduino integration but it’s going slow because of other priorities (but hopefully i will have something that i can put on github in a few months).
If you go with arduino relay and current sensor you will need more arduino’s because a current sensor needs to be polled for longer periods of time than a simple digital/analog read.
I hope i gave you a few ideas and goold luck with your automation.