BOSE SoundTouch integrieren CURL / HTTPMOD

Begonnen von Freibeuter, 09 Januar 2015, 12:24:00

Vorheriges Thema - Nächstes Thema

Freibeuter

Hallo,
ich versuche meine meine BOSE SoundTouch Portable zu integrieren.
Bei den Kollegen von IP-Symcon habe ich schon etwas gefunden:
http://www.ip-symcon.de/forum/threads/26554-Bose-Soundtouch-in-IPS-einbinden?highlight=soundtouch
Dort wird jedoch CURL verwendet und das läuft ja nicht ohne Tool auf der FritzBox.

Sieht hier jemand einen Möglichkeit wie man das mit FHEM Bordmitteln realisieren kann?
Ich bräuchte nur einen groben Fahrplan, dann würde ich mich gern selber an ein Modul machen.

Freibeuter

Bin schon etwas weiter, es braucht kein Modul denn es ist wohl mit HTTPMOD gut zu machen.

Ein einfaches Beispiel ist :
curl -d '<volume>33</volume>' http://192.168.2.34:8090/volume

Mein  Versuch
define BOSE HTTPMOD 192.168.2.34:8090/volume 600
attr BOSE userattr set01Data set01Hint set01Max set01Min set01Name set01URL setHeader1 verbose
attr BOSE room BOSE
attr BOSE set01Data <volume>$val</volume>
attr BOSE set01Hint 6,10,20,30
attr BOSE set01Max 30
attr BOSE set01Min 6
attr BOSE set01Name Volume
attr BOSE set01URL http://192.168.2.34:8090/volume
attr BOSE setHeader1 Content-type: text/xml
attr BOSE verbose 3



jedoch wird die Lautstärke immer auf 0 gesetzt und als buf bekomme ich
HTTP/1.1 200 OK Content-Type: text/xml Date: Fri, 09 Jan 2015 20:38:25 GMT Expires: Thu, 26 Oct 1995 00:00:00 GMT Last-Modified: Fri, 09 Jan 2015 20:38:25 GMT Pragma: no-cache Server: Allegro-Software-RomPager/5.40b1 <?xml version="1.0" encoding="UTF-8" ?><status>/volume</status>

eigentlich sollte dort:

<?xml version="1.0" encoding="UTF-8" ?><volume deviceID="000C8A965346"><targetvolume>10</targetvolume><actualvolume>10</actualvolume><muteenabled>false</muteenabled></volume>
kommen ...

ChiliApple

Hast du es geschafft zu implementieren? Habe auch eine Portable und würde auch gern

Grüße
:: FHEM last Version
:: Raspberry 3 mit Stretch
:: HWLAN
:: MAX
:: 3xSCC  Fw by björnh :: PiFace Digital 1

Freibeuter

Hallo, hier meine Konfiguration:

define BOSE_Volume HTTPMOD http://192.168.2.34:8090/volume 60
attr BOSE_Volume userattr disable event-on-change-reading readingsName1 readingsRegex1 requestHeader.* set01Data set01Hint set01Map set01Max set01Min set01Name set01URL setHeader1 stateFormat verbose webCmd
attr BOSE_Volume disable 1
attr BOSE_Volume event-on-change-reading .*
attr BOSE_Volume group 5 Bose
attr BOSE_Volume readingsName1 Volume
attr BOSE_Volume readingsRegex1 <actualvolume>(\d+)</actualvolume>
attr BOSE_Volume requestHeader.* Content-type: text/xml
attr BOSE_Volume room 5_Multimedia
attr BOSE_Volume set01Data <volume>$val</volume>
attr BOSE_Volume set01Hint 0,10,20,30,40,50,60,70,80,90,100
attr BOSE_Volume set01Max 100
attr BOSE_Volume set01Min 0
attr BOSE_Volume set01Name set_Volume
attr BOSE_Volume set01URL http://192.168.2.34:8090/volume
attr BOSE_Volume setHeader1 Content-type: text/xml
attr BOSE_Volume stateFormat Volume
attr BOSE_Volume verbose 3
attr BOSE_Volume webCmd set_Volume



