openLuup: AV plugins

Questions here to do with Sonos, DLNA, Squeezebox, … configuration.

But see separate thread for Cameras, BlueIris, …

@akbooer i am getting ready to install the DLNA plugin on openluup on my mac. I have lua5.1, luasocket, luasec, and the latest openluup from github installed and running.

Can i trouble you to please provide instructions and links to anything else that needs to be installed on a Mac before installing the DLNA plugin?

Also, could you possibly summarize any changes that need to be made to the DLNA plug in files here in this thread? Are these files the right starting point? http://code.mios.com/trac/mios_dlna-cntroller/browser/tags/1.4

I realize this info is probably in various places in the other threads but if you would not mind i think it would be very helpful to me and other openluup noob’s to have all the steps in one place. Thanks !

/usr/bin/GetNetworkState.sh

Some plugins (particularly Sonos, DLNA, Squeezebox, because they’ve all borrowed from the same source) require an external shell script (part of a standard Vera installation) to define the host machine IP address.

There’s two basic ways to implement this.

This file can either be VERY simple:

echo -n 172.16.42.22

…with the IP address appropriately set (manually)

or a more sophisticated approach using a Lua script to return the result (automatic) which is described here:
http://forums.coronalabs.com/topic/21105-found-undocumented-way-to-get-your-devices-ip-address-from-lua-socket/

#! /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/PORT
  local ip = mySocket:getsockname ()
  mySocket: close()
  return ip or "127.0.0.1"
end
io.write (myIP())
--------

After creating this file in [tt]/usr/bin[/tt] you need to make it executable with the following shell command

chmod a+x /usr/bin/GetNetworkState.sh

You can now test this from the command line

# /usr/bin/GetNetworkState.sh
172.16.42.22# 

Note that it shouldn’t give you a new line at the end.

AltUI: v0.95.883
openLuup: 5.5
Chrome: Version 46.0.2490.80 m

I was hoping someone could confirm if their Sonos is exhibiting any issues.

Sonos device/player tab.

