Skip to main content

python-afsapi

Asynchronous Python implementation of the Frontier Silicon API

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) and tests/test_device_recordings_write.py (write calls with state restore).
  • Cassettes are stored under tests/cassettes/.
  • Device tests replay cassettes by default (pytest runs them with no live device access).
  • Live/recording runs require both AFSAPI_DEVICE_IP and AFSAPI_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())

Metadata

Release files for afsapi 1.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for afsapi 1.0.2
File Size Uploaded
afsapi-1.0.2.tar.gz 142.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for afsapi 1.0.2
File Interpreter ABI Platform
afsapi-1.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 165.8 kB

Release files / afsapi-1.0.2.tar.gz

Download URL afsapi-1.0.2.tar.gz
Size 142.6 kB
Tags Source
SHA-256 checksum
How to use checksums
24d9be9cab648e8f8bcf8ff8362310a8eb4c7ee85408b14322daa21e6471115e
BLAKE2b-256 checksum
How to use checksums
22ef058c43f636a321deffd2f9d181e855e65623b38b6bf990619615f64a9575
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25

Release files / afsapi-1.0.2-py3-none-any.whl

Download URL afsapi-1.0.2-py3-none-any.whl
Size 23.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c5d1ceadecf75393e0565388d5801379b8001aeb675088a1a66d5d06ec052222
BLAKE2b-256 checksum
How to use checksums
41227438acc57a265709177db47dcdf8da6b2c330a09dbec1b94707251cce0aa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page