define BOSE_Playing HTTPMOD http://192.168.2.34:8090/now_playing 10
attr BOSE_Playing userattr disable readingsName1 readingsRegex1 requestHeader.* set01Data set01Hint set01Map set01Name set01URL setHeader1 stateFormat verbose webCmd
attr BOSE_Playing disable 1
attr BOSE_Playing group 5 Bose
attr BOSE_Playing readingsName1 Playing
attr BOSE_Playing readingsRegex1 <itemName>(.*)</itemName>
attr BOSE_Playing requestHeader.* Content-type: text/xml
attr BOSE_Playing room 5_Multimedia
attr BOSE_Playing set01Data <ContentItem source="INTERNET_RADIO" location="27731" sourceAccount="" isPresetable="true"><itemName>Radio Paloma</itemName></ContentItem>
attr BOSE_Playing set01Hint vorher
attr BOSE_Playing set01Map vorher:vorher
attr BOSE_Playing set01Name set_Playing
attr BOSE_Playing set01URL http://192.168.2.34:8090/select
attr BOSE_Playing setHeader1 Content-type: text/xml
attr BOSE_Playing stateFormat Playing
attr BOSE_Playing verbose 3
attr BOSE_Playing webCmd set_Playing



define BOSE_Presets HTTPMOD http://192.168.2.34:8090/presets 300
attr BOSE_Presets userattr disable readingsName1 readingsName2 readingsName3 readingsName4 readingsName5 readingsName6 readingsRegex1 readingsRegex2 readingsRegex3 readingsRegex4 readingsRegex5 readingsRegex6 stateFormat verbose
attr BOSE_Presets disable 1
attr BOSE_Presets group 5 Bose
attr BOSE_Presets readingsName1 Preset_1
attr BOSE_Presets readingsName2 Preset_2
attr BOSE_Presets readingsName3 Preset_3
attr BOSE_Presets readingsName4 Preset_4
attr BOSE_Presets readingsName5 Preset_5
attr BOSE_Presets readingsName6 Preset_6
attr BOSE_Presets readingsRegex1 <preset id="1".*(<ContentItem.*)<preset id="2"
attr BOSE_Presets readingsRegex2 <preset id="2".*(<ContentItem.*)<preset id="3"
attr BOSE_Presets readingsRegex3 <preset id="3".*(<ContentItem.*)<preset id="4"
attr BOSE_Presets readingsRegex4 <preset id="4".*(<ContentItem.*)<preset id="5"
attr BOSE_Presets readingsRegex5 <preset id="5".*(<ContentItem.*)<preset id="6"
attr BOSE_Presets readingsRegex6 <preset id="6".*(<ContentItem.*)</preset></presets>
attr BOSE_Presets room 5_Multimedia
attr BOSE_Presets stateFormat Preset_1
attr BOSE_Presets verbose 3


