Sonos save and restore

Hello,

I’m using openhab2 beta 4 in my Ubuntu 14.04 server. I have Sonos PLAYBAR connected to my TV and openhab.

I have following code in my Rules:

sendCommand(SonosSave,ON)
sendCommand(SonosVolume,15)
sendCommand(SonosFavorite,"kotona")
Thread::sleep(3000)
sendCommand(SonosRestore,ON)

This works when I’m playing radio. So it will play mp3 and return to the radio station after 3 sec.

But if I’m using my TV (that is connected via optical cable) this code will play my mp3 twice (and the second time with orginal volume) and not returning to TV sound.

I checked the code (was not able find reason) and also did this

openhab> log:set DEBUG org.openhab.binding.sonos
openhab> log:list
Logger                                                      | Level
-------------------------------------------------------------------
ROOT                                                        | INFO
javax.jmdns                                                 | ERROR
org.eclipse.smarthome                                       | INFO
org.jupnp                                                   | ERROR
org.openhab                                                 | INFO
org.openhab.binding.sonos                                   | DEBUG
org.ops4j.pax.web.service.jetty.internal.JettyServerWrapper | ERROR
smarthome.event                                             | INFO
smarthome.event.InboxUpdatedEvent                           | ERROR
smarthome.event.ItemStateEvent                              | ERROR
smarthome.event.ThingStatusInfoEvent 

But I was not able to see any markings for org.openhab.binding.sonos in the log files.

Help would be appreciated.

–Ari

I found this that is probably relate to my issue.

–Ari

Hi Ari,

Can I ask, did you declare SonosSave etc as items in an .items file?
If so, can you share the items with me?

Or is it possible to use the channels directly?

Cheers,
Per

Hello,

here are my sonos items

Switch SonosSave "Sonos save" (Sonos)  {channel="sonos:PLAYBAR:RINCON_5CAAFDA1631XXXXXX:save"} 
Switch SonosRestore  "Sonos restore"  (Sonos){channel="sonos:PLAYBAR:RINCON_5CAAFDA1631XXXXXX:restore"} 

Thanks!

I looked throught the event logfile and found that all channels added by paper-ui automatically seems to get an item as well.
For example my channel “sonos:PLAYBAR:RINCON_B8E93779243501400:save” is also an item “sonos_PLAYBAR_RINCON_B8E93779243501400_save”.

My mistake was that I used the channel-name in the rules and nothing happened,

So it seems not necsessary to declare the items again (unless I want a shorter name to use in rules and other places I guess)

I have acruallu turned the auto creation off items off. Mainly for following reasons

  1. I don’t want to have items in my items db that I’m not using
  2. I really like to name my items because then the rules are more maintainable / readable
  3. I’m having a version control for my items. Easier to back when I mess somthing up