setDoorState method
Implementation
Future<Map<String, dynamic>> setDoorState(
String serialNumber, String action) async {
try {
switch (action.toLowerCase()) {
case 'open':
case 'close':
return await _setDeviceState(serialNumber, action.toLowerCase(),
constants['stateAttributes']!['doorState'] as String?);
default:
throw MyQError(
'Invalid Action parameter "$action" specified for door; valid actions are open and close',
constants['codes']!['INVALID_ARGUMENT'] as String?);
}
} on MyQError catch (e) {
if (e.code == constants['codes']!['DEVICE_STATE_NOT_FOUND']) {
throw MyQError(
'device with serial number "$serialNumber" is not a door',
'Invalid Device');
}
throw e;
}
}