define BOSE_Key HTTPMOD http://192.168.2.34:8090/key 300
attr BOSE_Key userattr disable event-on-change-reading readingsName1 readingsRegex1 requestHeader.* set01Data set01Hint set01Map set01Max set01Min set01Name set01URL set02Data set02Hint set02Map set02Name set02URL set1Map setHeader1 setHeader2 stateFormat verbose webCmd
attr BOSE_Key disable 1
attr BOSE_Key event-on-change-reading .*
attr BOSE_Key group 5 Bose
attr BOSE_Key requestHeader.* Content-type: text/xml
attr BOSE_Key room 5_Multimedia
attr BOSE_Key set01Data <key state="press" sender="Gabbo">$val</key>
attr BOSE_Key set01Hint 1,AUX,POWER,PRESET_1,PRESET_2,PRESET_3,PRESET_4,PRESET_5,PRESET_6,STOP,PLAY,VOLUME_DOWN,VOLUME_UP
attr BOSE_Key set01Map POWER:POWER,PRESET_1:PRESET_1,PRESET_2:PRESET_2,PRESET_3:PRESET_3,PRESET_4:PRESET_4,PRESET_5:PRESET_5,PRESET_6:PRESET_6,AUX:AUX,STOP:STOP,PLAY:PLAY,VOLUME_DOWN:VOLUME_DOWN,VOLUME_UP:VOLUME_UP
attr BOSE_Key set01Name press
attr BOSE_Key set01URL http://192.168.2.34:8090/key
attr BOSE_Key set02Data <key state="release" sender="Gabbo">$val</key>
attr BOSE_Key set02Hint 0,AUX,POWER,PRESET_1,PRESET_2,PRESET_3,PRESET_4,PRESET_5,PRESET_6,STOP,PLAY,VOLUME_DOWN,VOLUME_UP
attr BOSE_Key set02Map POWER:POWER,PRESET_1:PRESET_1,PRESET_2:PRESET_2,PRESET_3:PRESET_3,PRESET_4:PRESET_4,PRESET_5:PRESET_5,PRESET_6:PRESET_6,AUX:AUX,STOP:STOP,PLAY:PLAY,VOLUME_DOWN:VOLUME_DOWN,VOLUME_UP:VOLUME_UP
attr BOSE_Key set02Name release
attr BOSE_Key set02URL http://192.168.2.34:8090/key
attr BOSE_Key setHeader2 Content-type: text/xml


# <key state="press" sender="Gabbo">POWER</key>'
# <key state="release" sender="Gabbo">POWER</key>'
#KEYS POWER PRESET_1 STOP PLAY VOLUME_DOWN VOLUME_UP



define BOSE dummy
attr BOSE group 5 Bose
attr BOSE room 0_Hoesel,5_Multimedia
attr BOSE setList Vol:slider,0,1,100
attr BOSE webCmd Off:P1:P2:P3:P4:P5:P6:AUX:Stop:Power:Reset:Play:↑:↓:Vol

