getCurrentPreset method
Implementation
Future<Preset?> getCurrentPreset(String profileToken) async {
loggy.debug('getCurrentPreset');
Preset? matchedPreset;
final presets = await getPresets(profileToken);
if (presets.first.position == null) {
throw Exception(
'Preset position is not available, the getCurrentPreset method can not be used on this device.');
}
final ptzStatus = await getStatus(profileToken);
for (var preset in presets) {
if (_matchPositionSettings(preset, ptzStatus)) {
matchedPreset = preset;
break;
}
}
return matchedPreset;
}