Author Topic: New setup  (Read 1369 times)

Offline 9H1LO

  • Newbie
  • *
  • Posts: 1
  • Karma: +0/-0
New setup
« on: April 15, 2014, 05:29:45 pm »
Hi, been going lots of info on this forum and online and now i feel i need to ask some questions

Currently building a new house and am considering such a setup

Was looking at the fibaro controller but not really convinced, the vera looks more "open" (price also another factor)

Since the house will have new wiring i'm looking at wiring every single switch location and lamp location direct to a central "control" area so Z-wave is not essential but nice to have for misc sensors ect

My guestimate is I need about 50 input channels, 16 dimmable output channels and 32 relay channels. Doing all this with z-wave modules is going to cost a fortune so i'm looking at alternatives. possibly a raspberrypi doing all the relay i/o and handling http to the vera if i'm understanding correctly. for dimmers i am thinking of a solution based on 0-x'ing triacs driven maybe by an arduino getting its commands over i2c from the pi

The thing is this all needs software/hardware development, i am perfectly capable of putting it all together, thing is TIME! is there some "cheapish" (compared to the all zwave units i'd need) off-the-shelf devices available ? my biggest headache is serial controllable dimmers, don't fancy playing with code to detect zero crossing whilst waiting for serial data and on and on, just don't have the time to experiment ! maybe in the future once all building works have settled down !

the rest of the i/o is easy with rpi and some i2c drivers to get all the i/o and if things go titsup i can easily bypass everything since all wiring will be coming into 1 control location

Offline aPL

  • Developers
  • Jr. Member
  • *****
  • Posts: 74
  • Karma: +1/-2
Re: New setup
« Reply #1 on: April 16, 2014, 02:37:13 am »
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 https://www.youtube.com/watch?v=BmsdXMbd2vo - 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> <comparison type> <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
1. arduino boots up and it sends a broadcast udp to find servers
2. 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

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

6. sends boot finished update and enters normal running state

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

8. Server can send a get value request or a reconfigure pin request at any time

9. 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.
working @ Vera / MiOS | anything stated is my own opinion and does not reflect the thoughts and opinions of my employer