/pyamaha

Python implementation of Yamaha Extended Control API Specification.

Primary LanguagePythonMIT LicenseMIT

PYAMAHA

PyPI Join the chat at https://gitter.im/rsc-dev/pyamaha Unit Tests

About

Pyamaha is Python implementation of Yamaha Extended Control API Specification. Please see Status for list of implemented functions. Undocumented functions will be added in future.

Instalation

pip install pyamaha

or

python setup.py install

Usage

API (with requests)

from pyamaha import Device, System

dev = Device('192.168.1.1')
res = dev.request(System.get_device_info())

print(res.json()) # JSON response

Async API (with aiohttp)

import asyncio
import sys

import aiohttp

from pyamaha import AsyncDevice, System


async def main():
    async with aiohttp.ClientSession() as session:
        dev = AsyncDevice(session, "192.168.1.1")
        res = await dev.request(System.get_device_info())

        v = await res.json()
        print(v)


# To avoid 'Event loop is closed' RuntimeError due to compatibility issue with aiohttp
if sys.platform.startswith("win") and sys.version_info >= (3, 8):
    try:
        from asyncio import WindowsSelectorEventLoopPolicy
    except ImportError:
        pass
    else:
        if not isinstance(
            asyncio.get_event_loop_policy(), WindowsSelectorEventLoopPolicy
        ):
            asyncio.set_event_loop_policy(WindowsSelectorEventLoopPolicy())
asyncio.run(main())

UDP Callbacks (see Chaper 10 in YXC documentation)

import time

from pyamaha import Device, System


def handle(message):
    print(message) # UDP event data (python dict)

dev = Device('192.168.1.1')
res = dev.request(System.get_device_info(), handle)

print(res.json()) # JSON response

time.sleep(60)

CLI

> python -m pyamaha
yxc>device 192.168.1.106
yxc>system
yxc\system>getDeviceInfo
{u'api_version': 1.17,
 u'destination': u'BG',
 u'device_id': u'XXX',
 u'model_name': u'CD-NT670D',
 u'netmodule_checksum': u'XXX',
 u'netmodule_version': u'1130    ',
 u'operation_mode': u'normal',
 u'response_code': 0,
 u'system_id': u'XXX',
 u'system_version': 1.7,
 u'update_error_code': u'FFFFFFFF'}
yxc\system>

Status

