Microorganisms often live in environments that fluctuate between mild and harsh conditions. Although such fluctuations are bound to cause local extinctions and affect species diversity, it is unknown how diversity changes at different fluctuation rates and how this relates to changes in species interactions. Here, we use a mathematical model describing the dynamics of resources, toxins, and microbial species in a chemostat where resource supplies switch. Over most of the explored parameter space, species competed, but the strength of competition peaked at either low, high or intermediate switching rates depending on the species' sensitivity to toxins. Importantly, however, the strength of competition in species pairs was a good predictor for how community diversity changed over the switching rate. In sum, predicting the effect of environmental switching on competition and community diversity is difficult, as species' properties matter. This may explain contradicting results of earlier studies on the intermediate disturbance hypothesis.