SONOS, 'say' what?

Thank you, @tobbesjufem!
I’ve tried as you suggested, but the server is not running after a reboot and

 systemctl status rc-local.service

reveals the following:

● rc-local.service - /etc/rc.local Compatibility
   Loaded: loaded (/lib/systemd/system/rc-local.service; static; vendor preset: enabled)
  Drop-In: /lib/systemd/system/rc-local.service.d
           └─debian.conf
   Active: active (exited) (Result: exit-code) since Mo 2016-09-19 22:46:26 CEST; 7min ago
  Process: 1330 ExecStart=/etc/rc.local start (code=exited, status=0/SUCCESS)
 Main PID: 1331 (code=exited, status=1/FAILURE)
    Tasks: 0
   Memory: 0B
      CPU: 0
   CGroup: /system.slice/rc-local.service

Sep 19 22:46:27 prometheus rc.local[1330]: module.js:341
Sep 19 22:46:27 prometheus rc.local[1330]:     throw err;
Sep 19 22:46:27 prometheus rc.local[1330]:     ^
Sep 19 22:46:27 prometheus rc.local[1330]: Error: Cannot find module '/home/phate/sonos/server.js'
Sep 19 22:46:27 prometheus rc.local[1330]:     at Function.Module._resolveFilename (module.js:339:15)
Sep 19 22:46:27 prometheus rc.local[1330]:     at Function.Module._load (module.js:290:25)
Sep 19 22:46:27 prometheus rc.local[1330]:     at Function.Module.runMain (module.js:447:10)
Sep 19 22:46:27 prometheus rc.local[1330]:     at startup (node.js:148:18)
Sep 19 22:46:27 prometheus rc.local[1330]:     at node.js:405:3
Sep 19 22:46:27 prometheus systemd[1]: rc-local.service: Main process exited, code=exited, status=1/FAILURE

Then, I’ve executed /etc/rc.local manually from a terminal session once again and it’s working, though a new error is printed out as can be seen below.
However, due to the “&” at the end of the command in rc.local, the manual execution allowed me to continue using the terminal session without being captured withing the execution of the server that will be killed as soonas I terminate the remote connection (could have thought about the amperstand before - shame on me).
It’s ok for now as I “just” need to remember to execute /etc/rc.local manually when having performed a reboot of the server. It would be nice to understand the problem and resolve the issue somehow though…
I’ve read that rc.local is executed before any user logs in - But granting 777 recursively to everything in ~/sonos (including server.js) also doesn’t change anything about the error message. No clue anymore what to check… Any help is still very much appreciated!
Thanks a lot, guys!

I need some help setting up this voice notifications to sonos speakers. I followed James Bruce article but I can’t seem to get it to work. I only have one Sonos Play1 speaker that is in the “Dining Room”. This is what I get when I use the “npm start” command:

pi@raspberrypi:~/node-v5.12.0-linux-armv7l/sonos $ npm start

sonos-http-api@1.4.4 start /home/pi/node-v5.12.0-linux-armv7l/sonos
node server.js

2017-09-06T21:36:07.104Z INFO Presets loaded: { example:
   { players:
  [ { roomName: 'Bathroom', volume: 10 },
    { roomName: 'Kitchen', volume: 10 },
    { roomName: 'Office', volume: 10 },
    { roomName: 'Bedroom', volume: 10 },
    { roomName: 'TV Room', volume: 15 } ],
 playMode: { shuffle: true, repeat: 'all', crossfade: false },
 pauseOthers: false,
 favorite: 'My example favorite' } }
2017-09-06T21:36:08.120Z INFO http server listening on port 5009

I changed the default port of 5005 to 5009 in the settings file due to that port being used by something else.
When I type:
http://192.168.0.32:5009/dining room/say/make%20use%20of%20is%20awesome/en-gb

into my browser I get a unable to connect message. Any help would be greatly appreciated.

I am unsure what you are trying to accomplish but oh2 has improved significantly over time and I think using the sonos binding, voiceRSS and audiosinks could be an alternative.

1 Like

As Robert stated, Sonos Players using the Sonos binding, TTS from VoiceRSS and the say command is all you need. Works like a charm.

