Das ist die sonos.things, die ich angelegt habe, nachdem das auto discovery in anderen threads als Problem genannt wurde:
Code: Alles auswählen
Thing sonos:CONNECTAMP:RINCON_5CAAFD000B0001400 [udn="RINCON_5CAAFDEABB0001400", refresh=60, notificationVolume=25]
Thing sonos:PLAY1:RINCON_B8E00046E0C01400 [udn="RINCON_B8E00046E0C01400", refresh=60, notificationVolume=25]
Thing sonos:Beam:RINCON_48A6000EC6E01400 [udn="RINCON_48A6000EC6E01400", refresh=60, notificationVolume=25]
In der Console lässt sich aber mit keinem der Sonos das Audio ausgeben. Die doorbell.mp3 liegt im Standard-Ordner sounds.
Exemplarisch ein paar items eines things:
Code: Alles auswählen
Player SonosBeamKuche_Fernbedienung "Sonos Beam" <player> (gSonos,EG_Kueche) { channel="sonos:Beam:RINCON_48A6000EC6E01400:control" }
Dimmer SonosBeamKuche_Lautstarke "Volume [%.1f %%]" <soundvolume> (gSonos,EG_Kueche) { channel="sonos:Beam:RINCON_48A6000EC6E01400:volume" }
Switch SonosBeamKuche_Stummschalten "Mute" <soundvolume_mute> (gSonos,EG_Kueche) { channel="sonos:Beam:RINCON_48A6000EC6E01400:mute" }
Switch SonosBeamKuche_Shuffle "Shuffle" <sonos_shuffle> (gSonos,EG_Kueche) { channel="sonos:Beam:RINCON_48A6000EC6E01400:shuffle" }
String SonosBeamKuche_repeat "Repeat [%s]" <text> (gSonos,EG_Kueche) { channel="sonos:Beam:RINCON_48A6000EC6E01400:repeat" }
Image SonosBeamKuche_Coverbild "Cover" <image> (gSonos,EG_Kueche) { channel="sonos:Beam:RINCON_48A6000EC6E01400:currentalbumart" }
String SonosBeamKuche_Kunstler "Künstler" <text> (gSonos,EG_Kueche) { channel="sonos:Beam:RINCON_48A6000EC6E01400:currentartist" }
String SonosBeamKuche_Album "Album" <text> (gSonos,EG_Kueche) { channel="sonos:Beam:RINCON_48A6000EC6E01400:currentalbum" }
String SonosBeamKucheState "Status" <text> (gSonos,EG_Kueche) { channel="sonos:Beam:RINCON_48A6000EC6E01400:state" }
String SonosBeamKucheTitle "Titel" <text> (gSonos,EG_Kueche) { channel="sonos:Beam:RINCON_48A6000EC6E01400:currenttitle" }
String SonosBeamKucheNotification "Notification Sound [%s]" <text> (gSonos,EG_Kueche) { channel="sonos:Beam:RINCON_48A6000EC6E01400:notificationsound" }
Das funktioniert alles.
Das ist die rule zum Türgong:
Code: Alles auswählen
rule "Es klingelt an der Haustür"
when
Item Doorbell_Pressed changed from OFF to ON
then
logInfo("Doorbird", "Es hat geklingelt. Jemand steht vor der Tür")
SonosBeamKucheNotification.sendCommand(ON)
// playSound("sonos:Beam: RINCON_48A6000EC6E01400", "doorbell.mp3") //hat auch nicht funktioniert
end
Im Binding habe ich die doorbell.mp3 als Callback URL über
http://192.168.1.30:8080/static/doorbell.mp3 zur Verfügung gestellt.
Wobei ich zugeben muss, dass ich die Variante ziemlich unflexibel finde, weil man nur eine URL angeben kann. Da wäre die Lösung per playSound wesentlich besser nutzbar. Soweit ich verstanden habe, soll openhab den playSound ja trotzdem an den Notification-Kanal des Sonos übergeben. Es sollte also genauso funktionieren.
In der Doku (oder irgendwo drum herum) habe ich unterschiedliche Angaben zum Sonos Binding gelesen. Der Type von notificationsound ist ja string. Daher dachte ich zuerst, ich kann im sendCommand den Pfad zur mp3 mitgeben. Da kommt aber im log, dass man nur onofftype verwenden dürfe. Da wundert mich dann aber der item-type. Auf type=Switch umzustellen hilft aber auch nicht.
Im den logs sieht das dann so aus, wenn ich die Klingel betätige.
openhab.log
Code: Alles auswählen
2022-02-08 23:00:11.032 [INFO ] [g.openhab.core.model.script.Doorbird] - Es hat geklingelt. Jemand steht vor der Tür
event.log
Code: Alles auswählen
2022-02-08 23:00:11.036 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'SonosAmpBueroNotification' received command ON
2022-02-08 23:00:11.037 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'SonosAmpBueroNotification' predicted to become ON
2022-02-08 23:00:11.037 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'SonosAmpBueroNotification' changed from OFF to ON
Danke schon mal!