Sonos steuern

Begonnen von Will, 05 Januar 2013, 15:51:12

Vorheriges Thema - Nächstes Thema

Spartacus

Zitat von: Reinerlein am 18 Februar 2015, 13:14:08
Hi Christian,

das einfachste wird ein userReading sein, wo der Enabled-Wert deines gesuchten Alarms direkt enthalten ist, und diesen dann als Zusatzbedingung mit in das DOIF.

Hier das userReading im Sonosplayer-Device:

Alarm674Enabled:AlarmList { eval(ReadingsVal('OG.kz.SON.ZP_S1', 'AlarmList', '{}'))->{674}{Enabled} }

Hi Reiner,
danke schön! Ja, so hatte ich mir das vorgestellt!

In deinem DOIF muss das doch nur noch als Zusatzbedingung dazu, oder?

(([state.NRW.FerienClone.dum] or [hl.01.Feiertag.cdm:today] ne "none") and [OG.kz.SON.ZP_S1:Alarm674Enabled] eq "1")
((set OG.kz.SON.ZP_S1 Alarm Update 674 {Volume => 2, Enabled => 0}))
DOELSE
((set OG.kz.SON.ZP_S1 Alarm Update 674 {Volume => 2, Enabled => 1}))
Jetzt hat DOIF auch einen Trigger auf die Alarm-Änderung am Controller...
Ob es das macht, was du möchtest, solltest du nochmal komtrollieren :)

Grüße
Reiner
Hi Reiner,
Danke schön! Genauso habe ich mir das vorgestellt! Der Trigger im DOIF sollte auch so funktionieren! Jetzt baue ich noch die Visualisierung drumherum, damit man die Wecker aller Sonos-Devices im Überblick hat!
Nochmal Danke,
Christian
Fhem-System: 1 x raspberry PI Typ B, 1 x enOcean PI Typ B | Enocean: PTM210, FMS61NP, FAM14, 2 x FSR14-4x, FTS14-EM | LaCrosse: 2 x TX29D über Jeelink V3 | 1-Wire: 2 x DS18B20 über DS9490R

Reinerlein

Hi Andre,

ich habe das nochmal im Code geprüft. Eigentlich holt das Sonos-Modul beim Erkennen (die einzige Stelle, an der 'appeared' gesetzt wird) die Informationen über Abspielzustand und Titel direkt neu vom Player und setzt diese gleichzeitig (in einem Bulkupdate) mit "Presence".
Das bedeutet, dass beim Start des Moduls erkennbar sein sollte, ob der Player neugestartet wurde (der hat dann ja keine Titelinformationen), oder nur das Modul/Fhem (dann gibt es u.U. Titelinformationen).

Ich werde mal versuchen, das nachzustellen...
Kannst du vielleicht mal dein Notify dazu hier posten? Hat dein Player auch den von dir erwarteten Zustand?

Grüße
Reiner

justme1968

