Tom-Hirschberger / MMM-MplayerRadio

An MagicMirror² module which playes m3u radio playlists with MPlayer and supports various stations to rotate through
MIT License
7 stars 0 forks source link

Setting Radio station to ID 0 via notification doesn't change the image of the radio station #31

Closed Milinator closed 2 months ago

Milinator commented 3 months ago

Hey there,

Thanks for this great module! I control it exclusively via Home Assistant (so basic REST calls to be exact). Changing the radio station works for all my stations via the ID (0 to 3). For station 1, 2 and 3, changing the image also works, but if I call the station with the ID 0, then the image of the previous station remains.

Would be nice if that could be fixed, I'll have a look at the problem tomorrow. Maybe I can find the issue too.

Have a good one!

Milinator commented 3 months ago

I found the issue, but only have a temporary/not optimal fix for it. The problem occurs in MMM-MplayerRadio.js in function getNextStationId: At some point newId becomes '01' instead of '0', probably somewhere here for(var i = 0; i < self.config.stations.length; i++){ newId += 1 if(newId > self.config.stations.length - 1){ newId = 0 }

I'm not sure if it's correct that ID is interpreted as a string at some points. But here is my temporary fix: if(newId === '01'){ console.log("Habe nur 01 auf 0 gesetzt") newId = 0; }

(Placed right after the first code that I posted above)

Maybe you can fix it in a cleaner way?

Best regards Milan

Tom-Hirschberger commented 3 months ago

Hi and sorry for the late reply,

You are right. There was a problem if the station id is send as string instead of integer. I integrated a fix by parsing any payload input as Integer and released version 0.1.4 a couple of seconds ago.

Tom-Hirschberger commented 2 months ago

Hi, I think the problem is solved with the new implementation. Feel free to reopen the issue if not.