Skip to content

Commit

Permalink
refactor: Use unique device name prefix for pairing
Browse files Browse the repository at this point in the history
  • Loading branch information
zehnm committed Apr 1, 2024
1 parent 0e7c963 commit 4b7c636
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

_Changes in the next release_

### Changed
- Use unique device name prefix for pairing to easily identify paired devices on Apple TV ([feature-and-bug-tracker#362](https://github.com/unfoldedcircle/feature-and-bug-tracker/issues/362)).

---

## v0.13.7 - 2024-03-18
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ For running a separate integration driver on your network for Remote Two, the co
### Run

```shell
python3 intg-appletv/driver.py
UC_CONFIG_HOME=./ python3 intg-appletv/driver.py
```

See available [environment variables](https://github.com/unfoldedcircle/integration-python-library#environment-variables)
Expand All @@ -65,6 +65,8 @@ in the Python integration library to control certain runtime features like liste
The configuration file is loaded & saved from the path specified in the environment variable `UC_CONFIG_HOME`.
Otherwise, the `HOME` path is used or the working directory as fallback.

The client name prefix used for pairing can be set in ENV variable `UC_CLIENT_NAME`. The hostname is used by default.

## Build self-contained binary

After some tests, turns out python stuff on embedded is a nightmare. So we're better off creating a single binary file
Expand Down
8 changes: 6 additions & 2 deletions intg-appletv/setup_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

import asyncio
import logging
import os
import socket
from enum import IntEnum

import config
Expand Down Expand Up @@ -384,7 +386,8 @@ async def _handle_device_choice(msg: UserDataResponse) -> RequestUserInput | Set
_LOG.debug("Pairing process begin")
# Hook up to signals
# TODO error conditions in start_pairing?
res = await _pairing_apple_tv.start_pairing(pyatv.const.Protocol.AirPlay, "Remote Two Airplay")
name = os.getenv("UC_CLIENT_NAME", socket.gethostname().split(".", 1)[0])
res = await _pairing_apple_tv.start_pairing(pyatv.const.Protocol.AirPlay, f"{name} Airplay")
if res is None:
return SetupError()

Expand Down Expand Up @@ -439,7 +442,8 @@ async def _handle_user_data_airplay_pin(msg: UserDataResponse) -> RequestUserInp
_pairing_apple_tv.add_credentials(c)

# Start new pairing process
res = await _pairing_apple_tv.start_pairing(pyatv.const.Protocol.Companion, "Remote Two Companion")
name = os.getenv("UC_CLIENT_NAME", socket.gethostname().split(".", 1)[0])
res = await _pairing_apple_tv.start_pairing(pyatv.const.Protocol.Companion, f"{name} Companion")
if res is None:
return SetupError()

Expand Down

0 comments on commit 4b7c636

Please sign in to comment.