automatically shutting down an ESXi host nightly
I'd personally let the server run or move it to a better running environment. This may not be worth automating.
If you must shut down the entire host, please make sure that your VMs have the VMWare tools installed (to allow graceful shutdown and power up) and that they're set to stop and start with the host.
You can use the vCli and schedule a cron job to place the host in maintenance mode and/or shut down the host entirely. I would probably just manually run the host shutdown command from the GUI client at the end of the day, though.
Before auto shutdown you should look at the host power settings and adjust them acordingly. See https://www.vmware.com/files/pdf/techpaper/hpm-performance-vsphere55-white-paper.pdf powercycling (and also thermalcycling from what you say) will reduce the lifespan of the server
vCli has already been mentioned and it is a best way to go in my opion.
However it seems you are dealing with a bigger problem , i.e overheating server room.This needs to be dealt with on a correct level.Fix HVAC asap or you will damage your equipment eventually.Read on http://www.openxtra.co.uk/articles/skimp-server-room-ac