Author Topic: openLuup - running unmodified plugins on any machine  (Read 100144 times)

Offline d55m14

  • Sr. Member
  • ****
  • Posts: 449
  • Karma: +8/-1
Re: openLuup - running unmodified plugins on any machine
« Reply #30 on: July 10, 2015, 12:15:09 pm »
Hi akbooer,

I'm using Datayours on Rpi. Do I have to follow any particular instructions to install openLuup on Rpi and continue to use Datayours ?

tnks

donato

Offline akbooer

  • Moderator
  • Master Member
  • *****
  • Posts: 6343
  • Karma: +288/-70
  • "Less is more"
Re: openLuup - running unmodified plugins on any machine
« Reply #31 on: July 10, 2015, 12:25:48 pm »
I'm using Datayours on Rpi. Do I have to follow any particular instructions to install openLuup on Rpi and continue to use Datayours ?

Oh hi there!  I was wondering if I should post instructions on transitioning to openLuup, but I thought I would make sure it worked OK for others first!  DataYours certainly works for me on this distribution, although I have made one change to it to make startup easier on openLuup.

All you would need to do is add to the startup code:
Code: [Select]
do -- DataYours
  local dy7 = luup.create_device ('', '', "DataYours", "D_DataYours7.xml","I_DataYours7.xml")        -- create the device
  luup.variable_set ("urn:akbooer-com:serviceId:DataYours1", "DAEMONS", "Graph, Dash, Cache, Watcher", dy7)
  luup.variable_set ("urn:akbooer-com:serviceId:DataYours1", "LOCAL_DATA_DIR", "/nas/whisper/", dy7)
  luup.variable_set ("urn:akbooer-com:serviceId:DataYours1", "VERAS", "172.16.42.10, 172.16.42.11, 172.16.42.12, 172.16.42.14", dy7)
end
...obviously with IP addresses, etc. tailored to your system.

I'll post the update to DataYours on that thread, to keep this focused on openLuup issues.

Thanks for the interest.
3x Vera Lite-UI5/Edge-UI7, 25x Fibaro, 23x TKB, 9x MiniMote, 2x NorthQ Power, 2x Netatmo, 1x Foscam FI9831P, 9x Philips Hue,
Razberry, MySensors Arduino, HomeWave, AltUI, AltHue, DataYours, Grafana, openLuup, ZWay, ZeroBrane Studio.

Offline vosmont

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 687
  • Karma: +60/-8
Re: openLuup - running unmodified plugins on any machine
« Reply #32 on: July 10, 2015, 03:08:59 pm »
Everything is Awesome !!!

It seems to work (LuaUPnP.log created and "alive" command responds "OK")

But, when I call "http://127.0.0.1:3480/data_request?id=lr_ALTUI_Handler&command=home#"
the response is "No handler".

The ALTUI files are in /etc/cmh-ludl

Offline akbooer

  • Moderator
  • Master Member
  • *****
  • Posts: 6343
  • Karma: +288/-70
  • "Less is more"
Re: openLuup - running unmodified plugins on any machine
« Reply #33 on: July 10, 2015, 03:43:13 pm »
Everything is Awesome !!!
Well, not quite everything, it would appear...

Quote
It seems to work (LuaUPnP.log created and "alive" command responds "OK")
Looking at the log file, then, are there any error messages from ALTUI ?  There are really three places to look: (a) early on, to be sure that the create device process has worked,
Code: [Select]
2015-07-10 17:04:49.229   luup.create_device:: [5] D_ALTUI.xml / I_ALTUI.xml
2015-07-10 17:04:49.233   luup.attr_set:: 5.device_json = D_ALTUI_UI7.json

... and (b) a bit later after the scheduler starts up and runs the job initialisation.
Code: [Select]
2015-07-10 17:04:51.798   openLuup.scheduler:5: device startup
2015-07-10 17:04:51.801   luup_log:5: ALTUI: initstatus(5) starting version: v0.52
2015-07-10 17:04:51.838   luup.register_handler:5: global_function_name=myALTUI_Handler, request=lr_ALTUI_Handler
2015-07-10 17:04:51.841   openLuup.scheduler:5: device startup completed: status=nil, msg=nil, name=nil

