openLuup - running unmodified plugins on any machine

[quote=“akbooer, post:80, topic:187412”]Very excited… have just got openLuup (a fairly complete implementation of the Vera environment) up and running on an Arduino Yun.

The Arduino Yun is a microcontroller board based on the ATmega32u4 and the Atheros AR9331. The Atheros processor (400 MHz) supports a Linux distribution based on OpenWrt (so very much like a VeraLite) and that’s what runs openLuup.

The board has built-in Ethernet and WiFi support, a USB-A port, micro-SD card slot, 20 digital input/output pins , … so should be a fabulous platform for the Arduino Bridge plugin. I am close to completing an adequate implementation of the luup.io module, so from there the Arduino Bridge should be plug’n play (not to be confused with UPnP!)

Start up time is very fast:

[ul][li]less than half a second before it starts running the user startup Lua,[/li]
[li]another second to load ALTUI, VeraBridge, and a complete DataYours installation,[/li]
[li]about six more seconds for each remote VeraBridge connection with about 50 devices on each.[/li][/ul]

ALTUI is very responsive (but then, it runs mostly on the browser.)

Happy days.[/quote]

great work… will the arduino plugin require another arduino or will the RPI still be the only thing you need?

My hope would be that the Yun would replace both the Vera and the gateway Arduino, so what you’d need is a radio connected to the Yun and then some remote sensors communicating with that… at least, I THINK that’s the way it should work. I haven’t built any MySensor devices yet so couldn’t be sure! You could probably attach some sensors directly to the Yun board too, but that seems less useful, and would probably require some customisation.

There is some old thread on the MySensors board discussing running the gateway software on that, but nothing recent, so I’m hoping to stir things up there a bit and see whether anyone has done anything more. I’d rather not have to delve into the Arduino sketch. If you have expertise along those lines, we could perhaps continue the discussion in that forum.


Edit: Just re-read your comment again (!) and note that you mention RPi. With openLuup running on the Linux cpu on the Yun board, you wouldn’t need an RPi at all.

My hope would be that the Yun would replace both the Vera and the gateway Arduino, so what you’d need is a radio connected to the Yun and then some remote sensors communicating with that… at least, I THINK that’s the way it should work. I haven’t built any MySensor devices yet so couldn’t be sure! You could probably attach some sensors directly to the Yun board too, but that seems less useful, and would probably require some customisation.

There is some old thread on the MySensors board discussing running the gateway software on that, but nothing recent, so I’m hoping to stir things up there a bit and see whether anyone has done anything more. I’d rather not have to delve into the Arduino sketch. If you have expertise along those lines, we could perhaps continue the discussion in that forum.


Edit: Just re-read your comment again (!) and note that you mention RPi. With openLuup running on the Linux cpu on the Yun board, you wouldn’t need an RPi at all.[/quote]

I already have a gateway and several sensors built and deployed (working great)
i guess what i was trying to ask was as far as running openluup. would that still run on the rpi or does it now run on an arduino?

my thinking (correct me if i’m wrong) sensor - > gateway → → vera
where is a rpi2 (or maybe a yun if I’m understanding correctly)
correct?

Can be almost anything… RPi, Mac, even a Windows machine… Anything that runs Lua. Given that openLuup plus ALTUI does (will do, in due course) almost everything that Vera does (except Zwave) then you might not need Vera at all.

@akbooer - can you please help me find a Lau sockets binary for Mac OS 10.10 ? I have googled but can only seem to find source (I don’t have Xcode installed so can’t compile). Thanks!

I’m actually using the excellent ZeroBrane Studio as an IDE, and that comes with all sorts of flavours of Lua, including the LuaSocket library. However, just trying it, I notice that it doesn’t out-of-the-box provide the command line hooks for running Lua. On the Mac, I’m only running Lua within the IDE.

How have you installed Lua in the first place? My first port of call would be the pre-compiled libraries at sourceforge, but I don’t know if that includes LuaSocket.

