UniFi UI allows people to create device names with blanks - of course these don't end up as valid hostnames. This is a very simplistic fix that replaces blanks with underscores. It allows for piggyback processing of the devices.