...and (c) a bit later still because ALTUI also has a delayed startup branch.
Code: [Select]
2015-07-10 17:05:04.421   luup_log:5: ALTUI: startupDeferred, called on behalf of device:5
2015-07-10 17:05:04.425   luup.variable_set:5: 5.urn:upnp-org:serviceId:altui1.Debug was: EMPTY now: 0 #hooks:0
2015-07-10 17:05:04.427   luup.variable_set:5: 5.urn:upnp-org:serviceId:altui1.Version was: EMPTY now: v0.52 #hooks:0
2015-07-10 17:05:04.430   luup.variable_set:5: 5.urn:upnp-org:serviceId:altui1.Present was: EMPTY now: 0 #hooks:0
2015-07-10 17:05:04.432   luup.variable_set:5: 5.urn:upnp-org:serviceId:altui1.RemoteAccess was: EMPTY now: https://vera-ui.strongcubedfitness.com/Veralogin.php #hooks:0
2015-07-10 17:05:04.434   luup.variable_set:5: 5.urn:upnp-org:serviceId:altui1.ThemeCSS was: EMPTY now:  #hooks:0
2015-07-10 17:05:04.436   luup.variable_set:5: 5.urn:upnp-org:serviceId:altui1.Version was: v0.52 now: v0.52 #hooks:0
2015-07-10 17:05:04.449   luup.variable_set:5: 5.urn:upnp-org:serviceId:altui1.PluginConfig was: EMPTY now: {...

Quote
But, when I call "http://127.0.0.1:3480/data_request?id=lr_ALTUI_Handler&command=home#"
the response is "No handler".
There should be a log file entry where ALTUI does a luup.register_handler - do you see that?  ALTUI also does a lot of fetches of files through the port:80 server - look for 404 errors in your regular HTTP server log.

Quote
The ALTUI files are in /etc/cmh-ludl
I have a feeling that I didn't mention this in the Guide, but you need to start up the openLuup process with your default directory as /etc/cmh-ludl/

One more question: have you create any other devices?  I've not tested ALTUI on openLuup without any.  Did you start the VeraBridge, for example?

Anyway, some progress is good.  ALTUI is actually a complex app to begin with, but we really have no choice since we need the interface!

3x Vera Lite-UI5/Edge-UI7, 25x Fibaro, 23x TKB, 9x MiniMote, 2x NorthQ Power, 2x Netatmo, 1x Foscam FI9831P, 9x Philips Hue,
Razberry, MySensors Arduino, HomeWave, AltUI, AltHue, DataYours, Grafana, openLuup, ZWay, ZeroBrane Studio.

Offline akbooer

  • Moderator
  • Master Member
  • *****
  • Posts: 6343
  • Karma: +288/-70
  • "Less is more"
Re: openLuup - running unmodified plugins on any machine
« Reply #34 on: July 10, 2015, 05:10:21 pm »
@Vosmont

Forget all that... I think I have found it.

ALTUI uses a shell script to determine its machine's IP address.  openLuup used to do the same, but now has a pure Lua way to do it...

The answer I posted a while ago here: http://forum.micasaverde.com/index.php/topic,31078.msg225192.html#msg225192 !!

You can suppress this message by creating the file /usr/bin/GetNetworkState.sh with the contents:
Code: [Select]
echo -n 172.16.42.88
replacing the IP address with that of your own (RPi) machine. 

in the absence of this script, ALTUI should have failed with an error message... which should be in the log?

I've never removed my copy from my machine, so all runs smoothly, although I had long forgotten it was there! 

3x Vera Lite-UI5/Edge-UI7, 25x Fibaro, 23x TKB, 9x MiniMote, 2x NorthQ Power, 2x Netatmo, 1x Foscam FI9831P, 9x Philips Hue,
Razberry, MySensors Arduino, HomeWave, AltUI, AltHue, DataYours, Grafana, openLuup, ZWay, ZeroBrane Studio.

Offline vosmont

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 687
  • Karma: +60/-8
Re: openLuup - running unmodified plugins on any machine
« Reply #35 on: July 10, 2015, 05:21:12 pm »
It's OK now. The file "L_ALTUI.lua" was missing.

Really great !

some remarks :
- In ZeroBrane log, there is an error about "GetNetworkState.sh"
- lots of errors in ALTUI on the browser : "GET http://ip:3480/luvd/D_MotionSensor1.xml 404 Not Found". It seems that all the definitions of devices must be on openLuup.

Offline akbooer

  • Moderator
  • Master Member
  • *****
  • Posts: 6343
  • Karma: +288/-70
  • "Less is more"
Re: openLuup - running unmodified plugins on any machine
« Reply #36 on: July 10, 2015, 05:24:08 pm »
- In ZeroBrane log, there is an error about "GetNetworkState.sh"
- lots of errors in ALTUI on the browser : "GET http://ip:3480/luvd/D_MotionSensor1.xml 404 Not Found". It seems that all the definitions of devices must be on openLuup.

Both of these are related and solved in my previous post (posted just before yours!)

...and just to be clear, you DO need all the .xml, .json files in /etc/cmh-ludl/ so that openLuup can load them.
3x Vera Lite-UI5/Edge-UI7, 25x Fibaro, 23x TKB, 9x MiniMote, 2x NorthQ Power, 2x Netatmo, 1x Foscam FI9831P, 9x Philips Hue,
Razberry, MySensors Arduino, HomeWave, AltUI, AltHue, DataYours, Grafana, openLuup, ZWay, ZeroBrane Studio.

Offline akbooer

  • Moderator
  • Master Member
  • *****
  • Posts: 6343
  • Karma: +288/-70
  • "Less is more"
Re: openLuup - running unmodified plugins on any machine
« Reply #37 on: July 10, 2015, 05:39:28 pm »
You can suppress this message by creating the file /usr/bin/GetNetworkState.sh with the contents...

Actually, here, now, is a better version of GetNetworkState.sh which uses a Lua script to, quite generally, find your IP address...

Code: [Select]
#! /usr/bin/env lua
--------------------------------------------------------------------------------
-- discover main IP address of machine and write to standard output
-- http://forums.coronalabs.com/topic/21105-found-undocumented-way-to-get-your-devices-ip-address-from-lua-socket/
--------------------------------------------------------------------------------
local socket = require "socket"
function myIP ()   
  local mySocket = socket.udp ()
  mySocket:setpeername ("42.42.42.42", "424242")  -- arbitrary IP and PORT
  local ip = mySocket:getsockname ()
  mySocket: close()
  return ip or "127.0.0.1"
end
io.write (myIP())
--------

if you have multiple versions of Lua installed, you may need to change the first line to:
Code: [Select]
#! /usr/bin/env lua5.1

This should be much better than having to craft a file specifically for your own machine IP - I'll put it in the next distribution.
« Last Edit: July 10, 2015, 05:57:08 pm by akbooer »
3x Vera Lite-UI5/Edge-UI7, 25x Fibaro, 23x TKB, 9x MiniMote, 2x NorthQ Power, 2x Netatmo, 1x Foscam FI9831P, 9x Philips Hue,
Razberry, MySensors Arduino, HomeWave, AltUI, AltHue, DataYours, Grafana, openLuup, ZWay, ZeroBrane Studio.

Offline vosmont

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 687
  • Karma: +60/-8
Re: openLuup - running unmodified plugins on any machine
« Reply #38 on: July 10, 2015, 06:53:39 pm »
As I am on Windows, I'm not sure that the script ".sh" will work.
For the moment I've modified the function getIP in L_ALTUI.lua, and it's OK.

I can controll the lights on the Vera via the bridge.

ALTUI is OK and putting the files of the plugin in /etc/cmh-ludl, lets ALTUI display their tabs.

The plugin RGB Controller doesn't work :
http://ip:3480/data_request?id=action&output_format=json&DeviceNum=41&serviceId=urn:upnp-org:serviceId:RGBController1&action=GetColorChannelNames
returns "-1"

I will do more tests but for the moment it seems to work well  :)

