It turns out that in order to get the correct switch instead of lightning, you need to define "state_topic" in addition to "command_topic". That's not all! HA checks whether "state_topic" really exists - presumably it checks whether the MQTT broker publishes such a thing. If all conditions are fulfilled, the "lightning" turns into a regular switch.