Seite 2 von 3
Re: Sonos Doorbell Rule
Verfasst: 24. Nov 2024 10:33
von astrong
kurzes Update,
also durch BLOCKLY ist das script echt "launisch". Mal gehts, mal nicht... das ist kein Zustand.
@udo,
ich bin mit DSL nicht so fitt, könntest du mir u.g. script in deine IF Schleife zusammenfassen.
Ich möchte das doorbell.mp3 auf BEIDEN Sonos gleichzeitig gespielt wird.
Code: Alles auswählen
configuration: {}
triggers:
- id: "1"
configuration:
itemName: Binareingang_Klingel_EG_Binareingang_Turklingel
state: CLOSED
type: core.ItemStateChangeTrigger
conditions: []
actions:
- inputs: {}
id: "2"
configuration:
type: application/vnd.openhab.dsl.rule
script: >
var PercentType vol = 45
if((OG_Jalousieaktor_4_Jalousie_OG_Kind_Sud.state as Number) > 80) vol =
25
playSound('doorbell.mp3', vol)
type: script.ScriptAction
- inputs: {}
id: "3"
configuration:
sink: sonos:Era100:RINCON_F0F6C1A58B5401400
sound: doorbell.mp3
type: media.PlayAction
- id: "4"
configuration:
sound: doorbell.mp3
sink: sonos:OneSL:RINCON_C438757317E001400
type: media.PlayAction
vielen Dank!
Re: Sonos Doorbell Rule
Verfasst: 24. Nov 2024 12:24
von udo1toni
So sollte das funktionieren:
Code: Alles auswählen
configuration: {}
triggers:
- id: "1"
configuration:
itemName: Binareingang_Klingel_EG_Binareingang_Turklingel
state: CLOSED
type: core.ItemStateChangeTrigger
conditions: []
actions:
- inputs: {}
id: "2"
configuration:
type: application/vnd.openhab.dsl.rule
script: >
var PercentType vol = 45
if((OG_Jalousieaktor_4_Jalousie_OG_Kind_Sud.state as Number) > 80)
vol = 25
val strSound = "doorbell.mp3"
val strSonos1 = "sonos:Era100:RINCON_F0F6C1A58B5401400"
val strSonos2 = "sonos:OneSL:RINCON_C438757317E001400"
playSound(strSonos1,strSound, vol)
playSound(strSonos2,strSound, vol)
type: script.ScriptAction
Re: Sonos Doorbell Rule
Verfasst: 25. Nov 2024 19:39
von astrong
Code: Alles auswählen
1. Type mismatch: cannot convert from int to PercentType; line 1, column 22, length 2
2. Type mismatch: cannot convert from int to PercentType; line 2, column 103, length 2
da passen die variablen Typen irgendwo nicht.
Re: Sonos Doorbell Rule
Verfasst: 25. Nov 2024 19:45
von peter-pan
evtl. so: var PercentType vol = 45.0
Re: Sonos Doorbell Rule
Verfasst: 25. Nov 2024 20:07
von astrong
ich habe jetzt einiges probiert, aber ich bekomme keine vollwertigen Zahlen hin.
Irgendwo kommt immer wieder die Meldung
" Script execution of rule with UID 'f8a56dc6f7' failed: Volume value must be in the range [0;1]!"
Re: Sonos Doorbell Rule
Verfasst: 25. Nov 2024 20:16
von peter-pan
Noch 'ne Idee: var PercentType vol = 0.45
Re: Sonos Doorbell Rule
Verfasst: 25. Nov 2024 20:20
von astrong
Code: Alles auswählen
configuration: {}
triggers:
- id: "1"
configuration:
itemName: Binareingang_Klingel_EG_Binareingang_Turklingel
state: CLOSED
type: core.ItemStateChangeTrigger
conditions: []
actions:
- inputs: {}
id: "2"
configuration:
type: application/vnd.openhab.dsl.rule
script: |
var PercentType vol = new PercentType(45)
if((OG_Jalousieaktor_4_Jalousie_OG_Kind_Sud.state as Number) > 80) {
vol = new PercentType(5)
playSound("sonos:Era100:RINCON_F0F6C1A58B5401400","doorbell.mp3",vol)
playSound("sonos:OneSL:RINCON_C438757317E001400","doorbell.mp3",vol)
}
playSound("sonos:Era100:RINCON_F0F6C1A58B5401400","doorbell.mp3",vol)
playSound("sonos:OneSL:RINCON_C438757317E001400","doorbell.mp3",vol)
type: script.ScriptAction
jetzt habe ich das "prozent" Problem dank chatgpt endlich gelöst, ABER... aus irgendeinem Grund werden nun "ALLE" Sonos Geräte gestoppt und die doorbell.mp3 wird mehrmals abgespielt... irgendwie versteh ichs nicht...
diese Xtend Script Sprache ist aber auch irgendwie mist... gibts kein bash oder python support dafür