define n_BOSE notify BOSE:.* {\
{Log 3, "BOSE %"}\
        if("%" eq "Off" ) { \
                my $vorherQ = GetHttpFile("192.168.2.34:8090", "/now_playing");;\
                my $vorhers = "ERROR";;\
                my $vorher = "ERROR";;\
                if($vorhers = $vorherQ =~ /(<ContentItem.*<\/ContentItem>)/igs ){\
                    $vorher = "$1";;\
                }\
                if($vorhers = $vorherQ =~ /<ContentItem source=\"(STANDBY)/igs ){\
                          $vorher = "$1";;\
                }\
                if($vorhers = $vorherQ =~ /(INVALID_SOURCE)/igs ){\
                        $vorher = "INVALID_SOURCE";;\
                }\
               if("$vorher" ne "STANDBY" ) { \
                    {fhem("set BOSE_Key press POWER;;sleep 0.5 ;; set BOSE_Key release POWER")};;\
               }\
        }\
        if("%" eq "Power" ) { \
                {fhem("set BOSE_Key press POWER;;sleep 0.5 ;; set BOSE_Key release POWER")};;\
        }\
        if("%" eq "Reset" ) { \
                {fhem("set BOSE_Key press AUX")};;\
        }\
        if("%" eq "AUX" ) { \
                {fhem("set BOSE_Key press AUX;;sleep 0.5 ;; set BOSE_Key release AUX")};;\
        }\
        if("%" eq "P1") { \
                {fhem("set BOSE_Key press PRESET_1;;sleep 0.5;; set BOSE_Key release PRESET_1") };;\
        }\
        if("%" eq "P2" ) { \
                {fhem("set BOSE_Key press PRESET_2;;sleep 0.5;; set BOSE_Key release PRESET_2") };;\
        }\
        if("%" eq "P3" ) { \
                {fhem("set BOSE_Key press PRESET_3;;sleep 0.5;; set BOSE_Key release PRESET_3") };;\
        }\
        if("%" eq "P4" ) { \
                {fhem("set BOSE_Key press PRESET_4;;sleep 0.5;; set BOSE_Key release PRESET_4") };;\
        }\
        if("%" eq "P5" ) { \
                {fhem("set BOSE_Key press PRESET_5;;sleep 0.5;; set BOSE_Key release PRESET_5") };;\
        }\
        if("%" eq "P6" ) { \
                {fhem("set BOSE_Key press PRESET_6;;sleep 0.5;; set BOSE_Key release PRESET_6") };;\
        }\
        if("%" eq "Play" ) { \
                {fhem("set BOSE_Key press PLAY;;sleep 0.5;; set BOSE_Key release PLAY") };;\
        }\
        if("%" eq "Stop" ) { \
                {fhem("set BOSE_Key press STOP;;sleep 0.5;; set BOSE_Key release STOP") };;\
        }\
        if("%" eq "↓" ) { \
                {fhem("set BOSE_Key press VOLUME_DOWN;;sleep 0.5;; set BOSE_Key release VOLUME_DOWN") };;\
        }      \
        if("%" eq "↑" ) { \
                {fhem("set BOSE_Key press VOLUME_UP;;sleep 0.5;; set BOSE_Key release VOLUME_UP") };;\
        }\
        if("%" =~ m/Vol/ ) { \
                my $Volume = substr("%",3,length("%"));;\
                {fhem("set BOSE_Volume set_Volume $Volume") };;\
        }\
}
attr n_BOSE group 5 Bose
attr n_BOSE room 5_Multimedia

define n_BOSE_Volume notify BOSE_Volume:Volume:.* {\
               {fhem("set BOSE Vol $EVTPART1")};;\
        }
attr n_BOSE_Volume group 5 Bose
attr n_BOSE_Volume room 5_Multimedia

Freibeuter

Hallo,
freut mich das es auch bei Dir klappt :-)
Ich habe daran nicht weiter gebastelt, für meine Anwendung reicht es so aus.

Ein Ausschalttimer könnte so aussehen:
set BOSE P1;sleep 1200;set BOSE Off

Gruß
Peter F.




Treibhaus

Hallo Freibeuter,

ich habe eine Frage, da ich es heute Abend auch mal probieren möchte.
Hast du deine Integration in der fhem.cfg eingetragen oder als extra modul abgelegt ?

Hast schon jemand Erfahrung mit mehreren Bose Soundtouch Geräten ? Multiroomsystem ?

Gruß Jörg
Signatur:
Odroid -C2 + BSC EnOcean USB 300-TCM310 + HM485
Enocean-Taster-Fensterkontakt,-Bewegungsmelder
HM-Module über 3 Etagen + Garage/Garten
+ 1-wired Temp-Sensoren, S0-Schnittstellen + RHASSPY-Spracherkennung

Freibeuter

Hallo,
ob Du es in fhem.cfg oder in ein bose.cfg schreibst ist dir überlassen, ggf an die include Funktion denken !


Seit einigen tagen muss das "disable 1" aus den httpmod entfernt werden sonst lüppt datt nicht mehr, und dann bitte auch das Intervall auf größere Werte setzen.
Habe nur eine Box, daher keine Erfahrung mit "multi".
Viel Spaß damit heute Abend

Der Freibeuter

Treibhaus

HI Sonic,

die per DHCP vergeben IP kann man in der Fritzbox per MAC-Adresse fest zuordnen.

Gruß Jörg
Signatur:
Odroid -C2 + BSC EnOcean USB 300-TCM310 + HM485
Enocean-Taster-Fensterkontakt,-Bewegungsmelder
HM-Module über 3 Etagen + Garage/Garten
+ 1-wired Temp-Sensoren, S0-Schnittstellen + RHASSPY-Spracherkennung

optimist

Hallo,
bin Neu hier und habe heute gleich mal mit dem Code von Freibeuter meine beiden Bose Soundtouch in FEHM integriert.
Dad läuft auf Anhieb Super !
Danke an Freibeuter für den Code.

Wäre doch richtig den Code fest in FHEM zu als Modul zu integrieren ?
Die Bose Tröten klingen besser als die SONOS finde ich.
Da Sonos schon in Fhem intergriert ist, sollte auch ein Modul für Bose rein !

Freibeuter Hau Rein und mach dad Ding !

danke nochmal


Sonic

Guten Morgen,
ich habe folgendes Problem. Nach Update auf Fhem 5.7 funkioniert leider der Bose Code von Freibeuter nicht mehr.
Ich habe verstanden, das im Notify die % durch $ erstetzt werden müssen.
Das habe ich gemacht, trotzdem keine Funktion mehr.
Sogar hängt sich Fhem teilweise auf so das der Raspi neu gestartet werden muss.

Ich bin Perl Anfänger und komme hier nicht weiter.

Kann mir jemand helfen ?

vielen Dank

krikan

Zitat von: Sonic am 11 Dezember 2015, 07:24:27
Ich habe verstanden, das im Notify die % durch $ erstetzt werden müssen.
Nein.
% durch $EVENT.
Details findet man: http://forum.fhem.de/index.php/topic,44094.0.html
Gruß, Christian

Sonic

Danke, ich konnte es soweit einkreisen.

Das notify funktioniert Aufgrund diesen Eintrages nicht mehr !
        if("$" =~ m/Vol/ ) { \
                my $Volume = substr("$",3,length("$"));;\
                {fhem("set BOSEW_Volume set_Volume $Volume") };;\
        }

Es scheint so, das nach dem Update die ~ nicht mehr erkannt wird. Oder kann mir jemand helfen, was in Version 5.7 bei diesem Code nicht mehr funktioniert ?

vielen Dank im voraus
Sonic

fiedel

#12
Ich hab es unten mal "verbessert". Alle "%", bzw. jetzt deine einzelnen (falsch ersetzten) "$" musst du so wie jetzt unten durch "$EVENT" ersetzen.

Gruß
Frank


Zitat von: Sonic am 11 Dezember 2015, 11:23:16
Danke, ich konnte es soweit einkreisen.

Das notify funktioniert Aufgrund diesen Eintrages nicht mehr !
        if("$EVENT" =~ m/Vol/ ) { \
                my $Volume = substr("$EVENT",3,length("$"));;\
                {fhem("set BOSEW_Volume set_Volume $Volume") };;\
        }

Es scheint so, das nach dem Update die ~ nicht mehr erkannt wird. Oder kann mir jemand helfen, was in Version 5.7 bei diesem Code nicht mehr funktioniert ?

vielen Dank im voraus
Sonic
FeatureLevel: 6.1 auf Wyse N03D ; Deb. 11 ; Perl: v5.14.2 ; IO: HM-MOD-RPI-PCB + VCCU|CUL 868 V 1.66|LinkUSBi |TEK603
HM: SEC-SCO|SCI-3-FM|LC-SW4-PCB|ES-PMSW1-PL|RC-4-2|SEN-MDIR-O|SEC-WDS-2
CUL: HMS100TF|FS20 S4A-2 ; OWDevice: DS18S20|DS2401|DS2406|DS2423

Sonic

Danke Frank,

alles klar. Klappt jetzt !

Vielen DANK nochmal

dominik

Hallo zusammen,

zur Info...ich habe mit den vorhandenen Informationen mal begonnen ein Modul zu bauen. Gerne mitarbeiten :)
http://forum.fhem.de/index.php/topic,46838.0.html
fhempy -  https://github.com/fhempy/fhempy: GoogleCast, Tuya, UPnP, Ring, EQ3BT, Nespresso, Xiaomi, Spotify, Object Detection, ...
Kaffeespende: https://paypal.me/todominik