Author Topic: openLuup: Sonos  (Read 18822 times)

Offline akbooer

  • Moderator
  • Master Member
  • *****
  • Posts: 6343
  • Karma: +288/-70
  • "Less is more"
Re: openLuup: Sonos
« Reply #15 on: April 01, 2016, 12:31:52 pm »
So what's the change needed to the wgets?  The openLuup server already has some special cases it catches, like icons, references to /luvd/ (which does not exist), cgi, etc...

I can make a change if it's robust and generally required.

Re. the "rm" command, this is poor programming in the plugin, I'm afraid.  Lua has a perfectly good, system independent, os.remove() function which does not complain if the file is absent.  In general, os.execute is a very, very bad idea.
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 CudaNet

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1401
  • Karma: +42/-11
  • Chimichanga !
Re: openLuup: Sonos
« Reply #16 on: April 01, 2016, 01:08:32 pm »
Yes, os.execute is used moderately throughout..

Vera version:
Code: [Select]
        local SAY_EXECUTE = "rm %s ; wget --output-document %s" .. [[ \
--quiet \
--header "Accept-Charset: utf-8;q=0.7,*;q=0.3" \
--header "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" \
--user-agent "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.64 Safari/537.11" \
"%s/tts?text=%s"]]

local returnCocde = os.execute(SAY_EXECUTE:format(file, file, OSXserverURL, url.escape(text)))

Modified version:
Code: [Select]
        local SAY_EXECUTE = "rm -f %s ; wget -O %s " .. [[ \
--header "Accept-Charset: utf-8;q=0.7,*;q=0.3" \
--header "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" \
--user-agent "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.64 Safari/537.11" \
"%s/tts?text=%s"]]

local returnCocde = os.execute(SAY_EXECUTE:format(file, file, OSXserverURL, url.escape(text), file))

CLI result of modified code.
Code: [Select]
--2016-04-01 20:57:55--  http://10.0.3.11:8080/tts?text=Here%20comes%20the%20sun%2e
Connecting to 10.0.3.11:8080... connected.
HTTP request sent, awaiting response... 200 OK
Length: 11381 (11K) [audio/mpeg]
Saving to: '/www/Say.5.mp3'

/www/Say.5.mp3                 100%[===================================================>]  11.11K  --.-KB/s   in 0s

2016-04-01 20:57:56 (31.9 MB/s) - ?/www/Say.5.mp3? saved [11381/11381]

So what's the change needed to the wgets?  The openLuup server already has some special cases it catches, like icons, references to /luvd/ (which does not exist), cgi, etc...

I can make a change if it's robust and generally required.

Re. the "rm" command, this is poor programming in the plugin, I'm afraid.  Lua has a perfectly good, system independent, os.remove() function which does not complain if the file is absent.  In general, os.execute is a very, very bad idea.
« Last Edit: April 01, 2016, 10:01:59 pm by CudaNet »
openLuup, AltUI, Zway and HomeWave, enough said...

Offline akbooer

  • Moderator
  • Master Member
  • *****
  • Posts: 6343
  • Karma: +288/-70
  • "Less is more"
Re: openLuup: Sonos
« Reply #17 on: April 01, 2016, 02:50:40 pm »
Ah, OK, I thought you meant luup.inet.wget().
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 CudaNet

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1401
  • Karma: +42/-11
  • Chimichanga !
Re: openLuup: Sonos
« Reply #18 on: April 01, 2016, 06:17:20 pm »
That was my bad, I should have clarified... Still looking into this HEAD method in relation to Sonos.. Not a whole lot out there ... Hopefully this is the final hurdle..

Ah, OK, I thought you meant luup.inet.wget().
openLuup, AltUI, Zway and HomeWave, enough said...

Offline CudaNet

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1401
  • Karma: +42/-11
  • Chimichanga !
Re: openLuup: Sonos
« Reply #19 on: April 01, 2016, 10:59:18 pm »
Might want to hold off on implementing the HEAD method... I thought of a workaround tonight for the OSXTTS that could keep this all Lua (that is if I can code it)....
openLuup, AltUI, Zway and HomeWave, enough said...

Offline CudaNet

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1401
  • Karma: +42/-11
  • Chimichanga !
