Sleep mode on a computer suspends its current state to the RAM. The computer will then go into a low power mode keeping enough power going to the RAM to keep the suspended state. No applications are running at this time.
To wake the computer back up from a remote session would have to be done by a WOL (Wake On LAN) which is controlled by the motherboard. This would then wake the system back up. ssh daemons would not be running at the time the system is asleep so you would not be able to connect to the host that way. Once the magic packet is sent to WOL, the system would no longer be in the sleep state so the answer would be false every time for sleep.
There would be one other way to find out if a system is powered on or not from a remote console but that requires special hardware that supports Out-of-band Management that is normally built into server hardware. There are some remote power management items that can be purchased for systems without the management, but they can be pricey and only control the power itself. Here are some that I did a quick search for.
Sleep mode on a computer suspends its current state to the RAM. The computer will then go into a low power mode keeping enough power going to the RAM to keep the suspended state. No applications are running at this time.
To wake the computer back up from a remote session would have to be done by a WOL (Wake On LAN) which is controlled by the motherboard. This would then wake the system back up. ssh daemons would not be running at the time the system is asleep so you would not be able to connect to the host that way. Once the magic packet is sent to WOL, the system would no longer be in the sleep state so the answer would be false every time for sleep.
See https://en.wikipedia.org/wiki/Sleep_mode for more information.
There would be one other way to find out if a system is powered on or not from a remote console but that requires special hardware that supports Out-of-band Management that is normally built into server hardware. There are some remote power management items that can be purchased for systems without the management, but they can be pricey and only control the power itself. Here are some that I did a quick search for.
Hope this helps!