Device not found when attempting to cast
Closed this issue · 8 comments
I just installed catt
and when I tried to cast, I got a device not found error:
$ catt scan
Scanning Chromecasts...
192.168.1.xxx - Bedroom TV - Google Inc. Chromecast
192.168.1.yyy - Bedroom speaker - Google Inc. Chromecast Audio
...
$ catt -d "Bedroom TV" cast https://www.youtube.com/watch?v=dQw4w9WgXcQ
Error: Specified device "bedroom tv" not found.
I can however cast by entering the IP:
$ catt -d 192.168.1.xxx cast https://www.youtube.com/watch?v=dQw4w9WgXcQ
Casting remote file https://www.youtube.com/watch?v=dQw4w9WgXcQ...
Playing "Rick Astley - Never Gonna Give You Up (Official Music Video)" on "Bedroom TV"...
It seems like the device name is being lowercased. Doing some digging, I found issue #366 which seems to be related, and this commit e52394d
I also can't set an alias to this device, or set it as default via the cli:
$ catt -d "Bedroom TV" set_alias bedroom
Error: Specified device "bedroom tv" not found.
$ catt -d "Bedroom TV" set_default
Error: Specified device "bedroom tv" not found.
However if I manually create a config and set an alias, I can use it:
$ cat catt.cfg
[aliases]
bedroom = Bedroom TV
$ catt -d bedroom cast https://www.youtube.com/watch?v=dQw4w9WgXcQ
Casting remote file https://www.youtube.com/watch?v=dQw4w9WgXcQ...
Playing "Rick Astley - Never Gonna Give You Up (Official Music Video)" on "Bedroom TV"...
I am running version v0.12.5
I've run into this too sometimes, unfortunately it seems that someone will need to use Wireshark to debug this, but I can't reproduce it any more.
I think I found the issue actually. It really is just the name getting converted to lowercase.
In cli.py
in the process_device function:
if is_ipaddress(device_desc):
return device_desc
else:
if device_desc:
device_desc = device_desc.lower()
return aliases.get(device_desc, device_desc)
That is lowercasing device_desc and then if the alias is not found in the dictionary, it returns that lowercase string.
I believe something like this would fix it:
if is_ipaddress(device_desc):
return device_desc
else:
if device_desc:
device_desc_lower = device_desc.lower()
return aliases.get(device_desc_lower, device_desc)
Oh hmm, this code was so that the lookup would be case-insensitive. I guess if it doesn't work while case-insensitive, we could drop that, but it seems like there could be a solution that would satisfy both requirements. Would you be willing to open a PR? I can't test this currently, unfortunately.
Yup I'll do some testing and open a PR.
I can confirm that this change is needed so device is found. I was getting same error:
# catt -d 'Google Kitchen' info
Error: Specified device "google kitchen" not found.
With this fix the command is working again.
Excellent, so yesterday's release is working fine for you?
I installed Catt via PIP. Did not get version with this fix.
# catt --version
catt v0.12.5, Zaniest Zapper.
Can you try the latest version?