Bravo !

Offline vosmont

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 687
  • Karma: +60/-8
Re: openLuup - running unmodified plugins on any machine
« Reply #39 on: July 11, 2015, 04:06:08 am »
The plugin RGB Controller doesn't work :
http://ip:3480/data_request?id=action&output_format=json&DeviceNum=41&serviceId=urn:upnp-org:serviceId:RGBController1&action=GetColorChannelNames
returns "-1"

I think the problem is that this action is for the distant Vera (the plugin is installed on it). So when it is executed on openLuup, it can't respond.
So for the javascript in the tab of the distant plugin, it lacks perhaps a proxy.

Offline akbooer

  • Moderator
  • Master Member
  • *****
  • Posts: 6343
  • Karma: +288/-70
  • "Less is more"
Re: openLuup - running unmodified plugins on any machine
« Reply #40 on: July 11, 2015, 05:45:46 am »
As I am on Windows, I'm not sure that the script ".sh" will work.
For the moment I've modified the function getIP in L_ALTUI.lua, and it's OK.
I never imagined that openLuup would be run on a Windows machine!  A fair number of plugins will be written with the assumption that the underlying system is Unix.  In particular, anything with an os.execute(...) call will likely fail.  Your ALTUI fix is what I originally did - hooray for open source!

The plugin RGB Controller doesn't work :
http://ip:3480/data_request?id=action&output_format=json&DeviceNum=41&serviceId=urn:upnp-org:serviceId:RGBController1&action=GetColorChannelNames
returns "-1"