?
Re: Sonos Doorbell Rule
Verfasst: 25. Nov 2024 20:21
von astrong
Code: Alles auswählen
2024-11-25 20:21:20.247 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Sonos_One_SL_Elternbad_Lautstarke' changed from 0 to 5
2024-11-25 20:21:20.266 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Sonos_One_SL_Elternbad_Fernbedienung' changed from PLAY to PAUSE
2024-11-25 20:21:20.266 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Sonos_Era_100_Wohnzimmer_Fernbedienung' changed from PLAY to PAUSE
2024-11-25 20:21:20.266 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Sonos_Era_100_Esszimmer_Fernbedienung' changed from PLAY to PAUSE
2024-11-25 20:21:23.714 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Sonos_One_SL_Elternbad_Fernbedienung' changed from PAUSE to PLAY
2024-11-25 20:21:23.714 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Sonos_Era_100_Wohnzimmer_Fernbedienung' changed from PAUSE to PLAY
2024-11-25 20:21:23.714 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Sonos_Era_100_Esszimmer_Fernbedienung' changed from PAUSE to PLAY
2024-11-25 20:21:28.846 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Sonos_One_SL_Elternbad_Fernbedienung' changed from PLAY to PAUSE
2024-11-25 20:21:28.846 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Sonos_Era_100_Wohnzimmer_Fernbedienung' changed from PLAY to PAUSE
2024-11-25 20:21:28.846 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Sonos_Era_100_Esszimmer_Fernbedienung' changed from PLAY to PAUSE
Re: Sonos Doorbell Rule
Verfasst: 25. Nov 2024 21:20
von peter-pan
Also ich hab mal ein bisschen im Multimedia-Binding geschmökert und mir eine kleine DSL-Regel gebastelt(ohne" Drumherum"). Und da wird nur ein bestimmter Speaker angesprochen.
Die Regel:
Code: Alles auswählen
rule "doorbell ring sonos"
when
Item Dummy_4 changed to ON
then
var volume = 15
playSound("sonos:PLAY1:RINCON_949F3E157B8401400", "doorbell.mp3", new PercentType(volume)) // test
end
Die Lautstärke wird auf den Wert eingestellt und es ertönt auch nur einmal der Gong. Es dauert dann ein paar Sekunden, aber dann wird wieder die laufende Musik in der ursprünglichen Lautstärke weiter gespielt oder wenn keine Musik läuft, eben nur die Klingel.
Re: Sonos Doorbell Rule
Verfasst: 26. Nov 2024 01:51
von udo1toni
Warum gibst Du denn die Play-Befehle zweimal an? Und warum, um Himmels Willen, fragst Du ChatGPT? Ist Dir klar, wie ChatGPT funktioniert? Das Teil ist dumm. Es handelt sich um eine Suchmaschine, die mit natürlicher Sprache agiert, sonst nichts. Da ungefähr 90 % der Codeschnipsel, die im Internet für openHAB bereitstehen fehlerhaft sind, müssen auch die Antworten von ChatGPT zu 90 % (eher mehr...) falsch sein.
new PercentType() hilft allerdings tatsächlich, aber der Rest der Regel sollte eher unberührt bleiben, also am ehesten so:
Code: Alles auswählen
configuration: {}
triggers:
- id: "1"
configuration:
itemName: Binareingang_Klingel_EG_Binareingang_Turklingel
state: CLOSED
type: core.ItemStateChangeTrigger
conditions: []
actions:
- inputs: {}
id: "2"
configuration:
type: application/vnd.openhab.dsl.rule
script: |
var vol = 45)
if((OG_Jalousieaktor_4_Jalousie_OG_Kind_Sud.state as Number) > 80)
vol = 5
playSound("sonos:Era100:RINCON_F0F6C1A58B5401400","doorbell.mp3",new PercentType(vol))
playSound("sonos:OneSL:RINCON_C438757317E001400","doorbell.mp3",new PercentType(vol))
type: script.ScriptAction