stack:TypeError: savedQueues.indexOf is not a function
    at Sonos_refreshPlayer (J_Sonos1.js:941:26)
    at Sonos_showPlayer (J_Sonos1.js:237:2)
    at eval (eval at _deviceDrawControlPanelJSTab (http://cobalt:3480/J_ALTUI_uimgr.js:4198:41), :1:1)
    at _deviceDrawControlPanelJSTab (http://cobalt:3480/J_ALTUI_uimgr.js:4198:17)
    at _deviceDrawControlPanelOneTabContent (http://cobalt:3480/J_ALTUI_uimgr.js:4573:7)
    at _displayActiveDeviceTab (http://cobalt:3480/J_ALTUI_uimgr.js:4599:4)
    at HTMLAnchorElement. (http://cobalt:3480/J_ALTUI_uimgr.js:6595:4)
    at HTMLDivElement.m.event.dispatch (http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js:4:8549)
    at HTMLDivElement.r.handle (http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js:4:5252)
    at Object.m.event.trigger (http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js:4:7650)

openLuup log data.

2015-11-08 02:40:54.737   luup_log:36: Sonos: UPnP proxy event identified - API version 
2015-11-08 02:40:54.895   openLuup.context_switch::  ERROR: ./L_Sonos1.lua:947: attempt to compare number with nil
2015-11-08 02:40:54.895   luup.delay_callback:: function: 0x10f9000 ERROR: ./L_Sonos1.lua:947: attempt to compare number with nil
2015-11-08 02:40:54.896   luup_log:37: Sonos: UPnP proxy event identified - API version 
2015-11-08 02:40:55.048   openLuup.context_switch::  ERROR: ./L_Sonos1.lua:947: attempt to compare number with nil
2015-11-08 02:40:55.048   luup.delay_callback:: function: 0x10ef0d0 ERROR: ./L_Sonos1.lua:947: attempt to compare number with nil
2015-11-08 02:40:55.048   luup_log:38: Sonos: UPnP proxy event identified - API version 
2015-11-08 02:40:55.222   openLuup.context_switch::  ERROR: ./L_Sonos1.lua:947: attempt to compare number with nil
2015-11-08 02:40:55.222   luup.delay_callback:: function: 0x105ccb0 ERROR: ./L_Sonos1.lua:947: attempt to compare number with nil
2015-11-08 02:40:55.223   luup_log:39: Sonos: UPnP proxy event identified - API version 
2015-11-08 02:40:55.420   openLuup.context_switch::  ERROR: ./L_Sonos1.lua:947: attempt to compare number with nil
2015-11-08 02:40:55.420   luup.delay_callback:: function: 0x15d2fd0 ERROR: ./L_Sonos1.lua:947: attempt to compare number with nil
2015-11-08 02:40:55.420   luup_log:40: Sonos: UPnP proxy event identified - API version 
2015-11-08 02:40:55.436   openLuup.context_switch::  ERROR: ./L_Sonos1.lua:947: attempt to compare number with nil
2015-11-08 02:40:55.436   luup.delay_callback:: function: 0x105f330 ERROR: ./L_Sonos1.lua:947: attempt to compare number with nil

I don’t get this, but perhaps it’s related to what’s in the queue, or some previous action.

AltUI v0.95.880
Firefox 42.0

[ul][li]You’re running 5 different Sonos systems? [/li]
[li]Are you running the Event Proxy?[/li]
[li]Don’t do that.[/li][/ul]

Line #947 in my version of L_Sonos1.lua is:

    if (ProxyApiVersion and tonumber(ProxyApiVersion:match("^(%d+)")) >= n) then

Thanks for moving this thread, kind of forgot about the AV plugin thread…
Yes, I had just added 5 speakers and for the most part one of them was working (displaying track and artist). I think It may have been coincidence I had just updated to .883. Hmm, event proxy - not sure I’d know if I was using it (inadvertently). I looked at debug > one devices states:

    {
      "id": 138,
      "service": "urn:micasaverde-com:serviceId:Sonos1",
      "value": "proxy is not in use",
      "variable": "ProxyUsed"
    },

But I’m not sure that’s what you meant…

[quote=“akbooer, post:5, topic:189395”]I don’t get this, but perhaps it’s related to what’s in the queue, or some previous action.

AltUI v0.95.880
Firefox 42.0

[ul][li]You’re running 5 different Sonos systems? [/li]
[li]Are you running the Event Proxy?[/li]
[li]Don’t do that.[/li][/ul]

Line #947 in my version of L_Sonos1.lua is:

if (ProxyApiVersion and tonumber(ProxyApiVersion:match("^(%d+)")) >= n) then [/quote]

Edit: OK, I did remove the UPNP Proxy from Vera as I was moving devices over, forgot (lets just say late night) I did that and forgot I had it installed remotely. I didn’t install it locally though…
Will see if putting it back on Vera resolves anything…

On the Settings page of the Sonos control panel, near the bottom:
[tt]
UPnP event proxy: proxy is not in use
[/tt]


Edit: I’m using 883 of AltUI now.

ok, it’s definitely not on…

On the Settings page of the Sonos control panel, near the bottom:
[tt]
UPnP event proxy: proxy is not in use
[/tt]


Edit: I’m using 883 of AltUI now.[/quote]

I’m going to clean off the rPi and test just adding a speaker to it and see what happens.

Good plan!

Well it seems to work on the rPi (one speaker) but speech isn’t working… Going to backup my production system and then see if I can add all my speakers, if that works then start slowly adding other devices to see what may be in contention.

2015-11-08 10:46:59.272   openLuup.server:: /data_request?id=lu_action&output_format=xml&DeviceNum=36&serviceId=urn:micasaverde-com:serviceId:Sonos1&action=Say&Text=testing&Language=en&Engine=OSX_TTS_SERVER&Volume=20&GroupZones=&SameVolumeForAll=false tcp{client}: 0x12d4368
2015-11-08 10:46:59.274   luup.call_action:: 36.urn:micasaverde-com:serviceId:Sonos1.Say 
2015-11-08 10:46:59.312   openLuup.context_switch::  ERROR: ./L_SonosTTS.lua:144: attempt to index local 'fh' (a nil value)
2015-11-08 10:46:59.314   openLuup.server:: request completed (2 bytes, 1 chunks, 41 ms) tcp{client}: 0x12d4368

Edit… Well I should have peeked at the console window. I don’t actually see it creating the file so hard to say what’s happening…
I know for the Nest I had to add a param to force (-f) removal so it would stop prompting and holding up the UI and openLuup.

rm: cannot remove ?/www/Say.36.mp3?: No such file or directory
/www/Say.36.mp3: Permission denied

Good plan![/quote]

Seems if I place a fake Say.36.mp3 file within the /www directory it’s able to remove the file which leads me to believe it’s not creating the file. I know, I’m jumping from issue to issue so I’ll just focus on the Sonos devices playing music and look at the TTS later.

2015-11-08 11:30:48.408   openLuup.server:: /data_request?id=lu_action&output_format=xml&DeviceNum=36&serviceId=urn:micasaverde-com:serviceId:Sonos1&action=Say&Text=Testing%20the%20server&Language=en&Engine=OSX_TTS_SERVER&Volume=&GroupZones=&SameVolumeForAll=false tcp{client}: 0x13d2c98
2015-11-08 11:30:48.410   luup.call_action:: 36.urn:micasaverde-com:serviceId:Sonos1.Say 
2015-11-08 11:30:48.447   luup_log:36: Sonos: warning: TTS server (ODX): failed!
2015-11-08 11:30:48.462   openLuup.server:: request completed (101 bytes, 1 chunks, 54 ms) tcp{client}: 0x13d2c98

[quote=“CudaNet, post:11, topic:189395”]Edit… Well I should have peeked at the console window. I don’t actually see it creating the file so hard to say what’s happening…
I know for the Nest I had to add a param to force (-f) removal so it would stop prompting and holding up the UI and openLuup.

rm: cannot remove ?/www/Say.36.mp3?: No such file or directory /www/Say.36.mp3: Permission denied [/quote]

Yes, I saw this a lot originally - I don’t use TTS ordinarily, so it may still be there.

Another example of a plugin using os.execute “rm …” when it should be using os.remove “…”

Didn’t stop TTS from working, though, I recall.

Well, if I create the Sonos device on the Raspberry Pi (Ubuntu Mate) - it works. If I move the user_data.json file over to the Ubuntu server, it works for a little while then starts to error. Starting clean on the Ubuntu server, I start off with errors. Not sure what’s going on with this…

2015-11-08 12:24:09.275   openLuup.server:: /data_request?id=lu_action&output_format=xml&DeviceNum=5&serviceId=urn:micasaverde-com:serviceId:Sonos1&action=SelectSonosDevice&URL=http%3A%2F%2F10.0.4.20%3A1400%2Fxml%2Fdevice_description.xml tcp{client}: 0x1f28878
2015-11-08 12:24:09.275   luup.call_action:: 5.urn:micasaverde-com:serviceId:Sonos1.SelectSonosDevice 
2015-11-08 12:24:09.280   luup.attr_set:5: 5.ip = 10.0.4.20
2015-11-08 12:24:09.280   luup.attr_set:5: 5.mac = 
2015-11-08 12:24:09.313   openLuup.context_switch::  ERROR: ./L_Sonos1.lua:947: attempt to compare number with nil

Ah, I think I may know what that might be. Can you set the MAC address to a space rather than nothing?

Well that seems to have fixed the help tab, but the player tab is a bit ill…

Edit: Looking at my test system, the help tab worked. So the help file working was more the result of my copying it from test to production. Adding a new Sonos to my production system failed and oddly enough I noticed this.

I actually tried to set it to the actual mac and it didn’t save. Correction, it just doesn’t show in the Attributes but rather the Variables…

Added 5 speakers to my Raspberry Pi Ubuntu Mate system. No issues. Even grouped they work perfect.
Copied over the user_data.json file to the Ubuntu Server.

I can’t imagine why these systems act so different…

2015-11-08 14:02:15.360   luup_log:36: Sonos: UPnP proxy event identified - API version 
2015-11-08 14:02:15.586   openLuup.context_switch::  ERROR: ./L_Sonos1.lua:947: attempt to compare number with nil
2015-11-08 14:02:15.586   luup.delay_callback:: function: 0x18f8ed0 ERROR: ./L_Sonos1.lua:947: attempt to compare number with nil
2015-11-08 14:02:15.587   luup_log:37: Sonos: UPnP proxy event identified - API version 
2015-11-08 14:02:15.781   openLuup.context_switch::  ERROR: ./L_Sonos1.lua:947: attempt to compare number with nil
2015-11-08 14:02:15.781   luup.delay_callback:: function: 0x1bf9640 ERROR: ./L_Sonos1.lua:947: attempt to compare number with nil
2015-11-08 14:02:15.781   luup_log:38: Sonos: UPnP proxy event identified - API version 
2015-11-08 14:02:17.265   openLuup.context_switch::  ERROR: ./L_Sonos1.lua:947: attempt to compare number with nil
2015-11-08 14:02:17.266   luup.delay_callback:: function: 0x1896720 ERROR: ./L_Sonos1.lua:947: attempt to compare number with nil
2015-11-08 14:02:17.266   luup_log:39: Sonos: UPnP proxy event identified - API version 
2015-11-08 14:02:17.465   openLuup.context_switch::  ERROR: ./L_Sonos1.lua:947: attempt to compare number with nil
2015-11-08 14:02:17.465   luup.delay_callback:: function: 0x1bcc300 ERROR: ./L_Sonos1.lua:947: attempt to compare number with nil
2015-11-08 14:02:17.465   luup_log:40: Sonos: UPnP proxy event identified - API version 
2015-11-08 14:02:17.620   openLuup.context_switch::  ERROR: ./L_Sonos1.lua:947: attempt to compare number with nil
2015-11-08 14:02:17.620   luup.delay_callback:: function: 0x1d320c0 ERROR: ./L_Sonos1.lua:947: attempt to compare number with nil

So, apparently, a system configuration problem.

Perhaps something got askew with testing at some point in time. Might have to level the Ubuntu Server and start from scratch. Seems to be something outside of the /cmh-ludl/ as I’ve copied the directories over from the Pi and it didn’t help. Sigh !