diff --git a/logs/RX-V500D.txt b/logs/RX-V500D.txt new file mode 100644 index 0000000..19c991e --- /dev/null +++ b/logs/RX-V500D.txt @@ -0,0 +1,517 @@ +Logs from https://github.com/mvdwetering/yamaha_ynca/issues/77 + +{ + "home_assistant": { + "installation_type": "Home Assistant OS", + "version": "2022.11.0", + "dev": false, + "hassio": true, + "virtualenv": false, + "python_version": "3.10.7", + "docker": true, + "arch": "x86_64", + "timezone": "", + "os_name": "Linux", + "os_version": "5.15.74", + "supervisor": "2022.10.2", + "host_os": "Home Assistant OS 9.3", + "docker_version": "20.10.18", + "chassis": "vm", + }, + "custom_components": { + "yamaha_ynca": { + "version": "5.1.0", + "requirements": [ + "ynca==3.11.0" + ] + } + + }, + "integration_manifest": { + "domain": "yamaha_ynca", + "name": "Yamaha (YNCA)", + "config_flow": true, + "documentation": "https://github.com/mvdwetering/yamaha_ynca", + "issue_tracker": "https://github.com/mvdwetering/yamaha_ynca/issues", + "requirements": [ + "ynca==3.11.0" + ], + "ssdp": [], + "zeroconf": [], + "homekit": {}, + "dependencies": [], + "codeowners": [ + "@mvdwetering" + ], + "iot_class": "local_push", + "loggers": [ + "ynca" + ], + "version": "5.1.0", + "is_built_in": false + }, + "data": { + "config_entry": { + "entry_id": "a9b6354a6c7987b6aff19e570061f317", + "version": 5, + "domain": "yamaha_ynca", + "title": "RX-V500D", + "data": { + "serial_url": "socket://:50000" + }, + "options": { + "hidden_sound_modes": [ + "7ch Stereo", + "9ch Stereo", + "All-Ch Stereo", + "Church in Freiburg", + "Church in Royaumont", + "Hall in Amsterdam", + "Recital/Opera", + "Village Vanguard", + "Warehouse Loft" + ], + "hidden_inputs_MAIN": [ + "AV1", + "AV2", + "AV3", + "AV4", + "AV5", + "AV6", + "Spotify", + "iPod (USB)", + "V-AUX" + ] + }, + "pref_disable_new_entities": false, + "pref_disable_polling": false, + "source": "user", + "unique_id": null, + "disabled_by": null + }, + "SYS": { + "modelname": "RX-V500D", + "version": "1.20/2.06" + }, + "communication": { + "initialization": [ + "Send: @SYS:MODELNAME=?", + "Received: @SYS:MODELNAME=RX-V500D", + "Send: @SYS:MODELNAME=?", + "Received: @SYS:MODELNAME=RX-V500D", + "Send: @SYS:AVAIL=?", + "Received: @UNDEFINED", + "Send: @MAIN:AVAIL=?", + "Send: @ZONE2:AVAIL=?", + "Received: @MAIN:AVAIL=Ready", + "Received: @RESTRICTED", + "Send: @ZONE3:AVAIL=?", + "Received: @RESTRICTED", + "Send: @ZONE4:AVAIL=?", + "Received: @RESTRICTED", + "Send: @TUN:AVAIL=?", + "Received: @RESTRICTED", + "Send: @SIRIUS:AVAIL=?", + "Received: @UNDEFINED", + "Send: @IPOD:AVAIL=?", + "Received: @UNDEFINED", + "Send: @BT:AVAIL=?", + "Received: @UNDEFINED", + "Send: @RHAP:AVAIL=?", + "Received: @RESTRICTED", + "Send: @SIRIUSIR:AVAIL=?", + "Received: @UNDEFINED", + "Send: @PANDORA:AVAIL=?", + "Received: @RESTRICTED", + "Send: @NAPSTER:AVAIL=?", + "Received: @RESTRICTED", + "Send: @PC:AVAIL=?", + "Received: @UNDEFINED", + "Send: @NETRADIO:AVAIL=?", + "Received: @NETRADIO:AVAIL=Not Ready", + "Send: @USB:AVAIL=?", + "Received: @USB:AVAIL=Not Ready", + "Send: @IPODUSB:AVAIL=?", + "Received: @IPODUSB:AVAIL=Not Ready", + "Send: @UAW:AVAIL=?", + "Received: @UNDEFINED", + "Send: @SIRIUSXM:AVAIL=?", + "Received: @RESTRICTED", + "Send: @SPOTIFY:AVAIL=?", + "Received: @SPOTIFY:AVAIL=Not Ready", + "Send: @SERVER:AVAIL=?", + "Received: @SERVER:AVAIL=Not Ready", + "Send: @AIRPLAY:AVAIL=?", + "Received: @AIRPLAY:AVAIL=Not Ready", + "Send: @SYS:VERSION=?", + "Received: @SYS:VERSION=1.20/2.06", + "Send: @SYS:AVAIL=?", + "Received: @UNDEFINED", + "Send: @SYS:PWR=?", + "Received: @SYS:PWR=Standby", + "Send: @SYS:MODELNAME=?", + "Received: @SYS:MODELNAME=RX-V500D", + "Send: @SYS:INPNAME=?", + "Received: @SYS:INPNAMEHDMI1=", + "Received: @SYS:INPNAMEHDMI2=", + "Send: @SYS:VERSION=?", + "Received: @SYS:INPNAMEHDMI3=", + "Received: @SYS:INPNAMEHDMI4=", + "Received: @SYS:INPNAMEHDMI5=", + "Received: @SYS:INPNAMEAV1= AV1 ", + "Received: @SYS:INPNAMEAV2= AV2 ", + "Received: @SYS:INPNAMEAV3= AV3 ", + "Received: @SYS:INPNAMEAV4= AV4 ", + "Received: @SYS:INPNAMEAV5= AV5 ", + "Received: @SYS:INPNAMEAV6= AV6 ", + "Received: @SYS:INPNAMEVAUX= V-AUX ", + "Received: @SYS:INPNAMEUSB= USB ", + "Received: @SYS:VERSION=1.20/2.06", + "Send: @AIRPLAY:AVAIL=?", + "Received: @AIRPLAY:AVAIL=Not Ready", + "Send: @SYS:VERSION=?", + "Received: @SYS:VERSION=1.20/2.06", + "Send: @IPODUSB:AVAIL=?", + "Received: @IPODUSB:AVAIL=Not Ready", + "Send: @IPODUSB:PLAYBACKINFO=?", + "Received: @IPODUSB:PLAYBACKINFO=Stop", + "Send: @IPODUSB:METAINFO=?", + "Received: @IPODUSB:ARTIST=", + "Received: @IPODUSB:ALBUM=", + "Received: @IPODUSB:SONG=", + "Send: @IPODUSB:REPEAT=?", + "Received: @IPODUSB:REPEAT=Off", + "Send: @IPODUSB:SHUFFLE=?", + "Received: @IPODUSB:SHUFFLE=Off", + "Send: @SYS:VERSION=?", + "Received: @SYS:VERSION=1.20/2.06", + "Send: @MAIN:AVAIL=?", + "Received: @MAIN:AVAIL=Ready", + "Send: @MAIN:PWR=?", + "Received: @MAIN:PWR=Standby", + "Send: @MAIN:BASIC=?", + "Received: @MAIN:PWR=Standby", + "Send: @MAIN:MAXVOL=?", + "Received: @MAIN:SLEEP=Off", + "Received: @MAIN:VOL=-40.0", + "Received: @MAIN:MUTE=Off", + "Received: @MAIN:INP=TUNER", + "Received: @MAIN:STRAIGHT=Off", + "Received: @MAIN:ENHANCER=On", + "Received: @MAIN:SOUNDPRG=5ch Stereo", + "Received: @MAIN:3DCINEMA=Auto", + "Received: @MAIN:TONEBASS=0.0", + "Received: @MAIN:TONETREBLE=-0.5", + "Received: @MAIN:DIRMODE=Off", + "Received: @SYS:HDMIOUT1=On", + "Received: @MAIN:ADAPTIVEDRC=Off", + "Received: @RESTRICTED", + "Send: @MAIN:SCENENAME=?", + "Received: @MAIN:SCENE1NAME=BD/DVD", + "Received: @MAIN:SCENE2NAME=TV", + "Received: @MAIN:SCENE3NAME=NET", + "Received: @MAIN:SCENE4NAME=RADIO", + "Send: @MAIN:ZONENAME=?", + "Received: @MAIN:ZONENAME=Main", + "Send: @SYS:VERSION=?", + "Received: @SYS:VERSION=1.20/2.06", + "Send: @NETRADIO:AVAIL=?", + "Received: @NETRADIO:AVAIL=Not Ready", + "Send: @NETRADIO:PLAYBACKINFO=?", + "Received: @NETRADIO:PLAYBACKINFO=Stop", + "Send: @NETRADIO:STATION=?", + "Received: @NETRADIO:STATION=", + "Send: @SYS:VERSION=?", + "Received: @SYS:VERSION=1.20/2.06", + "Send: @SERVER:AVAIL=?", + "Received: @SERVER:AVAIL=Not Ready", + "Send: @SERVER:PLAYBACKINFO=?", + "Received: @SERVER:PLAYBACKINFO=Stop", + "Send: @SERVER:METAINFO=?", + "Received: @SERVER:ARTIST=", + "Received: @SERVER:ALBUM=", + "Received: @SERVER:SONG=", + "Send: @SERVER:REPEAT=?", + "Received: @SERVER:REPEAT=Off", + "Send: @SERVER:SHUFFLE=?", + "Received: @SERVER:SHUFFLE=Off", + "Send: @SYS:VERSION=?", + "Received: @SYS:VERSION=1.20/2.06", + "Send: @SPOTIFY:AVAIL=?", + "Received: @SPOTIFY:AVAIL=Not Ready", + "Send: @SPOTIFY:PLAYBACKINFO=?", + "Received: @SPOTIFY:PLAYBACKINFO=Stop", + "Send: @SPOTIFY:METAINFO=?", + "Received: @SPOTIFY:ARTIST=", + "Send: @SPOTIFY:REPEAT=?", + "Received: @SPOTIFY:ALBUM=", + "Send: @SPOTIFY:SHUFFLE=?", + "Received: @SPOTIFY:TRACK=", + "Received: @RESTRICTED", + "Received: @RESTRICTED", + "Send: @SYS:VERSION=?", + "Received: @SYS:VERSION=1.20/2.06", + "Send: @USB:AVAIL=?", + "Send: @USB:PLAYBACKINFO=?", + "Received: @USB:AVAIL=Not Ready", + "Received: @USB:PLAYBACKINFO=Stop", + "Send: @USB:METAINFO=?", + "Received: @USB:ARTIST=", + "Received: @USB:ALBUM=", + "Send: @USB:REPEAT=?", + "Received: @USB:SONG=", + "Received: @USB:REPEAT=Off", + "Send: @USB:SHUFFLE=?", + "Received: @USB:SHUFFLE=Off", + "Send: @SYS:VERSION=?", + "Received: @SYS:VERSION=1.20/2.06" + ], + "history": [ + "Received: @SYS:MODELNAME=RX-V500D", + "Send: @SYS:MODELNAME=?", + + "Received: @SYS:MODELNAME=RX-V500D", + "Send: @MAIN:PWR=On", + "Received: @MAIN:PWR=On", + "Received: @MAIN:AVAIL=Ready", + "Received: @MAIN:DIRMODE=Off", + "Received: @MAIN:INP=HDMI5", + "Received: @MAIN:MUTE=Off", + "Received: @MAIN:SOUNDPRG=Sci-Fi", + "Received: @MAIN:STRAIGHT=On", + "Received: @MAIN:VOL=-37.5", + "Received: @SYS:PWR=On", + "Received: @SYS:DMCCONTROL=Enable", + "Received: @SYS:HDMIOUT1=On", + "Send: @MAIN:INP=HDMI4", + "Received: @MAIN:INP=HDMI4", + "Received: @MAIN:ENHANCER=Off", + "Received: @MAIN:STRAIGHT=Off", + "Received: @MAIN:SOUNDPRG=5ch Stereo", + "Send: @MAIN:INP=HDMI5", + "Received: @MAIN:INP=HDMI5", + "Received: @MAIN:ENHANCER=Off", + "Received: @MAIN:STRAIGHT=On", + "Received: @MAIN:SOUNDPRG=Sci-Fi", + "Received: @MAIN:INP=TUNER", + "Received: @MAIN:ENHANCER=On", + "Received: @MAIN:STRAIGHT=Off", + "Received: @MAIN:SOUNDPRG=5ch Stereo", + + "Received: @DAB:AVAIL=Ready", + "Received: @DAB:BAND=DAB", + "Received: @DAB:DABAUDIOMODE=Stereo", + "Received: @DAB:DABDATETIME=04NOV'22 12:24", + "Received: @DAB:DABDLSLABEL=Now on Nova: Enemy by Imagine Dragons", + "Received: @DAB:DABENSEMBLELABEL=DAB ", + "Received: @DAB:DABOFFAIR=Negate", + "Received: @DAB:DABPRESET=5", + "Received: @DAB:DABPRGTYPE=None", + "Received: @DAB:DABSERVICELABEL=Nova ", + "Received: @DAB:FMPRESET=No Preset", + "Received: @DAB:FMRDSCLOCK=", + "Received: @DAB:FMRDSPRGSERVICE=", + "Received: @DAB:FMRDSPRGTYPE=", + "Received: @DAB:FMRDSTXT=", + "Received: @DAB:FMSEARCHMODE=Preset", + "Received: @DAB:FMSIGSTEREOMONO=Negate", + "Send: @MAIN:PWR=Standby", + "Received: @DAB:FMTUNED=Negate", + "Received: @MAIN:PWR=Standby", + "Received: @SYS:PWR=Standby" + ] + } + } +} + + +and + + "Received: @MAIN:PWR=On", + "Received: @MAIN:AVAIL=Ready", + "Received: @MAIN:DIRMODE=Off", + "Received: @MAIN:INP=HDMI5", + "Received: @MAIN:MUTE=Off", + "Received: @MAIN:SOUNDPRG=Sci-Fi", + "Received: @MAIN:STRAIGHT=On", + "Received: @MAIN:VOL=-40.0", + "Received: @SYS:PWR=On", + "Received: @SYS:DMCCONTROL=Enable", + "Received: @SYS:HDMIOUT1=On", + + "Received: @MAIN:INP=TUNER", + "Received: @MAIN:ENHANCER=On", + "Received: @MAIN:STRAIGHT=Off", + "Received: @MAIN:SOUNDPRG=5ch Stereo", + "Received: @DAB:AVAIL=Ready", + "Received: @DAB:BAND=DAB", + "Received: @DAB:DABAUDIOMODE=Stereo", + "Received: @DAB:DABDATETIME=05NOV'22 09:40", + "Received: @DAB:DABDLSLABEL=Now on Nova: Never Gonna Not Dance Again by Pink", + "Received: @DAB:DABENSEMBLELABEL=DAB ", + "Received: @DAB:DABOFFAIR=Negate", + "Received: @DAB:DABPRESET=5", + "Received: @DAB:DABPRGTYPE=None", + "Received: @DAB:DABSERVICELABEL=Nova ", + "Received: @DAB:FMPRESET=No Preset", + "Received: @DAB:FMRDSCLOCK=", + "Received: @DAB:FMRDSPRGSERVICE=", + "Received: @DAB:FMRDSPRGTYPE=", + "Received: @DAB:FMRDSTXT=", + "Received: @DAB:FMSEARCHMODE=Preset", + "Received: @DAB:FMSIGSTEREOMONO=Negate", + "Received: @DAB:FMTUNED=Negate", + "Received: @DAB:DABDLSLABEL=", + "Received: @DAB:DABCHLABEL= 9B", + "Received: @DAB:DABDLSLABEL=Now on Nova: Never Gonna Not Dance Again by Pink", + "Send: @SYS:MODELNAME=?", + "Received: @SYS:MODELNAME=RX-V500D", + + "Received: @MAIN:INP=HDMI5", + "Received: @MAIN:ENHANCER=Off", + "Received: @MAIN:STRAIGHT=On", + "Received: @MAIN:SOUNDPRG=Sci-Fi", + + "Received: @DAB:AVAIL=Not Ready", + "Received: @MAIN:INP=TUNER", + "Received: @MAIN:ENHANCER=On", + "Received: @MAIN:STRAIGHT=Off", + "Received: @MAIN:SOUNDPRG=5ch Stereo", + "Received: @DAB:AVAIL=Ready", + "Received: @DAB:BAND=FM", + "Received: @DAB:DABAUDIOMODE=Stereo", + "Received: @DAB:DABDATETIME=05NOV'22 09:40", + "Received: @DAB:DABDLSLABEL=Now on Nova: Never Gonna Not Dance Again by Pink", + "Received: @DAB:DABENSEMBLELABEL=DAB ", + "Received: @DAB:DABOFFAIR=Negate", + "Received: @DAB:DABPRESET=5", + "Received: @DAB:DABPRGTYPE=None", + "Received: @DAB:DABSERVICELABEL=Nova ", + "Received: @DAB:FMPRESET=No Preset", + "Received: @DAB:FMRDSCLOCK=", + "Received: @DAB:FMRDSPRGSERVICE=", + "Received: @DAB:FMRDSPRGTYPE=", + "Received: @DAB:FMRDSTXT=", + "Received: @DAB:FMSEARCHMODE=Tuning", + "Received: @DAB:FMSIGSTEREOMONO=Negate", + "Received: @DAB:FMTUNED=Negate", + "Received: @DAB:DABDLSLABEL=", + "Received: @DAB:FMRDSPRGSERVICE=", + "Received: @DAB:FMTUNED=Assert", + "Received: @DAB:FMSIGSTEREOMONO=Assert", + "Received: @DAB:FMRDSPRGTYPE=ROCK M", + "Send: @SYS:MODELNAME=?", + "Received: @SYS:MODELNAME=RX-V500D", + + "Received: @DAB:FMFREQ=92.95", + "Received: @DAB:FMTUNED=Negate", + "Received: @DAB:FMSIGSTEREOMONO=Negate", + "Received: @DAB:FMRDSPRGTYPE=", + "Received: @DAB:FMRDSPRGSERVICE=", + "Received: @DAB:FMFREQ=93.00", + "Received: @DAB:DABAUDIOMODE=Mono", + "Received: @DAB:FMFREQ=93.05", + "Received: @DAB:FMFREQ=93.10", + "Received: @DAB:FMFREQ=93.15", + "Received: @DAB:FMFREQ=93.20", + "Received: @DAB:FMFREQ=93.25", + "Received: @DAB:FMFREQ=93.30", + "Received: @DAB:FMFREQ=93.35", + "Received: @DAB:FMFREQ=93.40", + "Received: @DAB:FMFREQ=93.45", + "Received: @DAB:FMFREQ=93.50", + "Received: @DAB:FMFREQ=93.55", + "Received: @DAB:FMFREQ=93.60", + "Received: @DAB:FMFREQ=93.65", + "Received: @DAB:FMFREQ=93.70", + "Received: @DAB:DABAUDIOMODE=Stereo", + "Received: @DAB:FMTUNED=Assert", + "Received: @DAB:FMSIGSTEREOMONO=Assert", + "Send: @SYS:MODELNAME=?", + "Received: @SYS:MODELNAME=RX-V500D", + + "Received: @DAB:FMFREQ=93.65", + "Received: @DAB:FMTUNED=Negate", + "Received: @DAB:FMSIGSTEREOMONO=Negate", + "Received: @DAB:FMFREQ=Auto Down", + "Received: @DAB:FMFREQ=Auto Down", + "Received: @DAB:FMFREQ=93.60", + "Received: @DAB:FMFREQ=93.55", + "Received: @DAB:FMFREQ=93.50", + "Received: @DAB:FMFREQ=93.45", + "Received: @DAB:FMFREQ=93.40", + "Received: @DAB:FMFREQ=93.35", + "Received: @DAB:FMFREQ=93.30", + "Received: @DAB:FMFREQ=93.25", + "Received: @DAB:FMFREQ=93.20", + "Received: @DAB:FMFREQ=93.15", + "Received: @DAB:FMFREQ=93.10", + "Received: @DAB:FMFREQ=93.05", + "Received: @DAB:FMFREQ=93.00", + "Received: @DAB:FMFREQ=92.95", + "Received: @DAB:FMFREQ=92.90", + "Received: @DAB:FMTUNED=Assert", + "Received: @DAB:FMSIGSTEREOMONO=Assert", + "Received: @DAB:FMRDSPRGTYPE=ROCK M", + + "Received: @MAIN:INP=HDMI5", + "Received: @MAIN:ENHANCER=Off", + "Received: @MAIN:STRAIGHT=On", + "Received: @MAIN:SOUNDPRG=Sci-Fi", + + "Received: @DAB:AVAIL=Not Ready", + "Received: @MAIN:INP=TUNER", + "Received: @MAIN:ENHANCER=On", + "Received: @MAIN:STRAIGHT=Off", + "Received: @MAIN:SOUNDPRG=5ch Stereo", + "Received: @DAB:AVAIL=Ready", + "Received: @DAB:BAND=DAB", + "Received: @DAB:DABAUDIOMODE=Stereo", + "Received: @DAB:DABDATETIME=05NOV'22 09:40", + "Received: @DAB:DABDLSLABEL=", + "Received: @DAB:DABENSEMBLELABEL=DAB ", + "Received: @DAB:DABOFFAIR=Negate", + "Received: @DAB:DABPRESET=5", + "Received: @DAB:DABPRGTYPE=None", + "Received: @DAB:DABSERVICELABEL=Nova ", + "Received: @DAB:FMPRESET=No Preset", + "Received: @DAB:FMRDSCLOCK=", + "Received: @DAB:FMRDSPRGSERVICE=", + "Received: @DAB:FMRDSPRGTYPE=ROCK M", + "Received: @DAB:FMRDSTXT=", + "Received: @DAB:FMSEARCHMODE=Preset", + "Received: @DAB:FMSIGSTEREOMONO=Assert", + "Received: @DAB:FMTUNED=Assert", + "Received: @DAB:FMTUNED=Negate", + "Received: @DAB:FMSIGSTEREOMONO=Negate", + "Received: @DAB:DABDATETIME=05NOV'22 09:41", + "Received: @DAB:DABDLSLABEL=Now on Nova: Never Gonna Not Dance Again by Pink", + + "Received: @DAB:DABPRESET=6", + "Received: @DAB:DABSERVICELABEL=MMM 90s", + "Received: @DAB:DABDLSLABEL=", + "Send: @SYS:MODELNAME=?", + "Received: @SYS:MODELNAME=RX-V500D", + "Received: @DAB:DABBITRATE=32", + "Received: @DAB:DABDATETIME=05NOV'22 09:42", + "Received: @DAB:DABDLSLABEL=Now Playing: This Is A Call - Foo Fighters", + + "Received: @DAB:DABPRESET=5", + "Received: @DAB:DABSERVICELABEL=Nova ", + "Received: @DAB:DABDLSLABEL=", + "Received: @DAB:DABDLSLABEL=Now on Nova: Never Gonna Not Dance Again by Pink", + "Received: @DAB:DABBITRATE=48", + + "Received: @MAIN:INP=HDMI5", + "Received: @MAIN:ENHANCER=Off", + "Received: @MAIN:STRAIGHT=On", + "Received: @MAIN:SOUNDPRG=Sci-Fi", + "Received: @DAB:AVAIL=Not Ready", + "Received: @MAIN:PWR=Standby", + "Received: @SYS:PWR=Standby", + "Send: @SYS:MODELNAME=?", + "Received: @SYS:MODELNAME=RX-V500D" + ] + } + } +} diff --git a/tests/test_dab.py b/tests/test_dab.py index b62ac9f..ec4e4b2 100644 --- a/tests/test_dab.py +++ b/tests/test_dab.py @@ -1,6 +1,7 @@ import pytest from ynca import BandDab +from ynca.enums import DabPreset, FmPreset from ynca.subunits.dab import Dab SYS = "SYS" @@ -19,12 +20,24 @@ (SUBUNIT, "BAND", "FM"), ], ), + ( + (SUBUNIT, "DABPRESET"), + [ + (SUBUNIT, "DABPRESET", "33"), + ], + ), ( (SUBUNIT, "FMFREQ"), [ (SUBUNIT, "FMFREQ", "101.60"), ], ), + ( + (SUBUNIT, "FMPRESET"), + [ + (SUBUNIT, "FMPRESET", "40"), + ], + ), ( (SUBUNIT, "FMRDSINFO"), [ @@ -36,7 +49,7 @@ SUBUNIT, "DABDATETIME", "13DEC'22 11:05", - ), # DAB is a bit weird, but it came from a log + ), # DAB is a bit weird, but it came from a log OF RX-V500D ], ), ( @@ -115,8 +128,30 @@ def test_fmrds(connection, initialized_dab: Dab): assert initialized_dab.fmrdstxt == "radiotext" -def test_fmsignal(connection, initialized_dab: Dab): +def test_fmfreq(connection, initialized_dab: Dab): # Set value and test stepsize handling (which is why it becomes 100.00) initialized_dab.fmfreq = 100.05 connection.put.assert_called_with(SUBUNIT, "FMFREQ", "100.00") + + +def test_fmpreset(connection, initialized_dab: Dab): + + assert initialized_dab.fmpreset == 40 + + initialized_dab.fmpreset = 12 + connection.put.assert_called_with(SUBUNIT, "FMPRESET", "12") + + connection.send_protocol_message(SUBUNIT, "FMPRESET", "No Preset") + initialized_dab.fmpreset = FmPreset.NO_PRESET + + +def test_dabpreset(connection, initialized_dab: Dab): + + assert initialized_dab.dabpreset == 33 + + initialized_dab.dabpreset = 22 + connection.put.assert_called_with(SUBUNIT, "DABPRESET", "22") + + connection.send_protocol_message(SUBUNIT, "DABPRESET", "No Preset") + initialized_dab.dabpreset = DabPreset.NO_PRESET diff --git a/tests/test_enums.py b/tests/test_enums.py index 96be1b3..b1fb534 100644 --- a/tests/test_enums.py +++ b/tests/test_enums.py @@ -6,7 +6,9 @@ Avail, BandDab, BandTun, + DabPreset, Enhancer, + FmPreset, HdmiOut, HdmiOutOnOff, InitVolLvl, @@ -34,7 +36,9 @@ def test_invalid_values_on_enums(): assert Avail("x") is Avail.UNKNOWN assert BandDab("x") is BandDab.UNKNOWN assert BandTun("x") is BandTun.UNKNOWN + assert DabPreset("x") is DabPreset.UNKNOWN assert Enhancer("x") is Enhancer.UNKNOWN + assert FmPreset("x") is FmPreset.UNKNOWN assert HdmiOut("x") is HdmiOut.UNKNOWN assert HdmiOutOnOff("x") is HdmiOutOnOff.UNKNOWN assert InitVolLvl("x") is InitVolLvl.UNKNOWN diff --git a/ynca/enums.py b/ynca/enums.py index 68446ec..8b07d4c 100644 --- a/ynca/enums.py +++ b/ynca/enums.py @@ -7,6 +7,7 @@ UNKNOWN_STRING = "< UNKNOWN >" + @unique class AdaptiveDrc(str, Enum): OFF = "Off" @@ -64,6 +65,19 @@ def _missing_(cls, value): """Unknown values in the enum are mapped to UNKNOWN""" +@unique +class DabPreset(str, Enum): + NO_PRESET = "No Preset" + + @classmethod + def _missing_(cls, value): + logger.warning("Unknown value '%s' in %s", value, cls.__name__) + return cls.UNKNOWN + + UNKNOWN = UNKNOWN_STRING + """Unknown values in the enum are mapped to UNKNOWN""" + + @unique class Enhancer(str, Enum): ON = "On" @@ -78,6 +92,19 @@ def _missing_(cls, value): """Unknown values in the enum are mapped to UNKNOWN""" +@unique +class FmPreset(str, Enum): + NO_PRESET = "No Preset" + + @classmethod + def _missing_(cls, value): + logger.warning("Unknown value '%s' in %s", value, cls.__name__) + return cls.UNKNOWN + + UNKNOWN = UNKNOWN_STRING + """Unknown values in the enum are mapped to UNKNOWN""" + + @unique class HdmiOut(str, Enum): OFF = "Off" @@ -207,6 +234,7 @@ def _missing_(cls, value): UNKNOWN = UNKNOWN_STRING """Unknown values in the enum are mapped to UNKNOWN""" + @unique class Party(Enum): ON = "On" diff --git a/ynca/function.py b/ynca/function.py index 902e6f5..1e03ccf 100644 --- a/ynca/function.py +++ b/ynca/function.py @@ -110,7 +110,7 @@ def __init__( super().__init__( name_override=name_override, cmd=cmd, - converter=EnumConverter[E](datatype), + converter=EnumConverter(datatype), init=init, ) @@ -176,6 +176,23 @@ def __init__( name_override=name_override, cmd=cmd, converter=converter - or MultiConverter([EnumConverter[E](datatype), FloatConverter()]), + or MultiConverter([FloatConverter(), EnumConverter(datatype)]), # Float first because enum will convert to UNKNOWN + init=init, + ) + +class EnumOrIntFunctionMixin(FunctionMixinBase, Generic[E]): + def __init__( + self, + datatype: Type[E], + converter: MultiConverter | None = None, + cmd: Cmd = Cmd.GET | Cmd.PUT, + name_override: str | None = None, + init=None, + ) -> None: + super().__init__( + name_override=name_override, + cmd=cmd, + converter=converter + or MultiConverter([IntConverter(), EnumConverter(datatype)]), # Int first because enum will convert to UNKNOWN init=init, ) diff --git a/ynca/server.py b/ynca/server.py index 604d9e6..96d98ec 100644 --- a/ynca/server.py +++ b/ynca/server.py @@ -214,6 +214,11 @@ def handle_put(self, subunit, function, value): if len(value) != 8: self.write_line(UNDEFINED) return + + # MEM does not seem to generate a response + # assume it was supported for the subunit + if function == "MEM": + return if function == "VOL" and value.startswith("Up") or value.startswith("Down"): # Need to handle Up/Down as it would otherwise overwrite the VOL value wtih text Up/Down diff --git a/ynca/subunits/dab.py b/ynca/subunits/dab.py index 5e4aa53..1f20d34 100644 --- a/ynca/subunits/dab.py +++ b/ynca/subunits/dab.py @@ -1,15 +1,20 @@ from __future__ import annotations from ..constants import Subunit -from ..function import Cmd, EnumFunctionMixin, StrFunctionMixin -from ..enums import ( - BandDab, +from ..converters import IntOrNoneConverter +from ..enums import BandDab, DabPreset, FmPreset +from ..function import ( + Cmd, + EnumFunctionMixin, + EnumOrIntFunctionMixin, + IntFunctionMixin, + StrFunctionMixin, ) from ..subunit import SubunitBase -from . import FmFreqFunctionMixin +from . import FmFreqFunctionMixin, MemFunctionMixin -class Dab(SubunitBase, FmFreqFunctionMixin): +class Dab(SubunitBase, FmFreqFunctionMixin, MemFunctionMixin): id = Subunit.DAB band = EnumFunctionMixin[BandDab](BandDab) @@ -18,8 +23,10 @@ class Dab(SubunitBase, FmFreqFunctionMixin): dabdlslabel = StrFunctionMixin(Cmd.GET) dabensemblelabel = StrFunctionMixin(Cmd.GET) dabservicelabel = StrFunctionMixin(Cmd.GET) + dabpreset = EnumOrIntFunctionMixin[DabPreset](DabPreset) dabprgtype = StrFunctionMixin(Cmd.GET) + fmpreset = EnumOrIntFunctionMixin[FmPreset](FmPreset) fmrdsprgservice = StrFunctionMixin(Cmd.GET, init="FMRDSINFO") fmrdsprgtype = StrFunctionMixin(Cmd.GET, init="FMRDSINFO") fmrdstxt = StrFunctionMixin(Cmd.GET, init="FMRDSINFO")