mysa-js-sdk
    Preparing search index...

    Function buildFanSpeedSendMap

    • Builds the send-side fan-speed fn mapping for a device, for the mode the command will leave it in.

      Sources are consulted from most to least specific:

      1. The target mode's own SupportedCaps.modes[md].fanSpeeds, mapped by value. A device can accept different speeds per mode — an AC-V1-0 offers all four in heat and cool, but only auto in dry — and only this list reflects that.
      2. The device-wide SupportedCaps.fanSpeeds, zipped positionally with CanonicalFanSpeedOrder, so that a list of 1, 2, 4, 6 reads as auto, low, medium and high respectively.
      3. The union of every mode's list, mapped by value — for devices that enumerate speeds per mode but publish no device-wide list, and for callers that did not name a mode.
      4. Failing all of those, CodeNum=1117 (AC-V1-X) devices use the CanonicalFanSpeedSendMap (they use canonical fn values even without enumerating them) and every other device the LegacyFanSpeedSendMap, preserving backward compatibility.

      Parameters

      • device: DeviceBase

        The device to build the mapping for.

      • Optionalmode: MysaDeviceMode

        The mode the device will be in, when known. Without it the mapping cannot be mode-specific and falls through to the device-wide sources.

      Returns Partial<Record<MysaFanSpeedMode, number>>

      A partial map from fan speed to the device-specific fn value.