I’ve also not succeeded in making my Sonos speakers say anything and I don’t really know where to start searching. Provided I have chosen a default sink and rss service in paperUI settings it should work right out of the box, right? For me, running a “smarthome:voice say test” makes no sound. Also a simple “smarthome:audio play doorbell.mp3” makes no sound (also tried “smarthome:audio play sonos:PLAY1:RINCON_B8E937838C1C01400 doorbell.mp3” with a correct sink name as returned by “smarthome:audio sinks”). None of the commands even return, I have to Ctrl+C them. No errors are logged, so no real indication on why it isn’t working…

Jurgen could check out my settings to see what I’m doing wrong.
I have the VoiceRSS and Sonos bindings. In the Paper UI I have Sonos PLAY:1 listed in the configuration-System-Audio-Default Sink. In configuration-System-Voice I have Default text to speech as “VoiceRSS Text to Speech Engine” and default voice as "VoiceRSS-English (United States). Here is my items file:

Player Sonos_Controller   "Controller"                          (Sonos) {channel="sonos:PLAY1:RINCON_xxxxxx:control"}
Dimmer Sonos_Volume       "Volume [%.1f %%]" <soundvolume>      (Sonos) {channel="sonos:PLAY1:RINCON_xxxxxx:volume"}
Switch Sonos_Mute         "Mute"             <soundvolume_mute> (Sonos) {channel="sonos:PLAY1:RINCON_xxxxxx:mute"}
Switch Sonos_LED          "LED"              <switch>           (Sonos) {channel="sonos:PLAY1:RINCON_xxxxxx:led"}
String Sonos_CurrentTrack "Now playing [%s]" <text>             (Sonos) {channel="sonos:PLAY1:RINCON_xxxxxx:currenttrack"}
String Sonos_State        "Status [%s]"      <text>             (Sonos) {channel="sonos:PLAY1:RINCON_xxxxxx:state"}
String Sonos_Favorite      "Favorite Channel"                   (Sonos) {channel="sonos:PLAY1:RINCON_xxxxxx:favorite"}
String Sonos_Radio         "Favorite Radio"                     (Sonos) {channel="sonos:PLAY1:RINCON_xxxxxx:radio"}
String Sonos_Notification  "Notifications"                      (Sonos) {channel="sonos:PLAY1:RINCON_xxxxxx:notificationsound"}
String Speech_Out   "Speech Out"

In my sitemap I have this:

Text label="Sonos" {
		        Default item=Sonos_Controller
		        Slider  item=Sonos_Volume
                        Slider  item=Sonus_Notification_Volume
		        Switch  item=Sonos_Mute
		        Switch  item=Sonos_LED
	        	Text    item=Sonos_CurrentTrack		
		        Text    item=Sonos_State
                        Switch item=Sonos_Favorite mappings=["Top Pop"="Top Pop","Top Country"="Top Country"]
	         }

I am able to control my Sonos Play1 from my sitemap. I am unable to get the rule below to work.

rule "Door Open Test"
when
     Item FrontDoor changed from CLOSED to OPEN
then
     sendCommand(Speech_Out.state.toString, "The front door is open")
     say(Speech_Out.state.toString,"voicerss:deDE","sonos:PLAY1:RINCON_XXXXXX")
end

Will completely check when I’m at my system, however which language are you using? English or German, you stated to have set English on PaperUI but are asking for German in the rule.

Oh, I didn’t realize that. It should be English. I’ll change that.

Some tests with my system using the karaf console:
“smarthome:audio play doorbell.mp3” should play the .mp3 on your default audio-sink (which you should have setup)
" smarthome:audio play sonos:PLAY1:RINCON_XXXX1400 doorbell.mp3" would be the command if no default is set or if you have more then one audio-sink.

for the TTS part,
“smarthome:voice say Hallo” played “Hallo” on my default audio-sink. If you managed the get feedback on the play-command but not for say check if VoiceRSS is setup correctly. A correct setup should write the .mp3 files to “userdata/voicerss/cache” on a linux-system that would be “var/lib/openhab2/voicerss/cache”. Do you have the files in that directory?

There are .txt and .mp3 files. The text ones just say “NULL”. Not the message I have in my rule: The front door is open

In this case lets make sure your VoiceRSS setup is correct:
My PaperUI system tab Voice looks like that:
grafik
and in the voicerss.cfg file I have:

######################## VoiceRSS Text-to-Speech Engine ########################

# API key you got when you subscribed to the Voice RSS service
# Open your profile to get the value: http://www.voicerss.org/personel/
apiKey=InHereIsMyAPIKey

