responseToDeviceTraitConverter static method
Implementation
static List<Trait> responseToDeviceTraitConverter(List deviceTraits) {
// There are two generated types which probably should be same
// We probably can clean it up a little bit to avoid duplications
if (deviceTraits.length == 0) {
return [];
}
return deviceTraits.map<Trait>((trait) {
switch (trait.name as GTraitName) {
case _traitNames.THERMOSTAT_SETTING:
return ThermostatRepository.getThermostatTrait(trait);
case _traitNames.LOCK:
return LockRepository.getLockTrait(trait);
case _traitNames.BATTERY_LEVEL:
return BatteryLevelRepository.getBatteryLevelTrait(trait);
case _traitNames.POWER:
return PowerRepository.getPowerTrait(trait);
case _traitNames.BRIGHTNESS:
return BrightnessRepository.getBrightnessTrait(trait);
case _traitNames.COLOR:
return ColorRepository.getColorTrait(trait);
case _traitNames.COLOR_TEMPERATURE:
return ColorTemperatureRepository.getColorTemperatureTrait(trait);
case _traitNames.PIN_CODE_CREDENTIAL:
return PinCodeRepository.getPinCodeTrait(trait);
default:
return UnknownTrait(trait.name.toString());
}
}).toList();
}