Chef de Cambuse

...cooking, cruising and wine

Archive for April 2006

EIB time-signals

written by Frank, on Apr 27, 2006 1:27:00 PM.

Quite some EIB devices have time-controlled actions nowadays, for example the GIRA Tastsensor 2plus. But apparently their internal clock has its own interpretation of time and seems to lose any contact with reality shortly.

One way to get around this is to use an EIB time emitter, something with a buildin DCF77 receiver, cyclically sending a time telegram on the bus.

On the other hand, with our eibcontrol homeserver and a simple NTP setup, we can achieve the same with just a few lines of code.

We need to add a dummy group address to the homeserver’s xml-database, something like this:

<node name="0" alias="central functions">
    <node name="0">
        <node name="40" alias="timer">
            <node name="valuelength">3</node>
            <node name="eistype">3</node>
            <node name="curvalue">0</node>
        </node>
    </node>
</node>

Now armed with some knowledge about the time encoding in an EIS 3 type (p.15) writing a little (Python) script that, when invoked, sends the current time to the above defined group address isn’t a big deal anymore.

#!/usr/bin/python
#
# _example_(!) python program for eibcontrol communication
# (c) 2006 Frank Scholz, dev * netzflocken . de
#
# eib_sendtime.py -a 0/0/40 
#

import socket,string,time,struct

HomeServer        =       '127.0.0.1'
HomeServerPort    =       8081 
EIBaddress        =       (0,0,40)

write_request = """<eib type="write" path="/eib/groups/%d/%d/%d/curvalue" data="%ld"/>\n"""

def eib_set( server, port, address, value):
    result=""
    state="false"
    s=socket.socket( socket.AF_INET, socket.SOCK_STREAM)
    s.connect( (server, port))
    request = write_request % ( address[0], address[1], address[2], value)
    s.send( request)
    result = s.recv( 1024)
    s.close()

    if( string.find( result, "state=\"true\"") != -1):
        state="true"
        result=result[ string.find( result, "data=\"")+6:]
        state=result[ 0 : string.find( result, "\"")]

    return( state)

def eis3_build( day, hour, minute, second):
    r = day<<21|hour<<16|minute<<8|second
    return struct.unpack("L", struct.pack("!L", r))[0]>>8


t = time.localtime(time.time())
value = eis3_build( t[6]+1, t[3], t[4], t[5])
eib_set( HomeServer, HomeServerPort, EIBaddress, value)

Download: a slightly longer version with parameter handling

Now put this in a crontab and you are all set.

Currently the eibcontrol homeserver whinges about not receiving an ack from the bus for his “write”-request. As there is no “send-only”-request we need to simulate this for now and live with the otherwise effectless nagging.

How to eat sushi in Japan...

written by Frank, on Apr 5, 2006 10:48:00 PM.

In our little sushi sequence we learn today - with the help of a very illustrative video - the proper way to eat sushi in Japan.

Enjoy, and may you always have ohtoro on your fresh sterilized geta.