TTS with secured device

I am taking a look through the code this weekend, to understand why the device has to be unsecured in order to play TTS messages. And I can’t help but wonder if it would be possible to setup a new share on the vera device and give sonos access to that share as readonly. Only thing I seem to be stuck on is where to modify the existing code to save the temp MP3 file in a different location. Anyway, perhaps if the developer of this plugin would PM me, progress may be possible.

In the file L_SonosTTS.lua, you could change:

  • LOCAL_BASE_WEB_URL at line 23: it is the base URL that will be given to Sonos for playback. The MP3 file name is added to this base URL
  • SAY_OUTPUT_FILE at line 24: it is the place where the final MP3 file will be saved in the Vera

By the way, I think that what you want to do will not work. The idea is to add a new share to your Sonos library. Ok but each new file added to this share will require an update of the Sonos library.

So I modified the lua file you mentioned:

[code]–local LOCAL_BASE_WEB_URL = “http://%s:%d”
local LOCAL_BASE_WEB_URL = “http://%s:8050”

local SAY_TMP_FILE = “/tmp/Say.%s.%s.mp3”
– local SAY_OUTPUT_FILE = “/www/Say.%s.mp3”
local SAY_OUTPUT_FILE = “/wwwsonos/Say.%s.mp3”
–local SAY_OUTPUT_URI = “%s/Say.%s.mp3”
local SAY_OUTPUT_URI = “%s:8050/Say.%s.mp3”
local CONCAT_EXECUTE = “cat %s > %s ; rm %s”
local DELETE_EXECUTE = "rm " … SAY_OUTPUT_FILE[/code]

I also modified lighttpd to run a second instance on port 8050. And I modified the auth to use password auth for everything (just as I had before) with an exception for port 8050. I tested this by verifying:

  • I still need password to login on vera
  • I can access a test file on 192.168.1.4:8050/test.html
  • Then I tried doing a TTS. The file doesn’t play from the plugin (running sonos at the same time tells me that access is denied). However I did manage to make a copy of the mp3 file before it was removed and then pointed my browser to it: http://192.168.1.4:8050/Say.200.mp3 and it played.

So I am wondering why sonos has a problem with this. Thoughts?

If I can manage to get to this to work, I’ll post all of the details on what changes I had to make.

Thanks…

So I can run the Luup code from Vera, and that works… so I must have something wrong in the config file as to why it won’t work from the plugin.

luup.call_action(“urn:micasaverde-com:serviceId:Sonos1”, “PlayURI”,{URIToPlay=“http://192.168.1.4:8050/Say.210.mp3”, Volume=70},210)

Turns out, that in function setup()…

This isn’t returning the correct port:

function setup(language, engine, playFct, baseURL, googleUrl, osxUrl) defaultLanguage = language or "en" defaultEngine = engine or "GOOGLE" play = playFct or engines.GOOGLE.fct if (baseURL == nil or baseURL == "") then local stdout = io.popen("GetNetworkState.sh ip_wan") local ip = stdout:read("*a") stdout:close() localBaseURL = LOCAL_BASE_WEB_URL:format(ip, 8050) else localBaseURL = baseURL end

So if I add, underneath that:

localBaseURL = "http://192.168.1.4:8050"

Everything works perfectly.

The port should be set in a constant to make the change easier. Then you will not have to change SAY_OUTPUT_URI.

In fact, the proper way for you would be to change the call of the setup function to provide your specific baseUrl.