stijnvdb88 / Snap.Net

A cross-platform control client and player for https://github.com/badaix/snapcast
GNU General Public License v3.0
121 stars 11 forks source link

Set --hostID to stap spamming of client names #19

Closed abelmatser closed 3 years ago

abelmatser commented 3 years ago

First, thanks for your awesome work! You make Snapcast more accessible to all of us. (Congratulations on the app store release btw!)

It would be nice if we could be able to set the client name of Snap.Net just like I do on dedicated clients:

SNAPCLIENT_OPTS="-h $IP --hostID woonkamer"

I would like to do this to stop the generation of tons of unused snapclient ids as: Desktop-Name # 1, ..., # 15. I get these when I stop and open Snap.Net after restarting the snapserver during troubleshooting.

stijnvdb88 commented 3 years ago

Hi there, thanks! Have you tried setting the names from within Snap.Net? (it's kind of hidden away, you need to click on the client name to get that dialog)

image

That ends up calling Client.SetName on the server, which is persistent across sessions :) (https://github.com/badaix/snapcast/blob/master/doc/json_rpc_api/v2_0_0.md#clientsetname)

Let me know please if that doesn't work!

abelmatser commented 3 years ago

This seems to work, thanks!

abelmatser commented 3 years ago

I would like to reopen this issue, because even though setting the name is useful, it does not achieve one of the goals I want it to achieve. Home Assistant obtains snapcast clients and names them by their id (media_player.snapcast_client_${ID}). Currently that id (which I believe is set by Snap.Net or automatically deduced by Snapcast) is the mac address of the computer, with an added #number for the index of the instance on that device.

I would like to be able to set the id (or have it be the same as the name), thus replacing the mac address by which it is currently set. If it enforces a unique name with a trailing number that is fine, then at least the client is recognizable by its id.

(Same is true for groups, in which the id is also non-human readable format)

stijnvdb88 commented 3 years ago

That makes sense, I didn't realize there were tools using these id's as names :) I'll add a field in the player settings for overriding the host ID. The mac address + instance ID are automatically filled in by snapclient by the way (see https://github.com/badaix/snapcast/blob/master/common/message/hello.hpp#L98), unless an id is explicitly specified via --hostID, as you pointed out before.

abelmatser commented 3 years ago

Thanks for the update, I just tested it and setting the ID works! Thanks for your time 👍

I'm not sure if I want to make an issue of this, but I do have a small one. Currently a trailing number is added to the id, even though the id is unique. In my case a trailing _6 was added, which I believe is because I have around that many output options on my computer, so this was not generated because this ID was non-unique.

I would think this trailing number is unnecessary if one chooses a unique ID.

stijnvdb88 commented 3 years ago

Thanks for the update! I had a quick look, the issue you're seeing is caused by the --instance parameter being passed. This parameter helps snapserver tell various players apart when they come from the same machine (which under normal circumstances means they all share the same mac address and therefore the same ID). It's fair to assume that an explicit --hostID override means it'll be unique anyway, so --instance can be omitted in this case. Will fix this for the next release :)