Squeezebox Modul - erste Version

Begonnen von bugster_de, 17 Dezember 2013, 22:12:10

Vorheriges Thema - Nächstes Thema

bugster_de

An Alle:

Soll das Squeezebox Modul in die normale FHEM Installation übernommen werden?

Gründe die dagegeben sprechen:
- ich bin beruflich sehr eingespannt und kann mich momentan nicht in der Geschwindigkeit um Bug-fixes kümmern, wei man sich das wünschen würde. Findet sich jemand, der mir bei der Wartung hilft?
- momentan ist die Hilfedokumentation im Modul nicht erstellt. Das ist HTML Text am unteren Ende, der dann für die FHEM commandref benutzt wird. Wer kann mir da helfen?


dowlix

Zitat von: bugster_de am 02 September 2014, 08:59:31
@dowlix:

I see the variable PASSWORD   yyy ist set. Does that mean, that you are using a username and password? If so, there is a bug (as just reported by Skram also). I'll fix that, but the fix is a little heavier and I don't have time this week to look into it. So for the time being: can you setup your LMS Server to be working without password?

Yes, it works when I set the server to not require username + password.

Thanks for identifying the cause of this problem. I can't leave the server unprotected permanently, and I'll take a look at the code myself in the meantime.

I noticed that the second SB player device was correctly identified and created, as described in the notes.

bugster_de

ok, the problem is starting in line #582: as you can see, the code for sending the usernam and password is not there.
also line #191 needs adoption: there is a reading called serversecure, that should be set to "1" if USERNAM and PASSWORD are specified.
In fact serversecure could even be dropped, as we just have to identify in line 582, that USERNAM and PASSWORD are not equal to "?"

The complex part is, that we have to send the command "login username password" once when establishing the connection.

So a quick fix is to add this before line #637:

if( ( $hash->{USERNAME} ne "?" ) &&( $hash->{PASSWORD} ne "?" ) ) {
    DevIo_SimpleWrite( $hash, "login $hash->{USERNAME} $hash->{PASSWORD}\n", 0 );
}


And please delete the code from #587 through to line #593

That should now work, if the correct username and passowrd are specified. No error treatment for worn username or password is done, which needs to be implemented. Also we need to implement the trap that you ran into: if the LMS requires login, it needs to be clearly reported to the FHEM user.

dowlix

There's at least one additional change required.

My original log entries show connections with commands:

listen 1
pref authorize ?
version ?
serverstatus 0 200
favorites items 0 30
playlists 0 200


This is in the  SB_SERVER_DoInit subroutine and also needs the test for credentials (prior to the "listen 1" line.

I'm not 100% certain which other modifications you were suggesting, I took out the code that I think you described, and it does appear to log in correctly and return database statistics now:

list LMS_Server
Internals:
   ALIVECHECK ?
   CFGFN      fhem-lms.cfg
   CLICONNECTION ?
   CLIPORT    9090
   DEF        192.168.1.11 USER:xxx PASSWORD:yyy
   DeviceName 192.168.1.11:9090
   FD         119
   IP         192.168.1.11
   LASTANSWER playlists 0 200 id:141207 playlist:MooseUndo1 id:141208 playlist:MooseUndo2 id:141209 playlist:MooseUndo3 id:141210 playlist:MooseUndo4 id:141211 playlist:MooseUndo5 id:141213 playlist:test-playlist id:148960 playlist:Zapped Songs count:7
   NAME       LMS_Server
   NR         1070
   NTFY_ORDER 50-LMS_Server
   PARTIAL   
   PASSWORD   yyy
   RCCNAME    none
   STATE      opened
   TYPE       SB_SERVER
   USERNAME   xxx
   WOLNAME    none
   Readings:
     2014-09-02 23:42:14   db_albums       4196
     2014-09-02 23:42:14   db_artists      1828
     2014-09-02 23:42:14   db_genres       115
     2014-09-02 23:42:14   db_songs        39788
     2014-09-02 23:42:14   favoritesname   Favorites
     2014-09-02 23:42:14   favoritestotal  18
     2014-09-02 23:42:14   players         1
     2014-09-02 23:42:14   players_mysb    0
     2014-09-02 23:42:14   players_other   0
     2014-09-02 23:42:06   power           on
     2014-09-02 23:42:14   scan_last       1-6-2014 0:24:45
     2014-09-02 23:42:14   scandb          ?
     2014-09-02 23:42:14   scanlastfailed  none
     2014-09-02 23:42:14   scanning        no
     2014-09-02 23:42:14   scanprogressdone 0
     2014-09-02 23:42:14   scanprogresstotal 0
     2014-09-02 23:42:14   serversecure    1
     2014-09-02 23:42:14   serverversion   7.7.3
Attributes:
   alivetimer 120
   doalivecheck true
   maxcmdstack 200
   maxfavorites 30


There is at least one remaining, outstanding issue. The Server is running on a Synology Diskstation NAS on port 9002. The first posts in this thread indicated how the port number of the server could be specified. Subsequent messages (If I understand correctly; I have had to use google translate) indicate a modified definition block, with no space for the server port number.

In the list output above, the server port number is not detailed. There are 3 places in 97_SB_SERVER.pm where port 9000 is hard-coded. I changed my file to use 9002 and as far as I can tell, all the examples given earlier in this thread are now working. But perhaps this isn't important, if the server is sending commands to the player(s), perhaps the library is implicit in those commands.

I love it. Thank you very much for this. Next task is to build some notify routines...

bugster_de

ZitatI'm not 100% certain which other modifications you were suggesting
pretty easy: we are building a module for a broader usage. So that means, the quick fix I suggested is just to make it wok for users knowing what they do.
Still to be added is
i.) check if log-in was succesful. If so, go ahead. This means The DoInit has to be split into two routines
ii.) if not succesful, handle the error and throw a meaningful message to the user.
This means we have to log in, wait for the answer, send a further command and check the answe. if this is succesful, go ahead with "listen 1" etc. If not --> error message and stop
iii.) I'm not sure, if the LMS server requires to send credentials from time to time. The documentation is not 100% clear to me in this point. So it might well be, that we have to do the log-in procedure from time to time over and over again

