mgth/LittleBigMouse · error · ArgumentException

Invalid VIDAA remote key.

Error message

Invalid VIDAA remote key.

What it means

TranslateKey maps library-facing remote key names to VIDAA protocol key codes. Keys not matching a known alias and not already starting with 'KEY_' are rejected with ArgumentException naming the key parameter. It is a whitelist check to avoid sending garbage key codes to the TV.

Solutions

  1. Use a recognized key constant (e.g. KEY_POWER, KEY_VOLUP, KEY_OK) or an alias from the mapping table
  2. Uppercase the name and prefix it with KEY_ if your key is not in the alias table
  3. Extend/wrap TranslateKey with your own mapping before calling it
  4. Check the VIDAA remote key list in the protocol source for valid names

Example fix

// before
var code = HisenseVidaaProtocol.TranslateKey("volume_up"); // throws
// after
var code = HisenseVidaaProtocol.TranslateKey("KEY_VOLUP");
Defensive patterns

Strategy: validation

Validate before calling

bool IsValidVidaaKey(string k) =>
    k.StartsWith("KEY_", StringComparison.Ordinal) || KnownAliases.Contains(k);

Type guard

bool IsRemoteKey(object k) => k is string s && s.Length > 0 && (s.StartsWith("KEY_") || AliasTable.ContainsKey(s));

Try / catch

try { code = TranslateKey(key); }
catch (ArgumentException ex) { log.Warn($"Unknown key {key}"); }

Prevention

When it happens

Trigger: Calling TranslateKey with a name like "volume_up", "OK", "power", or an empty string that isn't in the alias table and lacks the KEY_ prefix.

Common situations: Binding UI buttons to invented key names; translating from another remote-control library's key names; casing mistakes (VIDAA keys are uppercase with underscores).

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of mgth/LittleBigMouse@7a42f01d47 (2026-09-16). Data as JSON: /api/errors/e698626fb50d54c1. Report an issue: GitHub.

Appendix: source

Thrown at LittleBigMouse.Plugins/LittleBigMouse.Plugin.Vcp.Avalonia/HisenseVidaa/HisenseVidaaProtocol.cs:121

            model,
            NormalizeMac(mac),
            protocol,
            First(raw, "brand") is { Length: > 0 } brand ? brand : "his");
    }

    public static string TranslateKey(string key) => key.Trim().ToUpperInvariant() switch
    {
        "KEY_ENTER" => "KEY_OK",
        "KEY_RETURN" => "KEY_RETURNS",
        "KEY_VOLUP" => "KEY_VOLUMEUP",
        "KEY_VOLDOWN" => "KEY_VOLUMEDOWN",
        "KEY_CHUP" => "KEY_CHANNELUP",
        "KEY_CHDOWN" => "KEY_CHANNELDOWN",
        "KEY_PLAYPAUSE" => "KEY_PLAY",
        "KEY_FF" => "KEY_FORWARDS",
        "KEY_REWIND" => "KEY_BACKWARDS",
        var value when value.StartsWith("KEY_", StringComparison.Ordinal) => value,
        _ => throw new ArgumentException("Invalid VIDAA remote key.", nameof(key)),
    };

    public static string Topic(string service, string clientId, string action)
        => $"/remoteapp/tv/{service}/{clientId}/actions/{action}";

    /// <summary>
    /// The token exchange is asked for on a <c>data</c> topic rather than through
    /// <see cref="Topic"/>'s <c>actions</c> namespace.
    /// </summary>
    public static string TokenRequestTopic(string clientId)
        => $"/remoteapp/tv/platform_service/{clientId}/data/gettoken";

    /// <summary>An empty refresh token asks for a first pair of tokens.</summary>
    public static string TokenRequestPayload() => "{\"refreshtoken\":\"\"}";

    public static string PictureSettingPayload(int menuId, int value)
    {
        if (menuId is < 1 or > 999)

View on GitHub (pinned to 7a42f01d47)