Switch as X - programmatically?

Is there a way to create a Light from a switch programmatically (ie. not using the Helper GUI?). I have around 40 Z-wave switches in the house that control lights or fans. I’d like to be able to create them in YAML in case I need to recreate my home assistant. Is there any way to do this?

Thanks