A device, method, and processor-readable medium for water quality detection and diversion are disclosed. Water entering a building's plumbing system is tested for impurities before it routes for consumption. Impurities in the water could include bacteria, viruses, chemicals, toxins, fertilizers, minerals, biological weapons, radioactive materials, and radioactive waste. Sensors are located throughout the device to check for impurities in the water as it travels through the building's plumbing. Certain sensors decide how to route the water through various treatments within the device. Treatments to the impure water could include multi-level filtration and heating/cooling cycles for a prescribed time period to reduce impurities below an EPA-approved threshold. If the water still retains impurities after treatment in the device, the device can decide to divert the water out of the building to prevent consumption and illness to building occupants.