Re: openLuup: Sonos
« Reply #20 on: April 02, 2016, 01:04:29 pm »
OK, things look really good. So what I've done is re-written the function for OSXTTS. With OSXTTS, you have two options. The plugin uses option [1]. Basically it sends a string (via action) to the OSXTTS API and it receives an MP3 in response. The Sonos plugin was then storing this MP3 to a file then generating a duration (from file size) and uri (VeraIP/PORT with path to MP3). Once it had that, the plugin sends a request to Sonos to stream the file off of Vera. This is where the HEAD method occurs (I guess to check if it exists).

I implemented option [2]. Basically it sends the string to OSXTTS but asks for the URI of the MP3 - not the file itself. Once I have that I store that as the URI for the plugin and make another request using HEAD to get the file size itself (as it doesn't send that to me initially). I take that information and feed it back to the plugin and rather than Sonos hitting Vera, it hits the OSXTTS server.

All of this of course is in pure Lua using http.request.... I just need to run some tests

Code: [Select]
--- Debug output
Method: POST
result: /static/tmp/tmpoNwgym.mp3
URI: http://10.0.3.11:8080/static/tmp/tmpoNwgym.mp3
Method: HEAD
MP3: /static/tmp/tmpoNwgym.mp3
DATA etag: "9bec0dae2b5c1f8e984980262af69ce3"
DATA size: 14056
DATA type: audio/mpeg
openLuup, AltUI, Zway and HomeWave, enough said...

Offline CudaNet

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1401
  • Karma: +42/-11
  • Chimichanga !
Re: openLuup: Sonos
« Reply #21 on: April 02, 2016, 03:52:02 pm »
And I hit a wall again... I have no idea what's causing this, although it was appearing before I changed the function...

Code: [Select]
2016-04-02 14:46:14.544   luup_log:0: ALTUI: runLua(luup.call_action("urn:micasaverde-com:serviceId:Sonos1", "Say",{Text="Testing using openLuup version 7.", Volume=30, Language="en"},6))
2016-04-02 14:46:14.544   luup.call_action:0: 6.urn:micasaverde-com:serviceId:Sonos1.Say
2016-04-02 14:46:14.545   luup_log:6: TTS server (ODX): Function Started, params = [http://10.0.3.11:8080], Device [6], Language [en], Say [Testing using openLuup version 7.].
2016-04-02 14:46:14.545   luup_log:6: TTS server (ODX): OSX Server Text-2-Send [text=Testing using openLuup version 7.].
2016-04-02 14:46:14.545   luup_log:6: TTS server (ODX): OSX URL to Call [http://10.0.3.11:8080/tts].
2016-04-02 14:46:14.545   luup_log:6: TTS server (ODX): OSX URL Method [POST].
2016-04-02 14:46:14.867   luup_log:6: TTS server (ODX): OSX MP3 Path [/static/tmp/tmpQYqidv.mp3].
2016-04-02 14:46:14.867   luup_log:6: TTS server (ODX): OSX URI [http://10.0.3.11:8080/static/tmp/tmpQYqidv.mp3].
2016-04-02 14:46:14.867   luup_log:6: TTS server (ODX): OSX URL to Call [http://10.0.3.11:8080/static/tmp/tmpQYqidv.mp3].
2016-04-02 14:46:14.867   luup_log:6: TTS server (ODX): OSX URL Method [HEAD].
2016-04-02 14:46:14.873   luup_log:6: TTS server (ODX): OSX MP3 File Size [25885].
2016-04-02 14:46:14.873   luup_log:6: TTS server (ODX): OSX MP3 Play Duration(+1 Second) [5].
2016-04-02 14:46:14.873   luup_log:6: TTS server (ODX): Function Completed, sending 'duration' [5] and 'uri' [http://10.0.3.11:8080/static/tmp/tmpQYqidv.mp3].
2016-04-02 14:46:14.874   openLuup.context_switch::  ERROR: [string "[8] I_Sonos1.xml"]:1413: bad argument #1 to 'find' (string expected, got nil)

And line 1413 is.. Anyway to work around this ? I know nothing (ok very little) about Luup/Implementation files.. Debug logs tell me nothing.
Code: [Select]
local members, coordinator

Edit: Here are two Sonos devices back to back.. Same action performed twice. The nil's in the log are the members and coordinator. As you can see both have the same values but only one device worked.
Code: [Select]
2016-04-02 15:40:16.119   luup_log:0: ALTUI: runLua(luup.call_action("urn:micasaverde-com:serviceId:Sonos1", "Say",{Text="Testing", Volume=30, Language="en"},8))
2016-04-02 15:40:16.120   luup.call_action:0: 8.urn:micasaverde-com:serviceId:Sonos1.Say
2016-04-02 15:40:16.120   luup_log:8: TTS server (ODX): Function Started, params = [http://10.0.3.11:8080], Device [8], Language [en], Say [Testing].
2016-04-02 15:40:16.120   luup_log:8: TTS server (ODX): OSX Server Text-2-Send [text=Testing].
2016-04-02 15:40:16.120   luup_log:8: TTS server (ODX): OSX URL to Call [http://10.0.3.11:8080/tts].
2016-04-02 15:40:16.120   luup_log:8: TTS server (ODX): OSX URL Method [POST].
2016-04-02 15:40:16.275   luup_log:8: TTS server (ODX): OSX MP3 Path [/static/tmp/tmpYNG_hQ.mp3].
2016-04-02 15:40:16.275   luup_log:8: TTS server (ODX): OSX URI  [http://10.0.3.11:8080/static/tmp/tmpYNG_hQ.mp3].
2016-04-02 15:40:16.275   luup_log:8: TTS server (ODX): OSX URL to Call [http://10.0.3.11:8080/static/tmp/tmpYNG_hQ.mp3].
2016-04-02 15:40:16.275   luup_log:8: TTS server (ODX): OSX URL Method [HEAD].
2016-04-02 15:40:16.279   luup_log:8: TTS server (ODX): OSX MP3 File Size [8437].
2016-04-02 15:40:16.280   luup_log:8: TTS server (ODX): OSX MP3 Play Duration(+1 Second) [3].
2016-04-02 15:40:16.280   luup_log:8: TTS server (ODX): Function Completed, sending 'duration' [3] and 'uri' [http://10.0.3.11:8080/static/tmp/tmpYNG_hQ.mp3].
2016-04-02 15:40:16.280   luup_log:8: ((CUDA)) ----------------------------------------------------------
2016-04-02 15:40:16.280   luup_log:8: nil
2016-04-02 15:40:16.280   luup_log:8: nil
2016-04-02 15:40:16.280   luup_log:8: ((CUDA)) ----------------------------------------------------------
2016-04-02 15:40:16.779   luup.variable_set:8: 8.urn:upnp-org:serviceId:AVTransport.TransportState was: STOPPED now: PLAYING #hooks:0
2016-04-02 15:40:16.808   luup.variable_set:8: 8.urn:upnp-org:serviceId:AVTransport.CurrentTransportActions was: Set, Play, Stop, Pause, Next now: Set, Play, Stop, Pause, Seek, Next, Previous #hooks:0
2016-04-02 15:40:16.816   luup.variable_set:8: 8.urn:upnp-org:serviceId:AVTransport.NumberOfTracks was: 0 now: 1 #hooks:0
2016-04-02 15:40:16.816   luup.variable_set:8: 8.urn:upnp-org:serviceId:AVTransport.AVTransportURI was: x-sonosapi-radio:radio%3ara.985486574?sid=204&flags=8300&sn=4 now: http://10.0.3.11:8080/static/tmp/tmpYNG_hQ.mp3 #hooks:0
2016-04-02 15:40:16.817   luup.variable_set:8: 8.urn:upnp-org:serviceId:AVTransport.AVTransportURIMetaData was: <DIDL-Lite xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:upnp="urn:schemas-upnp-org:metadata-1-0/upnp/" xmlns:r="urn:schemas-rinconnetworks-com:metadata-1-0/" xmlns="urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/"><item id="000c206cradio%3ara.985486574" parentID="00082064radiogenre%3aClassical%20%26%20Jazz" restricted="true"><dc:title>Classical</dc:title><upnp:class>object.item.audioItem.audioBroadcast</upnp:class><desc id="cdudn" nameSpace="urn:schemas-rinconnetworks-com:metadata-1-0/">SA_RINCON52231_X_#Svc52231-0-Token</desc></item></DIDL-Lite> now:  #hooks:0
2016-04-02 15:40:16.829   luup.variable_set:8: 8.urn:upnp-org:serviceId:AVTransport.CurrentTrack was: 0 now: 1 #hooks:0
2016-04-02 15:40:16.829   luup.variable_set:8: 8.urn:upnp-org:serviceId:AVTransport.CurrentTrackDuration was: 0:00:00 now: 0:00:01 #hooks:0
2016-04-02 15:40:16.830   luup.variable_set:8: 8.urn:upnp-org:serviceId:AVTransport.CurrentTrackURI was:  now: http://10.0.3.11:8080/static/tmp/tmpYNG_hQ.mp3 #hooks:0
2016-04-02 15:40:16.830   luup.variable_set:8: 8.urn:upnp-org:serviceId:AVTransport.CurrentTrackMetaData was:  now: <DIDL-Lite xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:upnp="urn:schemas-upnp-org:metadata-1-0/upnp/" xmlns:r="urn:schemas-rinconnetworks-com:metadata-1-0/" xmlns="urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/"><item id="-1" parentID="-1" restricted="true"><res protocolInfo="http-get:*:audio/mpeg:*" duration="0:00:01">http://10.0.3.11:8080/static/tmp/tmpYNG_hQ.mp3</res><r:streamContent></r:streamContent><dc:title>tmpYNG_hQ.mp3</dc:title><upnp:class>object.item.audioItem.musicTrack</upnp:class></item></DIDL-Lite> #hooks:0
2016-04-02 15:40:16.831   luup.variable_set:8: 8.urn:micasaverde-com:serviceId:Sonos1.CurrentService was: Apple Music now:  #hooks:0
2016-04-02 15:40:16.831   luup.variable_set:8: 8.urn:upnp-org:serviceId:AVTransport.CurrentRadio was: Classical now:  #hooks:0
2016-04-02 15:40:16.831   luup.variable_set:8: 8.urn:upnp-org:serviceId:AVTransport.CurrentStatus was: Apple Music: Classical now: tmpYNG_hQ.mp3 #hooks:0
2016-04-02 15:40:16.832   luup.variable_set:8: 8.urn:upnp-org:serviceId:AVTransport.CurrentTitle was:  now: tmpYNG_hQ.mp3 #hooks:0
2016-04-02 15:40:16.832   luup.variable_set:8: 8.urn:upnp-org:serviceId:AVTransport.CurrentAlbumArt was: http://10.0.4.24:1400/getaa?s=1&u=x%2dsonosapi%2dradio%3aradio%253ara%2e985486574%3fsid%3d204%26amp%3bflags%3d8300%26amp%3bsn%3d4 now: http://10.0.4.24:1400/img/icon-S3.png #hooks:0
2016-04-02 15:40:16.885   luup.variable_set:8: 8.urn:upnp-org:serviceId:RenderingControl.Volume was: 15 now: 30 #hooks:0
2016-04-02 15:40:16.886   luup.variable_set:8: 8.urn:micasaverde-com:serviceId:HaDevice1.LastUpdate was: 1459629608 now: 1459629616 #hooks:0
2016-04-02 15:40:16.886   luup_log:0: ALTUI: Evaluation of lua code returned: nil
2016-04-02 15:40:16.888   openLuup.server:: request completed (8 bytes, 1 chunks, 771 ms) tcp{client}: 0xae5638
2016-04-02 15:40:16.938   openLuup.server:: request completed (62260 bytes, 4 chunks, 6017 ms) tcp{client}: 0x85fa38
2016-04-02 15:40:17.044   openLuup.server:: /data_request?id=lu_status2&output_format=json&DataVersion=629604931&Timeout=60&MinimumDelay=1500&_=1459626000975 tcp{client}: 0x85fa38
2016-04-02 15:40:20.594   luup.variable_set:8: 8.urn:upnp-org:serviceId:AVTransport.TransportState was: PLAYING now: STOPPED #hooks:0
2016-04-02 15:40:20.625   luup.variable_set:8: 8.urn:upnp-org:serviceId:AVTransport.CurrentTransportActions was: Set, Play, Stop, Pause, Seek, Next, Previous now: Set, Play, Stop, Pause, Next #hooks:0
2016-04-02 15:40:20.638   luup.variable_set:8: 8.urn:upnp-org:serviceId:AVTransport.NumberOfTracks was: 1 now: 0 #hooks:0
2016-04-02 15:40:20.638   luup.variable_set:8: 8.urn:upnp-org:serviceId:AVTransport.AVTransportURI was: http://10.0.3.11:8080/static/tmp/tmpYNG_hQ.mp3 now: x-sonosapi-radio:radio%3ara.985486574?sid=204&amp;flags=8300&amp;sn=4 #hooks:0
2016-04-02 15:40:20.638   luup.variable_set:8: 8.urn:upnp-org:serviceId:AVTransport.AVTransportURIMetaData was:  now: <DIDL-Lite xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:upnp="urn:schemas-upnp-org:metadata-1-0/upnp/" xmlns:r="urn:schemas-rinconnetworks-com:metadata-1-0/" xmlns="urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/"><item id="000c206cradio%3ara.985486574" parentID="00082064radiogenre%3aClassical%20%26%20Jazz" restricted="true"><dc:title>Classical</dc:title><upnp:class>object.item.audioItem.audioBroadcast</upnp:class><desc id="cdudn" nameSpace="urn:schemas-rinconnetworks-com:metadata-1-0/">SA_RINCON52231_X_#Svc52231-0-Token</desc></item></DIDL-Lite> #hooks:0
2016-04-02 15:40:20.647   luup.variable_set:8: 8.urn:upnp-org:serviceId:AVTransport.CurrentTrack was: 1 now: 0 #hooks:0
2016-04-02 15:40:20.647   luup.variable_set:8: 8.urn:upnp-org:serviceId:AVTransport.CurrentTrackDuration was: 0:00:01 now: 0:00:00 #hooks:0
2016-04-02 15:40:20.648   luup.variable_set:8: 8.urn:upnp-org:serviceId:AVTransport.CurrentTrackURI was: http://10.0.3.11:8080/static/tmp/tmpYNG_hQ.mp3 now:  #hooks:0
2016-04-02 15:40:20.648   luup.variable_set:8: 8.urn:upnp-org:serviceId:AVTransport.CurrentTrackMetaData was: <DIDL-Lite xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:upnp="urn:schemas-upnp-org:metadata-1-0/upnp/" xmlns:r="urn:schemas-rinconnetworks-com:metadata-1-0/" xmlns="urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/"><item id="-1" parentID="-1" restricted="true"><res protocolInfo="http-get:*:audio/mpeg:*" duration="0:00:01">http://10.0.3.11:8080/static/tmp/tmpYNG_hQ.mp3</res><r:streamContent></r:streamContent><dc:title>tmpYNG_hQ.mp3</dc:title><upnp:class>object.item.audioItem.musicTrack</upnp:class></item></DIDL-Lite> now:  #hooks:0
2016-04-02 15:40:20.649   luup.variable_set:8: 8.urn:micasaverde-com:serviceId:Sonos1.CurrentService was:  now: Apple Music #hooks:0
2016-04-02 15:40:20.649   luup.variable_set:8: 8.urn:upnp-org:serviceId:AVTransport.CurrentRadio was:  now: Classical #hooks:0
2016-04-02 15:40:20.649   luup.variable_set:8: 8.urn:upnp-org:serviceId:AVTransport.CurrentStatus was: tmpYNG_hQ.mp3 now: Apple Music: Classical #hooks:0
2016-04-02 15:40:20.649   luup.variable_set:8: 8.urn:upnp-org:serviceId:AVTransport.CurrentTitle was: tmpYNG_hQ.mp3 now:  #hooks:0
2016-04-02 15:40:20.650   luup.variable_set:8: 8.urn:upnp-org:serviceId:AVTransport.CurrentAlbumArt was: http://10.0.4.24:1400/img/icon-S3.png now: http://10.0.4.24:1400/getaa?s=1&u=x%2dsonosapi%2dradio%3aradio%253ara%2e985486574%3fsid%3d204%26amp%3bflags%3d8300%26amp%3bsn%3d4 #hooks:0
2016-04-02 15:40:20.664   luup.variable_set:8: 8.urn:upnp-org:serviceId:RenderingControl.Volume was: 30 now: 15 #hooks:0
2016-04-02 15:40:20.957   luup.variable_set:8: 8.urn:micasaverde-com:serviceId:HaDevice1.LastUpdate was: 1459629616 now: 1459629620 #hooks:0
2016-04-02 15:40:21.484   openLuup.server:: request completed (62221 bytes, 4 chunks, 4440 ms) tcp{client}: 0x85fa38
2016-04-02 15:40:21.590   openLuup.server:: /data_request?id=lu_status2&output_format=json&DataVersion=629604947&Timeout=60&MinimumDelay=1500&_=1459626000976 tcp{client}: 0x85fa38
2016-04-02 15:40:21.625   openLuup.server:: /data_request?id=lr_ALTUI_LuaRunHandler&command=run_lua&lua=luup.call_action(%22urn%3Amicasaverde-com%3AserviceId%3ASonos1%22%2C%20%22Say%22%2C%7BText%3D%22Testing%22%2C%20Volume%3D30%2C%20Language%3D%22en%22%7D%2C5)&_=1459626000977 tcp{client}: 0xae5638
2016-04-02 15:40:21.625   luup_log:0: ALTUI: runLua(luup.call_action("urn:micasaverde-com:serviceId:Sonos1", "Say",{Text="Testing", Volume=30, Language="en"},5))
2016-04-02 15:40:21.626   luup.call_action:0: 5.urn:micasaverde-com:serviceId:Sonos1.Say
2016-04-02 15:40:21.626   luup_log:5: Sonos: debug: Say: Testing
2016-04-02 15:40:21.626   luup_log:5: TTS server (ODX): Function Started, params = [http://10.0.3.11:8080], Device [5], Language [en], Say [Testing].
2016-04-02 15:40:21.626   luup_log:5: TTS server (ODX): OSX Server Text-2-Send [text=Testing].
2016-04-02 15:40:21.626   luup_log:5: TTS server (ODX): OSX URL to Call [http://10.0.3.11:8080/tts].
2016-04-02 15:40:21.626   luup_log:5: TTS server (ODX): OSX URL Method [POST].
2016-04-02 15:40:21.762   luup_log:5: TTS server (ODX): OSX MP3 Path [/static/tmp/tmpagA6An.mp3].
2016-04-02 15:40:21.762   luup_log:5: TTS server (ODX): OSX URI  [http://10.0.3.11:8080/static/tmp/tmpagA6An.mp3].
2016-04-02 15:40:21.762   luup_log:5: TTS server (ODX): OSX URL to Call [http://10.0.3.11:8080/static/tmp/tmpagA6An.mp3].
2016-04-02 15:40:21.762   luup_log:5: TTS server (ODX): OSX URL Method [HEAD].
2016-04-02 15:40:21.765   luup_log:5: TTS server (ODX): OSX MP3 File Size [8437].
2016-04-02 15:40:21.765   luup_log:5: TTS server (ODX): OSX MP3 Play Duration(+1 Second) [3].
2016-04-02 15:40:21.765   luup_log:5: TTS server (ODX): Function Completed, sending 'duration' [3] and 'uri' [http://10.0.3.11:8080/static/tmp/tmpagA6An.mp3].
2016-04-02 15:40:21.765   luup_log:5: ((CUDA)) ----------------------------------------------------------
2016-04-02 15:40:21.766   luup_log:5: nil
2016-04-02 15:40:21.766   luup_log:5: nil
2016-04-02 15:40:21.766   luup_log:5: ((CUDA)) ----------------------------------------------------------
2016-04-02 15:40:21.766   openLuup.context_switch::  ERROR: [string "[8] I_Sonos1.xml"]:1417: bad argument #1 to 'find' (string expected, got nil)

If I start clean (user_Data) and add each Sonos, the Sonos recently added works and everything previously stops working. UGH !
« Last Edit: April 02, 2016, 10:27:53 pm by CudaNet »
openLuup, AltUI, Zway and HomeWave, enough said...

Offline akbooer

  • Moderator
  • Master Member
  • *****
  • Posts: 6343
  • Karma: +288/-70
  • "Less is more"
Re: openLuup: Sonos
« Reply #22 on: April 03, 2016, 09:13:47 am »
I need to see the exact I_xxx.xml and L_xxx.lua files you are using, along with the D_xxx.xml file.  That is clearly not the line in error, but it's likely that it's offset by some of the code in the implementation file. 
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 CudaNet

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1401
  • Karma: +42/-11
  • Chimichanga !
Re: openLuup: Sonos
« Reply #23 on: April 03, 2016, 10:20:46 am »
I've attached all the files and included an mp3. My suspicion is this, even though the code knows what device to playback on - it may be trying to "find" the device ID within the filename of the mp3 (e.g. Say.[deviceID].mp3). There are options if that's the case.

Hopefully you can make sense of this and thank you for looking...

I need to see the exact I_xxx.xml and L_xxx.lua files you are using, along with the D_xxx.xml file.  That is clearly not the line in error, but it's likely that it's offset by some of the code in the implementation file.
openLuup, AltUI, Zway and HomeWave, enough said...

Offline akbooer

  • Moderator
  • Master Member
  • *****
  • Posts: 6343
  • Karma: +288/-70
  • "Less is more"
Re: openLuup: Sonos
« Reply #24 on: April 03, 2016, 11:04:31 am »
The error appears to be for the 'find' 4 lines further on than reported (I understand why this is... just don't ask)

Code: [Select]
local members, coordinator

if (saveAndRestore == true and sayPlayback[device] == nil) then
local uuidListe2 = uuidListe
if (uuidListe2:find(localUUID) == nil) then

...so this would imply that uuidListe is nil.  I don't know what this means in a wider context, but a quick fix would be to change the above to

Code: [Select]
local members, coordinator

if (saveAndRestore == true and sayPlayback[device] == nil) then
local uuidListe2 = uuidListe or ""
if (uuidListe2:find(localUUID) == nil) then

See if that gets you any further.  I guess we will have to involve @lolodomo at some time.
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 CudaNet

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1401
  • Karma: +42/-11
  • Chimichanga !
Re: openLuup: Sonos
« Reply #25 on: April 03, 2016, 11:24:00 am »
It's still complaining.

In all fairness, I'm going to adjust the TTS function to store the file just as lolodomo intended - a simple adjustment. If tests prove positive then It may be necessary to implement the HEAD method. I'll make an adjustment and report back. I agree with you 100%, it would be great to have lolodomo add support for openLuup within this plugin. As always, I'm grateful for all your help...

The error appears to be for the 'find' 4 lines further on than reported (I understand why this is... just don't ask)

Code: [Select]
local members, coordinator

if (saveAndRestore == true and sayPlayback[device] == nil) then
local uuidListe2 = uuidListe
if (uuidListe2:find(localUUID) == nil) then

...so this would imply that uuidListe is nil.  I don't know what this means in a wider context, but a quick fix would be to change the above to

Code: [Select]
local members, coordinator

if (saveAndRestore == true and sayPlayback[device] == nil) then
local uuidListe2 = uuidListe or ""
if (uuidListe2:find(localUUID) == nil) then

See if that gets you any further.  I guess we will have to involve @lolodomo at some time.
openLuup, AltUI, Zway and HomeWave, enough said...

Offline akbooer

  • Moderator
  • Master Member
  • *****
  • Posts: 6343
  • Karma: +288/-70
  • "Less is more"
Re: openLuup: Sonos
« Reply #26 on: April 03, 2016, 11:42:07 am »
Same place, or a bit further on?

Actually, you might try this to see if it's any better, I note that the variable is used later.

Code: [Select]
local members, coordinator

uuidListe = uuidListe or ""
if (saveAndRestore == true and sayPlayback[device] == nil) then
local uuidListe2 = uuidListe
if (uuidListe2:find(localUUID) == nil) then

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 CudaNet

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1401
  • Karma: +42/-11
  • Chimichanga !
Re: openLuup: Sonos
« Reply #27 on: April 03, 2016, 11:59:00 am »
Code: [Select]
openLuup.context_switch::  ERROR: [string "[6] I_Sonos1.xml"]:1416: bad argument #1 to 'find' (string expected, got nil)

Let me plug your change in ....

Same place, or a bit further on?

Actually, you might try this to see if it's any better, I note that the variable is used later.

Code: [Select]
local members, coordinator

uuidListe = uuidListe or ""
if (saveAndRestore == true and sayPlayback[device] == nil) then
local uuidListe2 = uuidListe
if (uuidListe2:find(localUUID) == nil) then

openLuup, AltUI, Zway and HomeWave, enough said...

Offline CudaNet

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1401
  • Karma: +42/-11
  • Chimichanga !
Re: openLuup: Sonos
« Reply #28 on: April 03, 2016, 12:04:57 pm »
Same error...

Code: [Select]
2016-04-03 11:04:10.371   openLuup.context_switch::  ERROR: [string "[6] I_Sonos1.xml"]:1417: bad argument #1 to 'find' (string expected, got nil)
openLuup, AltUI, Zway and HomeWave, enough said...

Offline akbooer

  • Moderator
  • Master Member
  • *****
  • Posts: 6343
  • Karma: +288/-70
  • "Less is more"
Re: openLuup: Sonos
« Reply #29 on: April 03, 2016, 12:14:07 pm »
My bad, it's the variable localUUID which is nil, not uuidListe.

So, then, ...
Code: [Select]
local members, coordinator
localUUID = localUUID or ""

if (saveAndRestore == true and sayPlayback[device] == nil) then
local uuidListe2 = uuidListe
if (uuidListe2:find(localUUID) == nil) then
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.