function buildFeatures(deviceName, deviceExternalId, broadlinkDevice) {
  const { TYPE, getEnergy } = broadlinkDevice;
  const features = [];

  // check for number of switch features
  const nbSwitch = TYPE === 'MP1' ? 4 : 1;

  for (let i = 0; i < nbSwitch; i += 1) {
    const switchNb = i + 1;
    const featureExternalId = `${deviceExternalId}:switch:${switchNb}`;
    features.push({
      name: `${deviceName}${nbSwitch > 1 ? ` ${switchNb}` : ''}`,
      category: DEVICE_FEATURE_CATEGORIES.SWITCH,
      type: DEVICE_FEATURE_TYPES.SWITCH.BINARY,
      external_id: featureExternalId,
      selector: featureExternalId,
      min: 0,
      max: 1,
      read_only: false,
      has_feedback: false,
    });
  }

  // check for energy sensor
  if (typeof getEnergy === 'function') {
    const featureExternalId = `${deviceExternalId}:energy-sensor`;
    features.push({
      name: `${deviceName} energy`,
      category: DEVICE_FEATURE_CATEGORIES.ENERGY_SENSOR,
      type: DEVICE_FEATURE_TYPES.ENERGY_SENSOR.ENERGY,
      external_id: featureExternalId,
      selector: featureExternalId,
      min: 0,
      max: 1000,
      unit: DEVICE_FEATURE_UNITS.WATT,
      read_only: true,
      has_feedback: false,
    });
  }

  return features;
}
@description Builds switch Broadlink features.
@param {string} deviceName - Device name.
@param {string} deviceExternalId - Device external ID.
@param {object} broadlinkDevice - Broadlink device.
@returns {Array} Gladys features.
@example
buildFeatures(a1Device);