petro-kushchak / homebridge-homepod-radio

MIT License
36 stars 2 forks source link

Enhancement: specify HomePod by name in config #53

Open justjam2013 opened 2 hours ago

justjam2013 commented 2 hours ago

This is a suggested enhancement to specify the HomePod by name instead of by id in the plugin config. As a side effect, it will fiix the issue with the mac addresses changing in iOS 18.

In bin/stream.py replace:

    atvs = await pyatv.scan(self.loop, identifier=self.atv_identifier, timeout=5)

    if not atvs:
        self.logger.error("* No Device found")
        return False

    conf = atvs[0]

with a scan by protocol:

    from pyatv.const import Protocol

    ...
    atvs = await pyatv.scan(self.loop, protocol=Protocol.AirPlay, timeout=5)

    atvs[:] = [atv for atv in atvs if atv.name == self.homepod_name]
    if not atvs:
        self.logger.error("* No Device found")
        return False

    conf = atvs[0]
justjam2013 commented 2 hours ago

Using the HomePod name instead of the id, would create volume buttons with human readable names instead of using the id string.

Screenshot 2024-09-30 at 1 40 44 AM