In my last post I mentioned I had tried everything. Reset the SMC, reset the PRAM, reseated the RAM, reloaded the OS, tried both the wifi and USB keyboards, tried a number of energy settings. All to no effect. The only way to wake the 27" from sleep is to switch off at the wall and wait 15-20 seconds before switching back on again. However, I found the problem went away when the USB network was disconnected. As this was a new iMac I was still using my USB 2.0 network. Either it was a cable, the hub or an external drive that was connected. The problem existed 100% of the time if the drive was connected, it was intermittent if the network is connected. So I have ordered USB 3 cables, hub and enclosure for the drive.
I installed a 15ft USB cable, a 7 port USB 3 Anker hub and a USB enclosure for my existing drive. Since installing these several days ago, I have not turned my Mac off and it has woken from sleep every time. In fact every time I see that my mac is asleep I wake it just for the fun of seeing it wake properly. If the non waking issue appears again I will let you know.