For the port:
define <name> SB_SERVER <serverip[:cliserverport]>

if you did not change the port in the LMS server (which i recommend), than you don't need to do anything.
define myserver SB_SERVER 192.168.2.17
CLI-Port will be 9090 by default

If you changed it, here's an example:
define myserver SB_SERVER 192.168.5.17:9002
To check if this was succesful, please look at the internal reading CLIPORT. It should be 9002 now. If not it is 9090



dowlix

Synology use 9090 for the cli port. That's not the problem. The issue is the web interface and audio on 9002.

i.e.

http://192.168.1.11:9002/stream.mp3

Or maybe it isn't a problem, because the LMS server handles interaction with the players without fhem needing to know any of this?

On the other hand, there is a link somewhere for artwork. In my case, I certainly require 9002 within that link.

bugster_de

Hi,

the webinterface is not of interest to the FHEM Modules for playing music. So that is don't care.
The webinterface is only used to gather the coverart URL. So if you want to display the current cover-art URL, then the port number is needed. So far in the code, I'm using a static Port number of 9000. As you have the need to change the port number, I'll put a parameter into that.

dowlix

Bugster -

Thank you very much.

I'm not certain if I may have discovered another issue, but perhaps you understood this already and anticipated it.

My LMS Server shuts down overnight. fhem runs on a Raspberry Pi, which runs 24 hours per day.

When I tried to switch on my Touch player through fhem today, it failed. Only when I restarted the fhem service on the Raspberry Pi did things work correctly.

I suppose that the fhem service was trying to re-use the connection that it had used yesterday, when the credentials had been passed [successfully]. fhem did not know that the LMS server had been rebooted in the meantime and that a new connection was opened, I suppose, requiring the credentials to be passed again.

I hope that this is because the changes that we have made are only the "quick fix" that we discussed earlier.

bugster_de

how does the LMS server shut-down? Hibernate? If it is hibernate, the effect you describe is pretty much right, as FHEM doesn't release the PC going away, as the LMS doesn't terminate the CLI session.
I thought my latest changes with all that on-off and alive handling where getting this sorted (works for me) but visibly not.
If that happens, the only thing to do is to  click on the modify button of the SB_SERVER. That will start things over again.

Our quick & dirty fix could also be a reason for that behavior. I was trying over lunch today a more solid fix and things don't seem to be so easy with login on the CLI port

dowlix

I'm not exactly sure how it powers off. It has the ability to be woken up by WOL when it is "off".

And I'm not exactly certain of the problem or its diagnosis. yesterday, I thought that the problem did not occur, and I was surprised by that. Today it looks as though my first 2 or 3 commands to the Touch (switch on, display a message, random play) got through. However, now my volume commands aren't getting through.