I think the problem is that this action is for the distant Vera (the plugin is installed on it). So when it is executed on openLuup, it can't respond.
So for the javascript in the tab of the distant plugin, it lacks perhaps a proxy.

A couple of points here:
  • An action call to a device bridged by VeraBridge will be re-routed to the remote machine device - this is how turning on lights, etc., works.  So the underlying mechanism should be working.  Actions which have return variables are not fully working at this time.  The definition of which variables to return is given in the service .xml files and I've been trying to avoid them, since this brings me too close to UPnP syntax nonsense.  The same with scene triggers.
  • Obviously, a plugin which assumes that it's manipulating the local machine GUI is going to struggle when bridged.  The solution is surely, simply to run RGB Controller on the openLuup machine - this is what it's for, to offload things from the original Vera. **** see edit below ***

Sounds like you've made a lot of progress.  Interested in hearing further.

---

Edit:  having re-read my reply, I suddenly realise that the action call you are making, which needs to be handled by VeraBridge, is NOT in its list of implemented actions (as given in the implementation file.)  This is perhaps what you implied by mentioning a proxy.  It would be a step forward to insert that action into I_VeraBridge.xml, but you may still have difficulties with the JavaScript.  Running it locally still makes sense to me.

« Last Edit: July 11, 2015, 05:52:33 am by akbooer »
3x Vera Lite-UI5/Edge-UI7, 25x Fibaro, 23x TKB, 9x MiniMote, 2x NorthQ Power, 2x Netatmo, 1x Foscam FI9831P, 9x Philips Hue,
Razberry, MySensors Arduino, HomeWave, AltUI, AltHue, DataYours, Grafana, openLuup, ZWay, ZeroBrane Studio.

Offline akbooer

  • Moderator
  • Master Member
  • *****
  • Posts: 6343
  • Karma: +288/-70
  • "Less is more"
Re: openLuup - running unmodified plugins on any machine
« Reply #41 on: July 11, 2015, 05:59:11 am »
Just for the sake of completeness, the serviceId / actions currently handled by VeraBridge are:

Code: [Select]
<serviceId>urn:upnp-org:serviceId:SwitchPower1</serviceId>
<name>SetTarget</name>

<serviceId>urn:upnp-org:serviceId:Dimming1</serviceId>
<name>SetLoadLevelTarget</name>

<serviceId>urn:micasaverde-com:serviceId:DoorLock1</serviceId>
<name>SetTarget</name>
 
<serviceId>urn:upnp-org:serviceId:TemperatureSetpoint1_Heat</serviceId>
<name>SetCurrentSetpoint</name>

<serviceId>urn:upnp-org:serviceId:HVAC_UserOperatingMode1</serviceId>
<name>SetModeTarget</name>

<serviceId>urn:upnp-org:serviceId:WindowCovering1</serviceId>
<name>Up</name>

<serviceId>urn:upnp-org:serviceId:WindowCovering1</serviceId>
<name>Down</name>

<serviceId>urn:upnp-org:serviceId:WindowCovering1</serviceId>
<name>Stop</name>

