This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

SONOS app
What has change in the meantime?
------------------------------
Ctrl+F5
Reply
Hi,

The old Sonos app triggered on startup a command to find the players and stored the result in the storage, now that you use the sonos.lp separate from the app you need to execute this command at least once before using the sonos.lp and you need to run it whenever a change in your Sonos setup occurs.

I guess the reason that it suddenly stopped is that you used it before with the old app (so the players table was already created) and the players have got a new IP address or something that not match the one in the players table.

You can create or renew the players table by calling this
Code:
-- Load modules
require('socket.http')

-- Set timout
socket.http.TIMEOUT = 5

socket.http.request('http://127.0.0.1/user/sonos.lp?action=refreshsonosdata')
You can check the players table content by the storage viewer app or run this code
Code:
log(storage.get('SONOS_PLAYERS'))
I noticed in your last post that you also uploaded sonos.lua to the ftp, this is not needed, sonos.lp is the only file you need to use the API from the old Sonos app, next to that a additional .mp3 file to use for the "say" or "sayall" command.

Keep in mind that sonos.lp is 100% build on the UpnP protocol that Sonos is using and they recently opened up the Sonos API where the new certified Sonos app is build on. It might happen one day that Sonos drops the UpnP part in the product and sonos.lp is not usable anymore, but for now i have no indication that Sonos is dropping the UpnP methode.

BR,

Erwin
Reply
(27.05.2020, 22:30)Erwin van der Zwart Wrote: Hi,

The old Sonos app triggered on startup a command to find the players and stored the result in the storage, now that you use the sonos.lp separate from the app you need to execute this command at least once before using the sonos.lp and you need to run it whenever a change in your Sonos setup occurs.

I guess the reason that it suddenly stopped is that you used it before with the old app (so the players table was already created) and the players have got a new IP address or something that not match the one in the players table.

You can create or renew the players table by calling this
Code:
-- Load modules
require('socket.http')

-- Set timout
socket.http.TIMEOUT = 5

socket.http.request('http://127.0.0.1/user/sonos.lp?action=refreshsonosdata')
You can check the players table content by the storage viewer app or run this code
Code:
log(storage.get('SONOS_PLAYERS'))
I noticed in your last post that you also uploaded sonos.lua to the ftp, this is not needed, sonos.lp is the only file you need to use the API from the old Sonos app, next to that a additional .mp3 file to use for the "say" or "sayall" command.

Keep in mind that sonos.lp is 100% build on the UpnP protocol that Sonos is using and they recently opened up the Sonos API where the new certified Sonos app is build on. It might happen one day that Sonos drops the UpnP part in the product and sonos.lp is not usable anymore, but for now i have no indication that Sonos is dropping the UpnP methode.

BR,

Erwin

Hi
OK, tried that, and then I get the following result from the storage;

Test Sonos 28.05.2020 08:24:53
* arg: 1
  * nil
* arg: 2
  * string: key not found or invalid type

I tried to replace the sonos.lp and do a new 'http://127.0.0.1/user/sonos.lp?action=refreshsonosdata', but still the same result. The log indicates that the sonos system is not really stored, is it not?
There are 10 kinds of people in the world; those who can read binary and those who don't  Cool
Reply
Hi,

Did you disable the need for a password on the user ftp in the user settings?

If you try to run the http command from a browser, you should get back a value ‘true’ when the action was successful

BR,

Erwin
Reply
(28.05.2020, 06:52)Erwin van der Zwart Wrote: Hi,

Did you disable the need for a password on the user ftp in the user settings?

If you try to run the http command from a browser, you should get back a value ‘true’ when the action was successful

BR,

Erwin

When running the http command in the browser, I get the list of all sonos devices, so that seems OK then.

What should I expect to get from the storage.get('SONOS_PLAYERS')?
There are 10 kinds of people in the world; those who can read binary and those who don't  Cool
Reply
The same table, only decoded to LUA format instead of JSON, what do you see when you use the Storage Viewer App?
Reply
(28.05.2020, 10:14)Erwin van der Zwart Wrote: The same table, only decoded to LUA format instead of JSON, what do you see when you use the Storage Viewer App?

I figured out the storage, In the storage, the table is not named as you mantioned, but rather
Code:
log(storage.get('Sonos:Players'))
 When I changed that, I got the table in the log as expected.

But the error I get when running the script is reffered to the sonos.lua file: 
Test Sonos 28.05.2020 10:42:29
* string: Error in /www/user/sonos.lua at line 0: attempt to get length of a nil value

The mp3 file is played on Sonos, but Sonos does not return to playing whatever was playing before the script was run.

There are 10 kinds of people in the world; those who can read binary and those who don't  Cool
Reply
Hi,

Okay, yes then you use another sonos.lp then i did, it's correct we changed this in a later stage to Sonos : Players

I don't understand why you get a error from /www/user/sonos.lua as this file is not needed, did you make a reference to this file or something?

The only file you need on the FTP is sonos.lp, can you try to delete the reference and the LUA file from the user folder?

BR,

Erwin
Reply
/www/user/sonos.lua is used by sonos.lp, removing it won't help. Have you tried using ip instead of player uuid?
Code:
ip = '1.2.3.4' -- change this
reply = socket.http.request('http://admin:PASSWORD@127.0.0.1/user/sonos.lp?action=say&ip=' .. ip .. '&audiofile=' .. audiofile .. '&volume=10&duration=10')
Reply
(28.05.2020, 11:05)Erwin van der Zwart Wrote: Hi,

Okay, yes then you use another sonos.lp then i did, it's correct we changed this in a later stage to Sonos : Players

