Today I managed, after some research, to write some Lua code to control Z-wave devices from the KNX bus. The way I did it is a little overkill but here it is:
I am using a GenOHM KNX Logic Machine ( http://genohm.eu/index.php?option=com_content&view=article&id=59&Itemid=50 ) to capture events on the KNX bus (the machine has its own TPUART - the physical layer for KNX). I then issue a Luup HTTP request to ask my Vera1 to update the corresponding Z-wave device.
As a 5-minute hack, it’s one-way only (no status feedback to the KNX bus) but I don’t think it’s gonna be very difficult to subscribe to the device’s events in order to do so.
So, here is what I am asking: how difficult is it to compile eibd (http://www.auto.tuwien.ac.at/~mkoegler/index.php/eibd) , the open source KNX/EIB daemon, for Vera? the Logic Machine is a PPC platform and its static binary is about 230k in size, so it shouldn’t be too hard. If eibd was running natively on Vera, one could bind KNX addresses to Luup devices in order e.g. to operate Z-wave from KNX and vice versa.
EIBD works either locally (connecting to KNX via serial/USB) or remotely (via IP uni-&multicast). Since Vera already has got a second USB port, it could interface to KNX with a USB adapter like eibmarkt.com - one of the leading technology shops in Europe
Z-wave and KNX could very well complement each other, and I see a gazillion of uses in existing KNX installations, so how about it?
These packages are for another openwrt release & hardware platform, ipkg complains about bad magic etc.etc.
[tt]root@HomeControl:~# ipkg install eibd_0.0.4-2010-07-21_brcm47xx.ipk
ipkg: invalid tar magic[/tt]
So, I downloaded OpenWRT SDK for Kamikaze 7.09 (as my Vera is old version=1), downloaded bcusdk and tried to cross-compile as per:
aaaaargh I’m getting old and after many wonderous hours, I get:
[tt]root@HomeControl:/tmp# ./eibd --help
Bus error
[/tt]
aaargh, no debug tools available on a machine with so little resources, can’t do much…
Will try again tomorrow.
ok folks, I’m fed up with arcane openWRT gcc errors like:
[tt]configure.ac:83: error: m4_copy: won’t overwrite defined macro: _AC_ARG_VAR_PRECIOUS
acinclude.m4:48: GLIBCXX_CONFIGURE is expanded from…
and
/usr/include/bits/fcntl2.h:51: error: call to ‘__open_missing_mode’ declared with attribute error: open with O_CREAT in second argument needs 3 arguments
make[5]: *** [collect2.o] Error 1
[/tt]
OK, I’m in a better state of zen now: Using the precompiled SDK for Kamikaze bcrm2.4 and the excellent sb2 (ScratchBox2) toolset for cross compilation I have a semi-working eibd version 0.0.5 (–help prints out command line arguments, anything else causes bus error bwhahaha).
Two questions for the elite squad:
Virtual Machine: It would be better if a VM (qemu? VBox?) was available for download so I had the build environment ready. How do you people normally compile new stuff for Vera? cross-compilation is like trickery, never works 100% as expected…
Binary size. stripped down version of eibd I compiled is about 700k (!) which is way too much for such a small machine. Do you optimize compilation for shared libs, or static binaries ?
SUCCESS! I have a working eibd for Vera. Now the real fun begins
I compiled it only for eibnet/ip (tunnel or routing mode) since OpenWRT has incomplete USB stack (maybe some special stack for Asus WL-500G??), but with some of YOUR help I could get it running locally as well.
try Zennio stuff it’s cheaper and quite high value for price ratio. And if I get eibd compiled with USB support, you won’t need an KNX/IP gateway (expensive stuff). You could start off with
OK! now I am in the process of interfacing Luup native code to eibd (the KNX/EIB daemon), by adding a Lua native interface to eibd’s UNIX socket.
Could someone from MCV tell me if it’s feasible to add a native KNX TP1 interface to Vera? there are already some very good attempts for a cheap KNX hardware interface out there…
Sorry to hear that the vera is a no-go.
I was leaning towards eibd, then saw the vera, and then I saw your post, and really hoped I could be spared the trouble
The board does not allow me to send a pm, maybe because I am a newbie, but I sure would like to hear from you.
If you could add me in gtalk (or email)(sdritsas.at.drinet.gr) or skype (sdritsas) I would be grateful.
I too am interested in controlling the knx with vera, Ekarak, you would have a detailed précédure?
I have an IP gateway and USB, and eibd / linknx installed on a Pogoplug. I know that you can send commands by opening a TCP socket with XML commands. The return status is in the xml file linknx.
I did it using the KNX Logic Machine [url=http://lm.openrb.com/]http://lm.openrb.com/[/url], which has a KNX TP1 adapter and a nice web front end with the Lua scripting engine. the Lua script library in the Logic Machine was:
-- load needed modules
--require("XmlParser")
local http = require("socket.http")
local ltn12 = require("ltn12")
-- a simplified http.get function
function http.get(u)
local t = {}
r,c,h = http.request{
url = u,
sink = ltn12.sink.table(t)
}
return table.concat(t), h, c
--return table.concat(t), respt.headers, respt.code
--return table.concat(t)
end
function zwave_binary_switch(event)
device_addr = event.dst:match("2/2/(%d+)")
device_state = tonumber(event.datahex)
url = string.format("http://192.168.0.1:3480/data_request?id=lu_action&output_format=xml&DeviceNum=%s&serviceId=urn:upnp
-org:serviceId:SwitchPower1&action=SetTarget&newTargetValue=%s", device_addr, device_state)
t,h,c = http.get(url)
end
function zwave_dimmer(event)
device_addr = event.dst:match("2/2/(%d+)")
device_state = tonumber("0x"..event.datahex)
if ((device_state > 0) and (device_state < 100)) then
url = string.format("http://192.168.0.1:3480/data_request?id=lu_action&output_format=xml&DeviceNum=%s&serviceId=urn:up
np-org:serviceId:Dimming1&action=SetLoadLevelTarget&newTargetValue=%s", device_addr, device_state)
t,h,c = http.get(url)
alert(url)
end
end
thus I bound a KNX group address range, say 2/2/x to call these routines and control zwave devices from KNX. So a on/off telegram for 2/2/13 would send a control command to zwave device #13 via vera via http.
I have compiled eibd for vera, with mediocre results (random segfaults).
I finally started writing my own daemon because Vera is too small to handle many different workloads at once and is very difficult to develop. there are already debian-based SBC (single board computers).
Plug computers are a good option, but they lack hardware extensibility.
Will keep you informed of the results.
Have you used PulseControl? I’ve tried to contact them many times in the past, but noone replied. I’ve also tried locating European resellers for their product, but I found none.
Even their website returns me a server error whenever I try to find out more about the product:
[url=http://www.pulseliving.com/en/product/products/pulsecontrol/pulsecontrol-pro.html]http://www.pulseliving.com/en/product/products/pulsecontrol/pulsecontrol-pro.html[/url]
Hi ekarak.
I am from Heraklion-Crete. I am olso trying to work with a Logicmachine. I am trying to interface it with my alarm panel which is connected to ethernet via a serial/TCP-IP server module. The problem is that i have no knowledge of scripting. From what i understand it needs a script to open a two way connection with the serial server and then filter incoming communication for meaningful status messages from the alarm and associating them to knx adresses so that i can incorporate them in the visualization engine. On the other hand it should have knx adresses issuing commands back to the alrm panel (arm-disarm etc).
Could you help me ?
Alex
[quote=“azafeiros, post:18, topic:168368”]Hi ekarak.
I am from Heraklion-Crete. I am olso trying to work with a Logicmachine. I am trying to interface it with my alarm panel which is connected to ethernet via a serial/TCP-IP server module. The problem is that i have no knowledge of scripting. From what i understand it needs a script to open a two way connection with the serial server and then filter incoming communication for meaningful status messages from the alarm and associating them to knx adresses so that i can incorporate them in the visualization engine. On the other hand it should have knx adresses issuing commands back to the alrm panel (arm-disarm etc).
Could you help me ?
Alex[/quote]
You might be better off with a special purpose KNX-to-RS232 adapters like the ones from Zennio or Intesis. Writing a protocol driver can be very hard, especially if you have to learn a programming language as well. Lua in my opinion is what BASIC was in the 80’s: NOT a good starting point. It’ll get you going, but when you hit a wall, Lua can drive you nuts!
Thanks for the reply. These rs232-knx adapters (servers) are a good option but they cost a lot (ARCUS 500Euro). I can not pay that kind of money. Thats why i setlled for a rs232-ip server (35Euro).