Of course whilst testing new things it is very easy to mess things up and / or become confused. I'm perfectly happy to work with things as they are currently, and perform any tests on new code. After all, it will be simple enough to automate the restarting of fhem when the Server reappears in the morning.

nillix

Hallo,

ich bekomme folgende Ereignismeldungen, wenn ich das 97_SB_SERVER Modul installiert habe und FHEM neu starte:

Bareword found where operator expected at ./FHEM/97_SB_SERVER.pm line 6, near ""en" class"
        (Missing operator before class?)
Bareword found where operator expected at ./FHEM/97_SB_SERVER.pm line 13, near "<title>fhem"
        (Missing operator before fhem?)
Bareword found where operator expected at ./FHEM/97_SB_SERVER.pm line 13, near "97_SB_SERVER"
        (Missing operator before SB_SERVER?)
Bareword found where operator expected at ./FHEM/97_SB_SERVER.pm line 6, near ""en" class"
        (Missing operator before class?)
Bareword found where operator expected at ./FHEM/97_SB_SERVER.pm line 13, near "<title>fhem"
        (Missing operator before fhem?)
Bareword found where operator expected at ./FHEM/97_SB_SERVER.pm line 13, near "97_SB_SERVER"
        (Missing operator before SB_SERVER?)


Das Modul lässt sich nicht in der Konfig ansprechen, da es nicht gefunden, bzw. nicht geladen wurde.
Kann jemand helfen?

Vielen Dank


bugster_de

#371
Hi,

zum gefühlt 20-sten Mal in diesem Thread: da hat wohl der Download aus Contrib nicht funktioniert. Bitte die Raw Ansicht öffnen und von dort aus in eine Textdatei kopieren.
ich habe das jetzt mal in den initialen Beitrag in diesem Thread aufgenommen.

nillix


limats

Hallo zusammen,

ich hab zwei kleine Probleme mit dem Modul

  • Wenn ich donotnotify auf true stelle, bekomme ich anders als in der Beschreibung gar keine Notifys. Also auch keine für die Statusänderung on/off. Genau die bräuchte ich aber, um meine Stereoanlage entsprechend zu bedienen. Muss ich dafür donotnotify auf false stellen (dann funktioniert es) oder ist das ein Bug?
  • Ich betreibe ein Squeezelite auf einem Raspi, der normalerweise aus ist. Wenn ich den Raspi hochfahre, aktualisiert sich der Player in FHEM zumindest sehr lange nicht. D.h. presence bleibt auf ? oder absent stehen und auch der Einschaltstatus wird nicht erkannt. Kann man das irgendwie ändern? Würde das Event gerne verwenden, um wie gesagt meine Stereoanlage zu steuern.

Ansonsten: Extrem cooles Modul. Ist einfach klasse, mit wie wenig Aufwand und Kosten damit Multiroom implementierbar ist. Hab auf den Raspis noch einen IR-Sender (Bauteilkosten < 5 EUR) mit LIRC am laufen. So ist sogar eine individuelle Steuerung des Hifi-Equipment möglich. Für Gesamtkosten wesentlich weniger als 100 EUR pro Raum soll das mal jemand mit Sonos und Co. nachmachen.

Gruß
Leo
Fhem auf BBB:
HM-CFG-USB für div. HM-Sensoren, CUL+WMBUS für EnergyCam, Nanocul für IT, Arduino Mega 2560 als 1-wire-Gateway und für div. digitale Ein-/Ausgänge, Volkszähler-USB-IR-Lesekopf mit SMLUSB, Solarsteuerung über VBUS

MarcoE

Hallo,
ich bin noch nicht wirklich der Held in der FHEM Welt, daher ein (wahrscheinlich) einfach zu beantwortende Frage:
Ich möchte- wenn eine Squeezbox ein- bzw ausgeschaltet wird eine Funksteckdose ein- bzw ausschalten, da an der die Aktivboxen hängen.
Jetzt habe ich folgendes eingefügt:
define Musik_an_ntfy notify SqueezeBox_Wohnzimmer set Strom_Aktivbox $EVENT
Soweit funktioniert das- nur bekomme ich jetzt im Logfile Einträge bzgl. der anderen Notifications wie playStatus, currentAlbum und viele mehr. Lasse ich bei der Initialisierung das donotify auf true bekomme ich die Steckdosen damit nicht an.
Was ist mein Fehler?

Danke und Gruß,
Marco