mein sonosAppeared notify schaut so aus:sonos_.*:presence:.appeared {
  Log 3, ">$NAME< >$EVENT< ".ReadingsVal($NAME, "currentTrackURI", "undef");
  if( !ReadingsVal($NAME, "currentTrackURI", undef) ) {
    Log 3, "$NAME: do init";
    fhem "sleep 1; set $NAME Volume 5; set $NAME LoadRadio SWR3%20Elchradio";
  } else {
    Log 3, "$NAME: do nothing";
  }


über die log zeilen sehe ich das wärend des notify currentTrackURI noch gefüllt ist und das notify folglich nichts tut. wenn ich etwas später nachschaue ist das reading nicht mehr gefüllt.

erst mit einem zusätzlichen notify sonosDisappeared:sonos_.*:presence:.disappeared deletereading $NAME currentTrackURI geht dann alles wie erwartet.

gruss
   andre
hue, tradfri, alexa-fhem, homebridge-fhem, LightScene, readingsGroup, ...

https://github.com/sponsors/justme-1968

Reinerlein

Hi Andre,

manchmal sollte man die Dinge tatsächlich mal selber ausführen  :-[

Ich habe den Fehler gefunden, und eine Korrektur gerade eingecheckt. Das kann aber noch nie funktioniert haben, da der Fehler grundsätzlicher Natur war...

Wie immer: Jetzt im SVN oder ab Morgen im Update...

Grüße
Reiner

justme1968

danke :)

gruss
  andre
hue, tradfri, alexa-fhem, homebridge-fhem, LightScene, readingsGroup, ...

https://github.com/sponsors/justme-1968

Mopedpaul

Hallo,
bin ja begeistert, dass die Sonos Systeme so perfekt in FHEM eingebunden werden. Daher hatte ich mich auch entschlossen die Systeme hier einzubinden. Unabhängig von FHEM läuft das System, beide meiner Sonos Module (Sonos Connect und Sonos Play 1) sind im Netzwerk mit einer festen IP sichtbar und per App steuerbar.

Mein FHEM läuft auf einem Intel NUC mit Ubuntu Linux LTS
Dann wie im Wiki beschrieben alle 4 Perlmodule per CPAN installiert. Beim erneuten Installationsversuch der 4 Module wird mir auch angezeigt, dass das jeweilige Modul bereits installiert ist und auch läuft.
habe dann zusätzlich die Module noch mal manuell mit "apt-get install" installiert, auch ohne Fehlermeldung.

Dann in FHEM die folgende Zeile eingefügt:
define Sonos SONOS localhost:4711 30 1 5

nach einem Neustart bekomme ich die Meldung :0 Cannot load module SONOS

und im Log:
2015.02.19 13:01:00 1: reload: Error:Modul 00_SONOS deactivated:
Attempt to reload UPnP/ControlPoint.pm aborted.
Compilation failed in require at ./FHEM/00_SONOS.pm line 394, <$fh> line 1322.
BEGIN failed--compilation aborted at ./FHEM/00_SONOS.pm line 394, <$fh> line 1322.

2015.02.19 13:01:00 0: Attempt to reload UPnP/ControlPoint.pm aborted.
Compilation failed in require at ./FHEM/00_SONOS.pm line 394, <$fh> line 1322.
BEGIN failed--compilation aborted at ./FHEM/00_SONOS.pm line 394, <$fh> line 1322.

Was ist hier passiert - wer kann mir da weiter helfen ? Finde leider keine weiteren Infos zu diesen Meldungen

Danke, viele Grüße Uwe
System:FHEM 5.7 auf Intel NUC  mit 1xCUL(433) ,1xCUNO V2 (868)mit Onewire,2xNetIO mit Onewire , HMLAN
,Max Cube , Philips Hue, webViewControll, MiLight
Devices:FS20,Onewire (Cuno+NetIO),Intertechno ,Homematic (Keymatic & TC & SD) Max ,Solaranlage 7,3kWP mit Solarlog 200

der-Lolo

#1641
Hallo Reinerlein,
bei mir häufen sich Meldungen vom Sonos-Modul im Log, eigenartig finde ich z.b. das kein Zeitstempel mitanhängt. Verbose sowohl GLOBAL als auch Sonos Device steht auf 1

ZitatRenewal of subscription failed with error: 500 Can't connect to 192.168.178.53:1400 (No route to host) at ./FHEM/00_SONOS.pm line 3396 thread 1
Renewal of subscription failed with error: 500 Can't connect to 192.168.178.53:1400 (No route to host) at ./FHEM/00_SONOS.pm line 3380 thread 1
2015.02.19 10:47:27 1: Perfmon: possible freeze starting at 10:47:26, delay is 1.267
Renewal of subscription failed with error: 500 Can't connect to 192.168.178.52:1400 (No route to host) at ./FHEM/00_SONOS.pm line 3476 thread 1
Renewal of subscription failed with error: 500 Can't connect to 192.168.178.52:1400 (No route to host) at ./FHEM/00_SONOS.pm line 3460 thread 1
Renewal of subscription failed with error: 500 Can't connect to 192.168.178.52:1400 (No route to host) at ./FHEM/00_SONOS.pm line 3444 thread 1
Renewal of subscription failed with error: 500 Can't connect to 192.168.178.52:1400 (No route to host) at ./FHEM/00_SONOS.pm line 3428 thread 1
Renewal of subscription failed with error: 500 Can't connect to 192.168.178.52:1400 (No route to host) at ./FHEM/00_SONOS.pm line 3412 thread 1
Renewal of subscription failed with error: 500 Can't connect to 192.168.178.52:1400 (No route to host) at ./FHEM/00_SONOS.pm line 3396 thread 1
Renewal of subscription failed with error: 500 Can't connect to 192.168.178.52:1400 (No route to host) at ./FHEM/00_SONOS.pm line 3380 thread 1
Renewal of subscription failed with error: 500 Can't connect to 192.168.178.53:1400 (No route to host) at ./FHEM/00_SONOS.pm line 3460 thread 1
Renewal of subscription failed with error: 500 Can't connect to 192.168.178.53:1400 (No route to host) at ./FHEM/00_SONOS.pm line 3444 thread 1
Renewal of subscription failed with error: 500 Can't connect to 192.168.178.53:1400 (No route to host) at ./FHEM/00_SONOS.pm line 3428 thread 1
Renewal of subscription failed with error: 500 Can't connect to 192.168.178.53:1400 (No route to host) at ./FHEM/00_SONOS.pm line 3412 thread 1
Renewal of subscription failed with error: 500 Can't connect to 192.168.178.53:1400 (No route to host) at ./FHEM/00_SONOS.pm line 3396 thread 1
Renewal of subscription failed with error: 500 Can't connect to 192.168.178.53:1400 (No route to host) at ./FHEM/00_SONOS.pm line 3380 thread 1
Renewal of subscription failed with error: 500 Can't connect to 192.168.178.52:1400 (No route to host) at ./FHEM/00_SONOS.pm line 3476 thread 1
Renewal of subscription failed with error: 500 Can't connect to 192.168.178.52:1400 (No route to host) at ./FHEM/00_SONOS.pm line 3460 thread 1
Renewal of subscription failed with error: 500 Can't connect to 192.168.178.52:1400 (No route to host) at ./FHEM/00_SONOS.pm line 3444 thread 1
Renewal of subscription failed with error: 500 Can't connect to 192.168.178.52:1400 (No route to host) at ./FHEM/00_SONOS.pm line 3428 thread 1
Renewal of subscription failed with error: 500 Can't connect to 192.168.178.52:1400 (No route to host) at ./FHEM/00_SONOS.pm line 3412 thread 1
Renewal of subscription failed with error: 500 Can't connect to 192.168.178.52:1400 (No route to host) at ./FHEM/00_SONOS.pm line 3396 thread 1
Renewal of subscription failed with error: 500 Can't connect to 192.168.178.52:1400 (No route to host) at ./FHEM/00_SONOS.pm line 3380 thread 1
Renewal of subscription failed with error: 500 Can't connect to 192.168.178.53:1400 (No route to host) at ./FHEM/00_SONOS.pm line 3460 thread 1
Renewal of subscription failed with error: 500 Can't connect to 192.168.178.53:1400 (No route to host) at ./FHEM/00_SONOS.pm line 3444 thread 1
Renewal of subscription failed with error: 500 Can't connect to 192.168.178.53:1400 (No route to host) at ./FHEM/00_SONOS.pm line 3428 thread 1
Renewal of subscription failed with error: 500 Can't connect to 192.168.178.53:1400 (No route to host) at ./FHEM/00_SONOS.pm line 3412 thread 1
Renewal of subscription failed with error: 500 Can't connect to 192.168.178.53:1400 (No route to host) at ./FHEM/00_SONOS.pm line 3396 thread 1
Renewal of subscription failed with error: 500 Can't connect to 192.168.178.53:1400 (No route to host) at ./FHEM/00_SONOS.pm line 3380 thread 1
2015.02.19 10:00:04 1: Perfmon: possible freeze starting at 10:00:02, delay is 2.789

Hast Du eine Idee was da los ist?
Parallel dazu fällt mir eine sagen wir etwas "stotternde" Radio Wiedergabe auf, die gelegentlich aussetzt...
Das kann auch am Sender oder der Internetverbindung liegen - bin also nicht sicher ob ein Zusammenhang besteht.
Update Check sagt mir zwar das ich mal wieder aktualisieren sollte, das Sonos Modul taucht aber nicht in der Liste auf...

PS: die IPs sind die des SonosAmps der im Büro steht und nur bei bedarf angeschaltet wird - und des Play3 der im Bad steht und ebenfalls nur bei bedarf angeschaltet wird.


Reinerlein

Hallo zusammen,

@Uwe: Aus irgendeinem Grund kann er das UPnP-Modul nicht laden. Sind die Dateien unter "FHEM/lib/UPnP" denn angekommen? Dort müsste eine Datei Common.pm und ControlPoint.pm existieren...

@der-Lolo: Das kommt auf dem STDERR raus, und ist kein echtes "Logging" sondern ein Fehler, den das UPnP-Modul über den zugrundeliegenden IP-Layer zugeworfen bekommt. Das klingt danach, als würde ein Player verschwunden sein, aber nicht als verschwunden erkannt worden sein. Dann versucht er immer wieder die Subscriptions zu erneuern, und erreicht den Player nicht...
Ich schaue mal, dass ich im Subscription-Erneuerungsbereich vielleicht ein Fehlerhandling einbaue, und das ganze wenigsten nur ein paarmal für einen verschwundenen Player auftaucht.
Wenn du allerdings sagst, dass du auch Aussetzer in der Wiedergabe hast, kann es auch sein, dass der Player wirklich ab und an einfach mal nicht erreichbar ist...

Grüße
Reinerlein

der-Lolo

Danke für die Info Reinerlein, die Aussetzer habe ich aber nicht nur auf einem der beiden player - sondern eben auch in der Wiedergabe des ZP90 der immer am Netz hängt...
Verbindungsprobleme halte ich ausserdem für unwahrscheinlich da der ZP120 im Büro per Kabel angeschlossen ist.

Mopedpaul

Hallo Reinerlein,
ja, das habe ich ja auch erst vermutet . Im Verzeichnis (root)/opt/fhem/FHEM/lib/UPnP liegen die beiden von dir erwähnten PM Dateien und weitere 5 jpg Dateien. Auch die Ordner und Dateirechte habe ich geprüft . Alle auf Lesen und Schreiben. Zusätzlich "Datei als Programm ausführen"
Gruß Uwe
System:FHEM 5.7 auf Intel NUC  mit 1xCUL(433) ,1xCUNO V2 (868)mit Onewire,2xNetIO mit Onewire , HMLAN
,Max Cube , Philips Hue, webViewControll, MiLight
Devices:FS20,Onewire (Cuno+NetIO),Intertechno ,Homematic (Keymatic & TC & SD) Max ,Solaranlage 7,3kWP mit Solarlog 200

Reinerlein

Hi Uwe,

du könntest mal das Modul alleine auf der Konsole ausführen:

perl 00_SONOS.pm 4711 5 1
Was wird da denn auf der Konsole angezeigt?

Grüße
Reiner

Mopedpaul

Hallo Reinerlein,
habe gesehen, das FHEM wohl das Modul XML::Parser::Lite fehlt und habe es versucht, wohl wenig erfolgreich, über cpan nachzuinstallieren. Ich bekomme folgende Meldung beim Versuch XML::Parser::Lite zu installieren:

Running install for module 'XML::Parser::Lite'
Running make for P/PH/PHRED/XML-Parser-Lite-0.72.tar.gz
Checksum for /home/fhem/.cpan/sources/authors/id/P/PH/PHRED/XML-Parser-Lite-0.72.tar.gz ok

  CPAN.pm: Building P/PH/PHRED/XML-Parser-Lite-0.72.tar.gz

Checking if your kit is complete...
Looks good
Writing Makefile for XML::Parser::Lite
Writing MYMETA.yml and MYMETA.json
cp lib/XML/Parser/Lite.pm blib/lib/XML/Parser/Lite.pm
Manifying blib/man3/XML::Parser::Lite.3pm
  PHRED/XML-Parser-Lite-0.72.tar.gz
  make -- OK
'YAML' not installed, will not store persistent state
Running make test
PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/07-xmlrpc_payload.t .. ok   
t/26-xmlrpc.t .......... 1/6 # Looks like you planned 6 tests but ran 8.
t/26-xmlrpc.t .......... Dubious, test returned 255 (wstat 65280, 0xff00)
All 6 subtests passed
(less 8 skipped subtests: -2 okay)
t/27-xmlparserlite.t ... ok     
t/37-mod_xmlrpc.t ...... Undefined subroutine &XMLRPC::Test::Server::run_for called at t/37-mod_xmlrpc.t line 16.
# Looks like your test exited with 255 before it could output anything.
t/37-mod_xmlrpc.t ...... Dubious, test returned 255 (wstat 65280, 0xff00)
Failed 17/17 subtests
t/Lite.t ............... ok     

Test Summary Report
-------------------
t/26-xmlrpc.t        (Wstat: 65280 Tests: 8 Failed: 2)
  Failed tests:  7-8
  Non-zero exit status: 255
  Parse errors: Bad plan.  You planned 6 tests but ran 8.
t/37-mod_xmlrpc.t    (Wstat: 65280 Tests: 0 Failed: 0)
  Non-zero exit status: 255
  Parse errors: Bad plan.  You planned 17 tests but ran 0.
Files=5, Tests=71,  6 wallclock secs ( 0.08 usr  0.01 sys +  0.96 cusr  0.05 csys =  1.10 CPU)
Result: FAIL
Failed 2/5 test programs. 2/71 subtests failed.
make: *** [test_dynamic] Fehler 255
  PHRED/XML-Parser-Lite-0.72.tar.gz
  make test -- NOT OK
//hint// to see the cpan-testers results for installing this module, try:
  reports PHRED/XML-Parser-Lite-0.72.tar.gz
Running make install
  make test had returned bad status, won't install without force


Wenn ich dann, wie du ja vorgeschlagen hast Sonos.pm direkt auf der Konsole aufrufe, bekomme ich folgendes:

fhem@ubuntu-FHEM:/opt/fhem/FHEM$ perl 00_SONOS.pm 4711 5 1

Can't locate XML/Parser/Lite.pm in @INC (you may need to install the XML::Parser::Lite module) (@INC contains: 00_SONOS.p/lib 00_SONOS.p/FHEM/lib ./FHEM/lib ./lib ./FHEM ./ /usr/local/FHEM/share/fhem/FHEM/lib /etc/perl /usr/local/lib/perl/5.18.2 /usr/local/share/perl/5.18.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.18 /usr/share/perl/5.18 /usr/local/lib/site_perl .) at lib/UPnP/Common.pm line 729.
BEGIN failed--compilation aborted at lib/UPnP/Common.pm line 729.
Compilation failed in require at lib/UPnP/ControlPoint.pm line 14.
BEGIN failed--compilation aborted at lib/UPnP/ControlPoint.pm line 14.
Compilation failed in require at 00_SONOS.pm line 394.
BEGIN failed--compilation aborted at 00_SONOS.pm line 394.


Bin etwas ratlos, aber da ich kein Linux Guru bin, wüsste ich auch mit den Meldungen nicht viel anzufangen  :-X

Vielleicht hast du ja eine Idee was ich da noch installieren muss.  :-[

Gruß Uwe
System:FHEM 5.7 auf Intel NUC  mit 1xCUL(433) ,1xCUNO V2 (868)mit Onewire,2xNetIO mit Onewire , HMLAN
,Max Cube , Philips Hue, webViewControll, MiLight
Devices:FS20,Onewire (Cuno+NetIO),Intertechno ,Homematic (Keymatic & TC & SD) Max ,Solaranlage 7,3kWP mit Solarlog 200

Reinerlein

Hi Uwe,

ich hatte die Anweisungen für XML::Parser::Lite aus dem Wiki herausgenommen, da ich der Meinung war, dass es mittlerweile in der Perl-Standardlieferung enthalten sei.

Wenn dem nicht so ist, dann versuch doch mal folgendes:

sudo apt-get install libxml-parser-lite-perl


Falls das jetzt hilft, werde ich das im Wiki entsprechend wieder aufnehmen...

Grüße
Reiner

Mopedpaul

Hallo Reinerlein,
gute Nachrichten - habe wohl mit CPAN das falsche Packet installiert. Mit:

# sudo apt-get install libxml-parser-lite-perl

und anschließendem Neustart, läuft es jetzt erst einmal soweit, daß keien Fehlermeldung mehr kommt. Auch werden bereits unter FHEM die Sonos Module angezeigt  ;D  ;D

So, werde jetzt mal weiter probieren und einrichten.

Vielleicht kannst du ja im Sonos Wiki nach ergänzen, das die Ubuntu User noch dieses Modul installieren müssen  ;)

Danke und Gruß Uwe
System:FHEM 5.7 auf Intel NUC  mit 1xCUL(433) ,1xCUNO V2 (868)mit Onewire,2xNetIO mit Onewire , HMLAN
,Max Cube , Philips Hue, webViewControll, MiLight
Devices:FS20,Onewire (Cuno+NetIO),Intertechno ,Homematic (Keymatic & TC & SD) Max ,Solaranlage 7,3kWP mit Solarlog 200

justme1968

hallo reiner,

das initialisieren der player mit presence funktioniert jetzt. danke nochmal.

leider habe ich aber noch zwei probleme die mehr oder weniger zusammen hängen...

- beim fhem start wird der zp120 immer sofort erkannt, die beiden play:1 aber nur selten. manchmal dauert es bis zu einer halben stunde bis sie in fhem als present auftauchen. mit verbose 5 sehe ich im log aber die ganze zeit die is alive meldungen per icmp (alle 10 sekunden). manchmal hilft es wenn ich die player über die normale sonos anwendung kurz etwas spielen lasse. aber auch nicht immer.

- wenn ich mit speak eine durchsage an TYPE=SONOSPLAYER schicke und ein player dabei der nicht erreichbar ist kann ich anschliessend keine kommandos mehr schicken und empfange auch keine mehr. hier scheint sich modul intern irgendetwas zu verheddern. wenn ich das ganze mit TYPE=SONOSPLAYER:FILTER=presence=appeared auf erreichbare player beschränke gibt es das problem nicht.

gruss
  andre



gruss
  andre
hue, tradfri, alexa-fhem, homebridge-fhem, LightScene, readingsGroup, ...

https://github.com/sponsors/justme-1968