That should be all.

I assume you DO have a personell API from VoiceRSS, don’t you?

Yes, all that looks just like mine, except I have the VoiceRSS-English (United States)

Here is my openhab log when I open my front door.

2017-09-07 15:05:29.155 [vent.ItemStateChangedEvent] - FrontDoor changed from CLOSED to OPEN

==> /var/log/openhab2/openhab.log <==
2017-09-07 15:05:29.726 [WARN ] [rthome.model.script.actions.BusEvent] - Item 'NULL' does not exist.

==> /var/log/openhab2/openhab.log <==
2017-09-07 15:05:29.764 [INFO ] [ipse.smarthome.model.script.Security] - FrontDoor Opened on 2017-09-07T15:05:29.132-04:00

==> /var/log/openhab2/events.log <==
2017-09-07 15:05:29.901 [vent.ItemStateChangedEvent] - sonos_PLAY1_RINCON_XXXXXX_volume changed from 41 to 51
2017-09-07 15:05:29.911 [vent.ItemStateChangedEvent] - Sonos_Volume changed from 41 to 51
2017-09-07 15:05:29.961 [vent.ItemStateChangedEvent] - sonos_PLAY1_RINCON_XXXXXX_currenttitle changed from a2ae447e-4a4c-4e5c-8202-048ead85211c.mp3 to ca689b3e-32c8-4b05-80eb-0c2cbed68a6e.mp3
2017-09-07 15:05:29.979 [vent.ItemStateChangedEvent] - sonos_PLAY1_RINCON_xxxxxx_currenttrack changed from  -  - a2ae447e-4a4c-4e5c-8202-048ead85211c.mp3 to  -  - ca689b3e-32c8-4b05-80eb-0c2cbed68a6e.mp3
2017-09-07 15:05:29.990 [vent.ItemStateChangedEvent] - Sonos_CurrentTrack changed from  -  - a2ae447e-4a4c-4e5c-8202-048ead85211c.mp3 to  -  - ca689b3e-32c8-4b05-80eb-0c2cbed68a6e.mp3
2017-09-07 15:05:43.705 [vent.ItemStateChangedEvent] - FrontDoor changed from OPEN to CLOSED

   ==> /var/log/openhab2/openhab.log <==
2017-09-07 15:05:43.815 [INFO ] [ipse.smarthome.model.script.Security] - FrontDoor Closed on 2017-09-07T15:05:43.699-04:00

==> /var/log/openhab2/events.log <==
2017-09-07 15:05:50.138 [vent.ItemStateChangedEvent] - sonos_PLAY1_RINCON_xxxxxx_volume changed from 51 to 41
2017-09-07 15:05:50.143 [vent.ItemStateChangedEvent] - Sonos_Volume changed from 51 to 41

Well, as I stated earlier: Those commands play nothing at all.

Yep, that part seems to work, I’ve got mp3 and txt files in that directory. So obviously my problem is not the tts but the fact that it isn’t able to play the sound at all (which makes this thread a bit mixed I guess since me and @MikeH obviously have different problems, sorry for that).

Anyway, is there some log level I can increase that might give me something?

edit: After a closer thought, maybe that’d simply be the log level of the Sonos binding. Too bad my children have gone to sleep now, I don’t dare testing anything including the Sonos system when they have :blush:

Could you post your result of “smarthome:audio sinks”

openhab> smarthome:audio sinks
sonos:PLAY1:RINCON_B8E937838C1C01400
enhancedjavasound
javasound
webaudio

I take it you have the sonos box set as default sink AND have tried the play command with the audio-sink from your setup as well.
In this case I’m out of ideas at the moment.

I get this when I enter “smarthome:audio sinks” :
openhab> smarthome:audio sinks
sonos:PLAY1:RINCON_xxxxxx1400
enhancedjavasound
javasound
webaudio
openhab>

I get command not found when I enter: smarthome:say play doorbell.mp3

When I enter “smarthome:audio play sonos:PLAY1:RINCON_XXXX1400 doorbell.mp3” I get no error message. The command prompt just come back after 5-6 seconds. I never hear any sound on my Sonos

That was a typo in my post , of course “smarthome:say play doorbell.mp3” isn’t playing anything it should have read “smarthome:audio play doorbell.mp3”.

Changed my post above!