Switch several switches at same time with binary coded integer?

I use 4 gpio pins as 4 switches to control a ventilation device that uses BCD coded input for setting the level. At the moment I manually break up the level (integer) into the 4 bits in HA and switch the ESP switches sequentially with the results.
Does anyone know if there is a solution to send an integer to ESPHome which switches the binary equivalent gpio‘s?
Example. Send a ‘5’ and gpios 2 and 0 switch on and 1 and 3 switch off.