this looks like hole in logic. For me it looks like at least params["type"] should be mandatory as creating device "5" is useless so it should be forced and above if is not needed