I’ve installed quite successfully on Debian (BeagleBone Black) and OpenWRT (Arduino Yun) using [tt]apt-get install lua-socket[/tt] and [tt]opkg install luasocket[/tt], respectively, but that’s apparently not applicable to the Mac.

The Lua distribution here seems to contain lots of things, include the socket library:

[url=http://luadist.org/]http://luadist.org/[/url]

[quote=“akbooer, post:87, topic:187412”]The Lua distribution here seems to contain lots of things, include the socket library:

http://luadist.org/[/quote]

Thanks. From the luadist binary disc image at https://github.com/LuaDist/Binaries/archive/LuaDist-batteries-0.9.8-Darwin-x86_64.zip i installed:

  • everything in /bin into /usr/local/bin/lua5.1/
  • everything in /lib into /usr/local/lib/lua/5.1/socket.lua
  • everything /share into /usr/local/share/lua/5.1/

my package path variables are:

[code]sh-3.2# lua5.1
Lua 5.1.5 Copyright (C) 1994-2012 Lua.org, PUC-Rio

print(package.path…‘\n’…package.cpath)
./?.lua;/usr/local/share/lua/5.1/?.lua;/usr/local/share/lua/5.1/?/init.lua;/usr/local/lib/lua/5.1/?.lua;/usr/local/lib/lua/5.1/?/init.lua
./?.so;/usr/local/lib/lua/5.1/?.so;/usr/local/lib/lua/5.1/loadall.so;./lib?51.so;/usr/local/lib/lua/5.1/lib?51.so;
[/code]

But when i run

lua5.1 openLuup_release.lua /dev/null from /etc/cmh-ludl 

i get the error:

lua5.1: error loading module 'socket.core' from file '/usr/local/lib/lua/5.1/socket/core.so': dlopen(/usr/local/lib/lua/5.1/socket/core.so, 2): Library not loaded: @executable_path/../lib/liblua.dylib Referenced from: /usr/local/lib/lua/5.1/socket/core.so Reason: image not found stack traceback: [C]: ? [C]: in function 'require' /usr/local/lib/lua/5.1/socket.lua:13: in main chunk [C]: in function 'require' ./openLuup/logs.lua:6: in main chunk [C]: in function 'require' ./openLuup/init.lua:19: in main chunk [C]: in function 'require' openLuup_release.lua:6: in main chunk [C]: ?

I have been at it for hours and i am stumped. I hate to bother you but can you offer any help? I suspect i have not installed things in the right place or set the necessary variables (which i do not know how to do) but i can’t figure it out. Thanks again for your help.

-mda

How did you install the original Lua5.1?
What directory are you running in?

It looks from the error that it is looking on a relative path to the current directory?

@mda

Wow! I simply cannot believe how difficult it is to install Lua with LuaSocket on a Mac !

This may not be the best way BUT here goes:

  1. Install Homebrew, following the instruction here: [url=http://brew.sh/]http://brew.sh/[/url] BUT note that you need to be running bash:

% bash bash-3.2$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

then proceed as prompted.

  1. Follow these instructions to use Homebrew to install Lua: [url=https://github.com/keplerproject/luarocks/wiki/Installation-instructions-for-Mac-OS-X]https://github.com/keplerproject/luarocks/wiki/Installation-instructions-for-Mac-OS-X[/url]

[code]bash-3.2$ brew update
Already up-to-date.
bash-3.2$ brew install lua
==> Downloading https://homebrew.bintray.com/bottles/lua-5.2.4_1.yosemite.bottle.tar.gz
######################################################################## 100.0%
==> Pouring lua-5.2.4_1.yosemite.bottle.tar.gz
==> Caveats
Please be aware due to the way Luarocks is designed any binaries installed
via Luarocks-5.2 AND 5.1 will overwrite each other in /usr/local/bin.

This is, for now, unavoidable. If this is troublesome for you, you can build
rocks with the --tree= command to a special, non-conflicting location and
then add that to your $PATH.
[/code]

  1. Then follow these instructions to use LuaRocks(which comes with the above Lua install) to install LuaSocket: [url=https://github.com/keplerproject/luarocks/wiki/Using-LuaRocks]https://github.com/keplerproject/luarocks/wiki/Using-LuaRocks[/url]
bash-3.2$ luarocks install luasocket
Installing https://luarocks.org/luasocket-3.0rc1-2.src.rock...
Using https://luarocks.org/luasocket-3.0rc1-2.src.rock... switching to 'build' mode
...
Updating manifest for /usr/local/lib/luarocks/rocks-5.2
No existing manifest. Attempting to rebuild...
luasocket 3.0rc1-2 is now built and installed in /usr/local (license: MIT)
  1. Now, with luck, you have a Lua install with the socket library too:
bash-3.2$ lua
Lua 5.2.4  Copyright (C) 1994-2015 Lua.org, PUC-Rio
> local socket = require "socket"
>
  1. Breathe a sigh of relief.

I know I must be doing something wrong, but that’s what I found so far.

Hope this helps.

Well, I got it wrong. This, by default, appears to install Lua5.2, and you need 5.1 for Vera Luup compatibility (and, in fact, openLuup uses 5.1 features to manage environments.) Need to read the docs further!

OK, so the fix appears to be:

bash-3.2$ brew install lua51

and then

bash-3.2$ luarocks-5.1 install luasocket

and to check:

bash-3.2$ lua5.1
Lua 5.1.5  Copyright (C) 1994-2012 Lua.org, PUC-Rio
> x = require "socket"
> 

Phew.

So to run openLuup, simply:

bash-3.2$ lua5.1 openLuup_release_2.lua 

Hope THIS works for you.


Edit: However, all this mucking about screwed up my ZeroBrane Studio install, so I was left with a non-functioning IDE :frowning:
… but now fixed, so all is well.

Here is Release 3 of openLuup.

This is the version which should be able to run the MySensors Arduino gateway (ethernet only, not serial, sorry.) I have not been able to test it fully since I do not have any Arduino sensors constructed (yet.) However, I have it linked to an Arduino Uno with an Ethernet shield running the latest 1.5 gateway sketch. When the openLuup Arduino plugin starts it receives the “Gateway startup complete” log message as the openLuup log extract below shows:

2015-08-15 15:17:58.404   luup_log:6: Arduino plugin: loading library L_Arduino ...
2015-08-15 15:17:58.407   luup_log:6: Arduino plugin: library L_Arduino loaded
2015-08-15 15:17:58.407   luup_log:6: Arduino: urn:upnp-arduino-cc:serviceId:arduino1,PluginVersion, 1.4, 6
2015-08-15 15:17:58.407   luup.variable_set:6: 6.urn:upnp-arduino-cc:serviceId:arduino1.PluginVersion was: EMPTY now: 1.4 #hooks:0
2015-08-15 15:17:58.407   luup_log:6: Arduino: Using network connection: IP address is 172.16.42.21:5003
2015-08-15 15:17:58.407   luup.io.open:6: connecting to 172.16.42.21:5003
2015-08-15 15:17:58.407   openLuup.io:6: connect OK
2015-08-15 15:17:58.407   luup_log:6: Arduino: urn:upnp-arduino-cc:serviceId:arduino1,Unit, M, 6
2015-08-15 15:17:58.407   luup.variable_set:6: 6.urn:upnp-arduino-cc:serviceId:arduino1.Unit was: EMPTY now: M #hooks:0
2015-08-15 15:17:58.407   luup_log:6: Arduino: Sending: 0;0;3;0;2;Get Version
2015-08-15 15:17:58.407   luup.io.write:6: bytes sent: 21, status: OK
2015-08-15 15:17:58.407   openLuup.scheduler:6: device startup completed: status=nil, msg=nil, name=nil
2015-08-15 15:17:58.409   luup.io.incoming:6: bytes received: 36, status: OK
2015-08-15 15:17:58.409   luup_log:6: Arduino: Log: Gateway startup complete.

It’s also able to send start/stop commands for inclusion.

The major change in this release has been the addition of an asynchronous I/O module to support the luup.io calls (open / write / etc.) and the device code in the tag. The scheduler has been changed to accommodate this and the server restructured to run as a number of standard Luup jobs using the new I/O structure. It works beautifully with ALTUI and also writes a special log file so that variable and scene history can be displayed there.

I have tested it extensively under Debian (on BeagleBone Black), OpenWRT (on Arduino Yun), and Mac OS.

I’d be really keen to hear feedback on anything, but particularly whether this works with a fully functioning set of Arduino MySensors. Also, anyone willing to try on Windows?


Edit: This release has been superseded. Please see link on post #1 of this thread for latest

I think i am close, but socket is not building. when i test it i get:

[code]bash-3.2$ lua5.1
Lua 5.1.5 Copyright (C) 1994-2012 Lua.org, PUC-Rio

x = require “socket”
stdin:1: module ‘socket’ not found:
no field package.preload[‘socket’]
no file ‘./socket.lua’
no file ‘/usr/local/share/lua/5.1/socket.lua’
no file ‘/usr/local/share/lua/5.1/socket/init.lua’
no file ‘/usr/local/lib/lua/5.1/socket.lua’
no file ‘/usr/local/lib/lua/5.1/socket/init.lua’
no file ‘./socket.so’
no file ‘/usr/local/lib/lua/5.1/socket.so’
no file ‘/usr/local/lib/lua/5.1/loadall.so’
stack traceback:
[C]: in function ‘require’
stdin:1: in main chunk
[C]: ?[/code]

The output from ‘luarocks-5.1 install luasocket’ is attached as a text file (I can not find anything on the ‘dyld: Symbol not found: _NETSCAPE_X509_it
error’ with google)

is it possible i am trying to install a version of luasocket for lua 5.2 rather than 5.1 somehow? (this is just a wild guess, i of course have no idea what i am talking about :wink: )

i really appreciate your help… i think i am sooo close. Thanks!

i tried the instructions here Re: [Luarocks-developers] Install LuaSocket for Lua 5.1 on OSX | LuaRocks but got the same error at the ‘make bootstrap’ step

[code]dyld: Symbol not found: _NETSCAPE_X509_it
Referenced from: /usr/local/bin/openssl
Expected in: /usr/lib/libcrypto.0.9.8.dylib
in /usr/local/bin/openssl

Error: Failed producing checksum: Failed to compute MD5 hash for file /usr/local/lib/luarocks/rocks-5.1/luarocks/2.2.0-1/bin/luarocks
make: *** [bootstrap] Error 1[/code]

i do have the libcrypto file

bash-3.2$ ls -lsa /usr/lib/libcrypto.0.9.8.dylib 2536 -rwxr-xr-x 1 root wheel 2637984 Mar 19 19:16 /usr/lib/libcrypto.0.9.8.dylib

so i am stumped :frowning:

Have you simply tried the install(s) again ?

Yes, several times. Do you happen to have the sockets binary(ies) you could share so i can install them without compiling ? That would be a life saver! (And where do I put them?) thanks again

Don’t know if these are any good.
Found them, and the contained sub-directory in /usr/local/lib/

Got it running on a pogoplug v4 with mysensors with about 20 nodes, two vera’s ,one edge and one lite and it works great and fast thanks akbooer :slight_smile:

[quote=“akbooer, post:98, topic:187412”]Don’t know if these are any good.
Found them, and the contained sub-directory in /usr/local/lib/[/quote]

worked! Thanks!!! now on to configuring and testing openluup :wink: