Switch Fan ON/OFF - How To?

I have a fan connected to pin 4&6. I need to switch it on/off with a button on dashboard. Is it possible?

To pin 4&6 of what? What is the entity type?

GPIO of Raspberry Pi 4 > 5v+gnd pin

Direct support by HA of GPIO’s has been discontinued for a while. I use MQTT. On RPi side you have to setup MQTT on RPi

I have found this: Can help?

I never succeeded to make it work, hence MQTT. Maybe you will be luckier.

So u can confirm that is possible power on/off the 5V pin showned in the picture where i have connected a cooling fan ?

The library is for driving GPIO’s. I’m not aware of any mean to switch off the 5V output. You should set up some circuitry driven by a GPIO to achieve your goal,