I don't understand why you get a error from /www/user/sonos.lua as this file is not needed, did you make a reference to this file or something?

The only file you need on the FTP is sonos.lp, can you try to delete the reference and the LUA file from the user folder?

BR,

Erwin
Hi
The only code I have is this:

Code:
require('socket.http')
socket.http.timeout = 5
socket.http.request('http://127.0.0.1/user/sonos.lp?action=getsonosdata')
--socket.http.request('http://127.0.0.1/user/sonos.lp?action=refreshsonosdata')
log(storage.get('Sonos:Players'))


PlayerID = 'RINCON_347E5C3B47D801400' --Kontor
--PlayerID = 'RINCON_347E5C35715E01400' --Stue
audiofile = socket.url.escape('http://192.168.39.10/user/Ringeklokke.mp3')

reply = socket.http.request('http://admin:PASS@127.0.0.1/user/sonos.lp?action=say&uuid=' .. PlayerID .. '&audiofile=' .. audiofile .. '&volume=10&duration=10')

log(reply)

I do not know where I might have a link to sonos.lua. I tried to delete the sonos.lua, and run the script; same error message.

(28.05.2020, 11:10)admin Wrote: /www/user/sonos.lua is used by sonos.lp, removing it won't help. Have you tried using ip instead of player uuid?
Code:
ip = '1.2.3.4' -- change this
reply = socket.http.request('http://admin:PASSWORD@127.0.0.1/user/sonos.lp?action=say&ip=' .. ip .. '&audiofile=' .. audiofile .. '&volume=10&duration=10')
Same result...
There are 10 kinds of people in the world; those who can read binary and those who don't  Cool
Reply
Are you sure you are using these files?
https://dl.openrb.com/misc/sonos.lp
https://dl.openrb.com/misc/sonos.lua

These are from old Sonos app which did not use Sonos API.
Reply
(28.05.2020, 11:30)admin Wrote: Are you sure you are using these files?
https://dl.openrb.com/misc/sonos.lp
https://dl.openrb.com/misc/sonos.lua

These are from old Sonos app which did not use Sonos API.
Yes.

Downloaded them again earlier today to be sure....
There are 10 kinds of people in the world; those who can read binary and those who don't  Cool
Reply
Hi,

Apperently admin added the sonos.lua  and changed the sonos.lp and i was unaware of this change (:

I removed all storage entry's before testing (so that couldn't influence the test) and uploaded the 2 new files to my ftp and runned this script:
Code:
require('socket.http')
socket.http.timeout = 5
audiofile = socket.url.escape('http://192.168.10.200/user/deurbel.mp3')
ip = '192.168.10.206' -- change this to your Sonos IP
reply = socket.http.request('http://127.0.0.1/user/sonos.lp?action=say&ip=' .. ip .. '&audiofile=' .. audiofile .. '&volume=80&duration=20')
I was playing a radio track from intune, it paused, went to a higer volume , played the doorbell.mp3 and reduced volume and continuud playing on intune.

There are no errors in my log so it seems to work perfect..

BR,

Erwin
Reply
I've just stared using the new Sonos app and while looking at the Schneider Electric youtube video at 1:20 a widget is created which also seems to create some useful group addresses.

Likewise I tried to create a sonos widget on my factory defaulted LM5 but it seems to fail because I can't enter a Floor and Room. Presumably a pulldown menu should have been presented and populated with floors ans rooms which have to be created beforehand so I created a few in the Vis.Structure tab but unfortunately without any success.

Am I missing something ?
Reply
Install Mosaic 2.0. For Mosaic 3.0 we created different storage, the app keeps using old one.
------------------------------
Ctrl+F5
Reply
Thanks!
Reply
(29.05.2020, 09:55)Erwin van der Zwart Wrote: Hi,

Apperently admin added the sonos.lua  and changed the sonos.lp and i was unaware of this change (:

I removed all storage entry's before testing (so that couldn't influence the test) and uploaded the 2 new files to my ftp and runned this script:
Code:
require('socket.http')
socket.http.timeout = 5
audiofile = socket.url.escape('http://192.168.10.200/user/deurbel.mp3')
ip = '192.168.10.206' -- change this to your Sonos IP
reply = socket.http.request('http://127.0.0.1/user/sonos.lp?action=say&ip=' .. ip .. '&audiofile=' .. audiofile .. '&volume=80&duration=20')
I was playing a radio track from intune, it paused, went to a higer volume , played the doorbell.mp3 and reduced volume and continuud playing on intune.

There are no errors in my log so it seems to work perfect..

BR,

Erwin

Hi

I still get the same error message. 
I checked with another project where I have tried this function, and it works there. Maybe There is something wrong with the LM I have here? 

Could it be that there is a problem with the memory card?
There are 10 kinds of people in the world; those who can read binary and those who don't  Cool
Reply
If you have memory card issues then just reboot and check if all your changes are still there. Maybe your problem is in sonos player?
------------------------------
Ctrl+F5
Reply
(03.06.2020, 07:40)Daniel. Wrote: If you have memory card issues then just reboot and check if all your changes are still there.  Maybe your problem is in sonos player?

All changes are still there after reboot. Might of course be a Sonos problem, but the player I tested is brand new, and also this wokred on a different player earlier, but not any more.

The only thinf not working in the script is the retur to the old state after playing the mp3-file.
There are 10 kinds of people in the world; those who can read binary and those who don't  Cool
Reply
Hi,

What source are you playing from? We store the current URI when playing the mp3 and works with Intune Radio, but it might be that playing Spotify or other service has another methode then the URI we store and That might be the cause of what you experience. Can you test it with a radio station playing?

BR,

Erwin
Reply


Forum Jump: