ol-iver / denonavr

Automation Library for Denon AVR receivers.
MIT License
176 stars 67 forks source link

Input and validation scheme for XML commands. #95

Closed JPHutchins closed 4 years ago

JPHutchins commented 5 years ago

Here is what I have come up with for formatting commands gleaned from the XML data dump. I have included one example command. Here we use XmlCommand3 class because this is a command with the cmd id="3" (AppCommand0300.xml endpoint). We enter first a friendly name, then the command name according to data dump, then a tuple representing the min and max values acceptable, then the param name as required by the API, then optionally enter a list which is going to allow the dev to later issue a string command, see below.

SET_DYNAMIC_VOL = XmlCommand3(
    "Dynamic Volume", "SetAudyssey",
    (0, 3), param="dynamicvol",
    values=[
        "Off",
        "Light",
        "Medium",
        "Heavy"]
)

In the main file you can see that we can now call this method: denonavrobject.set_dynamic_range("Light") which would send the "1" command corresponding to its place on the list during object construction. Error handling allows dev to send 1 or "1" as well for the same result.

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.