<serviceId>urn:micasaverde-com:serviceId:SecuritySensor1</serviceId>
<name>SetArmed</name>
3x Vera Lite-UI5/Edge-UI7, 25x Fibaro, 23x TKB, 9x MiniMote, 2x NorthQ Power, 2x Netatmo, 1x Foscam FI9831P, 9x Philips Hue,
Razberry, MySensors Arduino, HomeWave, AltUI, AltHue, DataYours, Grafana, openLuup, ZWay, ZeroBrane Studio.

Offline tomvanbreda

  • Newbie
  • *
  • Posts: 15
  • Karma: +2/-0
Re: openLuup - running unmodified plugins on any machine
« Reply #42 on: July 11, 2015, 08:29:04 am »
Hi
I tried this in Ubuntu and get the following response:

/etc/cmh-ludl$ sudo lua5.1 openLuup_release_1.lua /dev/null

lua5.1: ./openLuup/logs.lua:6: module 'socket' not found:
        no field package.preload['socket']
        no file './socket.lc'
        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 '/usr/share/lua/5.1/socket.lua'
        no file '/usr/share/lua/5.1/socket/init.lua'
        no file './socket.so'
        no file '/usr/local/lib/lua/5.1/socket.so'
        no file '/usr/lib/x86_64-linux-gnu/lua/5.1/socket.so'
        no file '/usr/lib/lua/5.1/socket.so'
        no file '/usr/local/lib/lua/5.1/loadall.so'

Offline akbooer

  • Moderator
  • Master Member
  • *****
  • Posts: 6343
  • Karma: +288/-70
  • "Less is more"
Re: openLuup - running unmodified plugins on any machine
« Reply #43 on: July 11, 2015, 08:38:37 am »
Hi
I tried this in Ubuntu and get the following response:

/etc/cmh-ludl$ sudo lua5.1 openLuup_release_1.lua /dev/null

lua5.1: ./openLuup/logs.lua:6: module 'socket' not found:

Yes.  I think it means what it says - you haven't installed the LuaSocket library.

See the bottom line of this earlier post: http://forum.micasaverde.com/index.php/topic,32315.msg240753.html#msg240753

It may be that you need a different instruction on Ubuntu to install it, but if you have already managed to install Lua then this should be along the same lines.
3x Vera Lite-UI5/Edge-UI7, 25x Fibaro, 23x TKB, 9x MiniMote, 2x NorthQ Power, 2x Netatmo, 1x Foscam FI9831P, 9x Philips Hue,
Razberry, MySensors Arduino, HomeWave, AltUI, AltHue, DataYours, Grafana, openLuup, ZWay, ZeroBrane Studio.

Offline akbooer

  • Moderator
  • Master Member
  • *****
  • Posts: 6343
  • Karma: +288/-70
  • "Less is more"
Re: openLuup - running unmodified plugins on any machine
« Reply #44 on: July 11, 2015, 10:33:46 am »
@vosmont

The solution is surely, simply to run RGB Controller on the openLuup machine...

So I tried this and got quite a long way using this startup code:
Code: [Select]
do -- RGB Controller
  local Drgb = luup.create_device ('', '', "RGBW Controller", "D_RGBController1.xml", "I_RGBController1.xml")
  luup.attr_set ("device_json", "D_RGBController1_UI7.json", Drgb)
  luup.variable_set ("urn:upnp-org:serviceId:RGBController1", "DeviceType", "FGRGBWM-441", Drgb)
  luup.variable_set ("urn:upnp-org:serviceId:RGBController1", "DeviceId", "217", Drgb)
end

I had to force the DeviceType and DeviceId variables, because I couldn't get the settings tab on the control panel to display for some reason.  The problem I ran into, however, is that, currently, the VeraBridge does not honour parent/child relationship from the bridged Vera: all remote devices are children of the VeraBridge (I think this is how it works on natively bridged Veras too, so it wouldn't work there either.)  This means that the target master device (Fibaro, in my case) does not have any RGBW children.

If you want to discuss this further, I'd recommend starting a new thread because we are drifting away from the general issues around openLuup.  Thanks.
3x Vera Lite-UI5/Edge-UI7, 25x Fibaro, 23x TKB, 9x MiniMote, 2x NorthQ Power, 2x Netatmo, 1x Foscam FI9831P, 9x Philips Hue,
Razberry, MySensors Arduino, HomeWave, AltUI, AltHue, DataYours, Grafana, openLuup, ZWay, ZeroBrane Studio.