Function API CLI Info
SYSTEM
/YamahaExtendedControl/v1/system/getDeviceInfo x x Documented
/YamahaExtendedControl/v1/system/getFeatures x x Documented
/YamahaExtendedControl/v1/system/getNetworkStatus x x Documented
/YamahaExtendedControl/v1/system/getFuncStatus x x Documented
/YamahaExtendedControl/v1/system/setAutoPowerStandby x x Documented
/YamahaExtendedControl/v1/system/getLocationInfo x x Documented
/YamahaExtendedControl/v1/system/sendIrCode x x Documented
/YamahaExtendedControl/v1/system/setWiredLan x x Documented
/YamahaExtendedControl/v1/system/setWirelessLan x - Documented
/YamahaExtendedControl/v1/system/setWirelessDirect x - Documented
/YamahaExtendedControl/v1/system/setIpSettings x - Documented
/YamahaExtendedControl/v1/system/setNetworkName x - Documented
/YamahaExtendedControl/v1/system/setAirPlayPin x - Documented
/YamahaExtendedControl/v1/system/getMacAddressFilter x - Documented
/YamahaExtendedControl/v1/system/setMacAddressFilter x - Documented
/YamahaExtendedControl/v1/system/getNetworkStandby x - Documented
/YamahaExtendedControl/v1/system/setNetworkStandby x - Documented
/YamahaExtendedControl/v1/system/getBluetoothInfo x - Documented
/YamahaExtendedControl/v1/system/setBluetoothStandby x - Documented
/YamahaExtendedControl/v1/system/setBluetoothTxSetting x - Documented
/YamahaExtendedControl/v1/system/getBluetoothDeviceList x - Documented
/YamahaExtendedControl/v1/system/updateBluetoothDeviceList x - Documented
/YamahaExtendedControl/v1/system/connectBluetoothDevice x - Documented
/YamahaExtendedControl/v1/system/disconnectBluetoothDevice x - Documented
/YamahaExtendedControl/v1/system/setSpeakerA x - Documented
/YamahaExtendedControl/v1/system/setSpeakerB x - Documented
/YamahaExtendedControl/v1/system/setDimmer x - Documented
/YamahaExtendedControl/v1/system/setZoneBVolumeSync x - Documented
/YamahaExtendedControl/v1/system/setHdmiOut1 x - Documented
/YamahaExtendedControl/v1/system/setHdmiOut2 x - Documented
/YamahaExtendedControl/v1/system/getNameText x - Documented
/YamahaExtendedControl/v1/system/setNameText x - Documented
/YamahaExtendedControl/v1/system/setSpeakerPattern x - Documented
/YamahaExtendedControl/v1/system/setPartyMode x - Documented
ZONE
/YamahaExtendedControl/v1/{zone}/getStatus x - Documented
/YamahaExtendedControl/v1/{zone}/getSoundProgramList x - Documented
/YamahaExtendedControl/v1/{zone}/setPower x - Documented
/YamahaExtendedControl/v1/{zone}/setSleep x - Documented
/YamahaExtendedControl/v1/{zone}/setVolume x - Documented
/YamahaExtendedControl/v1/{zone}/setMute x - Documented
/YamahaExtendedControl/v1/{zone}/setInput x - Documented
/YamahaExtendedControl/v1/{zone}/setSoundProgram x - Documented
/YamahaExtendedControl/v1/{zone}/prepareInputChange x - Documented
/YamahaExtendedControl/v1/{zone}/set3dSurround x - Documented
/YamahaExtendedControl/v1/{zone}/setDirect x - Documented
/YamahaExtendedControl/v1/{zone}/setPureDirect x - Documented
/YamahaExtendedControl/v1/{zone}/setEnhancer x - Documented
/YamahaExtendedControl/v1/{zone}/setToneControl x - Documented
/YamahaExtendedControl/v1/{zone}/setEqualizer x - Documented
/YamahaExtendedControl/v1/{zone}/setBalance x - Documented
/YamahaExtendedControl/v1/{zone}/setDialogueLevel x - Documented
/YamahaExtendedControl/v1/{zone}/setDialogueLift x - Documented
/YamahaExtendedControl/v1/{zone}/setClearVoice x - Documented
/YamahaExtendedControl/v1/{zone}/setSubwooferVolume x - Documented
/YamahaExtendedControl/v1/{zone}/setBassExtension x - Documented
/YamahaExtendedControl/v1/{zone}/getSignalInfo x - Documented
/YamahaExtendedControl/v1/{zone}/setLinkControl x - Documented
/YamahaExtendedControl/v1/{zone}/setLinkAudioDelay x - Documented
TUNER
/YamahaExtendedControl/v1/tuner/getPresetInfo x - Documented
/YamahaExtendedControl/v1/tuner/getPlayInfo x - Documented
/YamahaExtendedControl/v1/tuner/setFreq x - Documented
/YamahaExtendedControl/v1/tuner/recallPreset x - Documented
/YamahaExtendedControl/v1/tuner/switchPreset x - Documented
/YamahaExtendedControl/v1/tuner/storePreset x - Documented
/YamahaExtendedControl/v1/tuner/setDabService x - Documented
NETWORK/USB
/YamahaExtendedControl/v1/netusb/getPresetInfo x - Documented
/YamahaExtendedControl/v1/netusb/getPlayInfo x - Documented
/YamahaExtendedControl/v1/netusb/setPlayback x - Documented
/YamahaExtendedControl/v1/netusb/toggleRepeat x - Documented
/YamahaExtendedControl/v1/netusb/toggleShuffle x - Documented
/YamahaExtendedControl/v1/netusb/getListInfo x - Documented
/YamahaExtendedControl/v1/netusb/setListControl x - Documented
/YamahaExtendedControl/v1/netusb/setSearchString x - Documented
/YamahaExtendedControl/v1/netusb/recallPreset x - Documented
/YamahaExtendedControl/v1/netusb/storePreset x - Documented
/YamahaExtendedControl/v1/netusb/getAccountStatus x - Documented
/YamahaExtendedControl/v1/netusb/switchAccount x - Documented
/YamahaExtendedControl/v1/netusb/getServiceInfo x - Documented
CD
/YamahaExtendedControl/v1/cd/getPlayInfo x - Documented
/YamahaExtendedControl/v1/cd/setPlayback x - Documented
/YamahaExtendedControl/v1/cd/toggleTray x - Documented
/YamahaExtendedControl/v1/cd/toggleRepeat x - Documented
/YamahaExtendedControl/v1/cd/toggleShuffle x - Documented
DIST
/YamahaExtendedControl/v1/dist/getDistributionInfo x - Documented
/YamahaExtendedControl/v1/dist/setServerInfo x - Documented
/YamahaExtendedControl/v1/dist/setClientInfo x - Documented
/YamahaExtendedControl/v1/dist/startDistribution x - Documented
/YamahaExtendedControl/v1/dist/stopDistribution x - Documented
/YamahaExtendedControl/v1/dist/setGroupName x - Documented
CLOCK
/YamahaExtendedControl/v1/clock/getSettings x - Documented
/YamahaExtendedControl/v1/clock/setAutoSync x - Documented
/YamahaExtendedControl/v1/clock/setDateAndTime x - Documented
/YamahaExtendedControl/v1/clock/setClockFormat x - Documented
/YamahaExtendedControl/v1/clock/setAlarmSettings x - Documented

License

Code is released under MIT license © Radoslaw '[rsc]' Matusiak.