toBridgeObject method

  1. @override
Map toBridgeObject({
  1. String? action,
})

Implementation

@override
Map toBridgeObject({String? action}) {
  if ('create' == action) {
    return {
      'name': name,
      'description': description ?? '',
      'localtime': time,
      'command': command!.toBridgeObject(),
      'status': status ?? 'enabled',
      'autodelete': autoDelete ?? true,
      'recycle': recycle ?? false
    };
  } else if ('attributes' == action) {
    final body = {};
    if (name != null) {
      body['name'] = name;
    }
    if (description != null) {
      body['description'] = description;
    }
    if (time != null) {
      body['localtime'] = time;
    }
    if (command != null) {
      body['command'] = command;
    }
    if (status != null) {
      body['status'] = status;
    }
    return body;
  }
  return {};
}