Pi zero w + enOcean to control Eltako home control

I have a basic system in place to control light in the house by means of Eltako relays. I wanted to control these lights from the phone.

In my specific situation, it seemed easiest add a wireless module to the Eltako system and then use a simple webserver on a raspberry pi. The pi on the one hand runs a webserver to communicate with the smartphone; on the other hand it communicates with the Eltako system.

Step 1: basic communication between pi and FSR14-4

Components:

  • Raspberry pi Zero w
  • Enocean USB dongle “USB 300 Gateway”
  • Python library for EnOcean. There are many options, I found this one really simple and convenient: https://github.com/cgarnier/domolife (actually only the Python folder is necessary)

I verified the correct functioning with the code below. The Raspberry Pi will act as an input button to my Eltako FSR14-4 relay board. So, the FSR14-4 needs to be put in learning mode and then the code below is executed. If things go well, the blinking LED on the Eltako module goes out after running it.

from sys import argv
from enOcean.Modules.Rcm250 import Rcm250
import serial

ser = serial.Serial('/dev/ttyUSB0', 57600, timeout=1)
rcm = Rcm250(ser)
rcm.setId([0xFF, 0xFF, 0xff, 0xff])
# so, we have to put FSR14-4 in lrn and then switchOn with the right senderID

#senderId = [0xFF, 0xB9, 0xE1, 0x01]
rcm.setSenderId(senderId)
rcm.switchOn()

print('done')

Step 2: A flask webserver

I am using Flask to glue the run a simple website with a few buttons to switch on/off the lights and to communicate with the Eltako stuff.

from flask import Flask, escape, request
from enOcean.Modules.Rcm250 import Rcm250
import serial

app = Flask(__name__,static_url_path='')
ser = serial.Serial('/dev/ttyUSB0', 57600, timeout=1)

rcm = Rcm250(ser)
rcm.setId([0xFF, 0xFF, 0xff, 0xff])

devices = [[0xFF,0xB9,0xE1,0x08],[0xFF,0xB9,0xE1,0x1A],[0xFF,0xB9,0xE1,0x1C],[0xFF,0xB9,0xE1,0x1E],[0xFF,0xB9,0xE1,0x20],[0xFF,0xB9,0xE1,0x22]]

@app.route('/on/<int:deviceid>')
def switchon(deviceid):
        print('Switching on: Device %d' % deviceid)
        senderId = devices[deviceid]
        rcm.setSenderId(senderId)
        rcm.switchOn()
        return 'Device %d' % deviceid

@app.route('/off/<int:deviceid>')
def switchoff(deviceid):
        print('Switching off: Device %d' % deviceid)
        senderId = devices[deviceid]
        rcm.setSenderId(senderId)
        rcm.switchOff()
        return 'Switching off: Device %d' % deviceid

In the static folder of the Flask server goes the following html page

<html>
  <head>
    <title>Sonos Controller</title>

    <script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>

    <!-- Latest compiled and minified CSS -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" integrity="sha512-dTfge/zgoMYpP7QbHy4gWMEGsbsdZeCXz7irItjcC3sPUFtf0kuFbDz/ixG7ArTxmDjLXDmezHubeNikyKGVyQ==" crossorigin="anonymous">

    <!-- Optional theme -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css" integrity="sha384-aUGj/X2zp5rLCbBxumKTCw2Z50WgIr1vs/PFN4praOTvYXWlVyh2UtNUU0KAUhAX" crossorigin="anonymous">

    <!-- Latest compiled and minified JavaScript -->
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js" integrity="sha512-K1qjQ+NcF2TYO/eI3M6v8EiNYZfA95pQumfvcVrTHtwQVDG+aHRqLi/ETn2uB+1JqwYqVG3LIvdm9lj6imS/pQ==" crossorigin="anonymous"></script>

    <script type="text/javascript">

$(document).on('click', '#Onbuttons', function (e)
{
   stationid = e.target.id;
  jQuery.get( "http://10.0.1.5:5000/on/" + stationid, function( response ) 
  {
    ;
    }
  );
})

$(document).on('click', '#Offbuttons', function (e)                                
{                                                                                   
   stationid = e.target.id;                                                        
   jQuery.get( "http://10.0.1.5:5000/off/" + stationid, function( response )         
  {                                                                                      ;                                                                              
    }                                                                                
  );                                                                                 
})                                                                                   
   
</script>

</head>
<body>
<center>
<h1>hello</h1>

<div class="btn-group-vertical btn-group-lg" role="group" aria-label="..." id="Onbuttons">
 <button id=0 type="button" class="btn btn-default">keuken aanrecht aan</button>
 <button id=1 type="button" class="btn btn-default">keuken tafel aan</button>
 <button id=2 type="button" class="btn btn-default">keuken led aan</button>
 <button id=3 type="button" class="btn btn-default">living tv aan</button> 
 <button id=4 type="button" class="btn btn-default">living vooraan aan</button> 
 <button id=5 type="button" class="btn btn-default">gang beneden aan</button> 
</div>

<div class="btn-group-vertical btn-group-lg" role="group" aria-label="..." id="Offbuttons">                                                                               
 <button id=0 type="button" class="btn btn-default">keuken aanrecht uit</button>      
 <button id=1 type="button" class="btn btn-default">keuken tafel uit</button>      
 <button id=2 type="button" class="btn btn-default">keuken led uit</button>      
 <button id=3 type="button" class="btn btn-default">living tv uit</button>      
 <button id=4 type="button" class="btn btn-default">living vooraan uit</button>      
 <button id=5 type="button" class="btn btn-default">gang beneden uit</button>      
</div>  

<br>
<br>
</center>
</body>
</html>

Vestiaire / shoe closet

So for many years our entrance hall has been stuffed with zillions of shoes and coats. In the end, we got so tired of it that we decided to sacrifice a small part of our living room to solve the lack of storage space in the entrance hall.

The above picture is taken from the living room (the staircase is in the entrance hall). It shows some clear beginner mistake as the wooden support should have been turned 90 degrees. After opening the wall, a single brick was put at the left. At the right there was already a 30cm wide wall.

Picture taken from within the entrance hall. The back of the small vestiaire is made out of Gyproc.

Here the vestiaire already has a pair of doors. These are actually the Ikea Pax Tanem doors (229 cm version) that were cut a bit at the bottom to fit.