The switch
component automatically creates corresponding HA entities for each ESP entity and it syncs all changes back and forth with the associated GPIOs.
The output
component does not create any corresponding HA entities. So with output
you create access to the GPIOs that is only meant to be used internally by ESP logic but not mirrored to HA.
The relevant change was simply to replace “switch” by “output”.