Asynchronous implementation of the Frontier Silicon API
Project description
python-afsapi
Asynchronous Python implementation of the Frontier Silicon API
- This project was started in order to embed Frontier Silicon devices in Home Assistant (https://home-assistant.io/)
- Inspired by:
- https://github.com/flammy/fsapi/
- https://github.com/tiwilliam/fsapi
- https://github.com/p2baron/fsapi
Runtime dependency:
- aiohttp
- defusedxml
Development workflow (uv + ruff):
uv sync --group dev
uv run ruff check .
uv run pytest -q
Device recording tests (pytest-recording)
The repository includes integration tests that can record and replay real responses from the development radio.
- Tests are in
tests/test_device_recordings.py(read calls) andtests/test_device_recordings_write.py(write calls with state restore). - Cassettes are stored under
tests/cassettes/. - Device tests replay cassettes by default (
pytestruns them with no live device access). - Live/recording runs require both
AFSAPI_DEVICE_IPandAFSAPI_DEVICE_PIN.
Set device IP + PIN and record fresh cassettes:
AFSAPI_DEVICE_IP="192.168.1.183" AFSAPI_DEVICE_PIN="1234" uv run pytest tests/test_device_recordings.py tests/test_device_recordings_write.py --run-device-tests --record-mode=once -q
Re-record all cassettes:
AFSAPI_DEVICE_IP="192.168.1.183" AFSAPI_DEVICE_PIN="1234" uv run pytest tests/test_device_recordings.py tests/test_device_recordings_write.py --run-device-tests --record-mode=all -q
Run default tests without touching the device:
uv run pytest -q
Usage
import asyncio
from afsapi import AFSAPI
URL = 'http://192.168.1.XYZ:80/device'
PIN = 1234
TIMEOUT = 1 # in seconds
async def test():
afsapi = await AFSAPI.create(URL, PIN, TIMEOUT)
print(f'Set power succeeded? - {await afsapi.set_power(True)}' )
print(f'Power on: {await afsapi.get_power()}')
print(f'Friendly name: {await afsapi.get_friendly_name()}')
for mode in await afsapi.get_modes():
print(f'Available Mode: {mode}')
print(f'Current Mode: {await afsapi.get_mode()}')
for equaliser in await afsapi.get_equalisers():
print(f'Equaliser: {equaliser}')
print(f'EQ Preset: {await afsapi.get_eq_preset()}' )
for preset in await afsapi.get_presets():
print(f"Preset: {preset}")
print(f'Set power succeeded? - {await afsapi.set_power(False)}')
print(f'Set sleep succeeded? - {await afsapi.set_sleep(10)}')
print(f'Sleep: {await afsapi.get_sleep()}')
print(f'Get power {await afsapi.get_power()}' )
loop = asyncio.new_event_loop()
loop.run_until_complete(test())
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file afsapi-1.0.1.tar.gz.
File metadata
- Download URL: afsapi-1.0.1.tar.gz
- Upload date:
- Size: 139.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.25
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3cf1f1d50e8a5f11fe1e8a5d04fc1a2251946f4ddc170bc136cb4cad6dcf2371
|
|
| MD5 |
4d3d6dae9eac1be76fb4ae03305ddaa5
|
|
| BLAKE2b-256 |
6381ecba6e92cb24947b59a08799bee7f932f0e5d27e1c6c1da609bcda1ab0ad
|
File details
Details for the file afsapi-1.0.1-py3-none-any.whl.
File metadata
- Download URL: afsapi-1.0.1-py3-none-any.whl
- Upload date:
- Size: 23.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.25
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5a6d86fd24d04021e50ae872fc4b11be9d28414565bead9816ca150e907e5591
|
|
| MD5 |
ecfa81861e76280cfb0fe091e9466081
|
|
| BLAKE2b-256 |
d5c5789c84c3387afa5bb8dacec4f2970c635a91d71045cca46ada634a85464e
|