Chosen Solution

I recently replaced the mac keybaord+trackpad assembly because the keyboard went haywire randomly. After the replacement, the system doesn’t sleep when lid is closed. Tried resetting the SMC and PRAM. I think its a sleep/close lid sensor issue? Any help how i can locate the sensor, and make sure its the issue before ordering a part. I saw videos for MBP to put the system to sleep using magnet. i treid running a magnet around the screen and keyboard. nothing happend Help appreciated. Update (07/07/2018) Just FYI, this unit had a very peculiar problem. Remember the volcanic eruption in Bali couple of years ago? My friend (the real owner this laptop) was there when it happened. Soon, after couple of days, the keyboard and trackpad goes crazy, random keypress, random trackpad movement, some keys not working, after the system is on for sometime. When i opened the unit, i did find deposits of volcano ashes under the trackpad , and keyboard/trackpad connectors. and along the air vents. Luckily none the IO or main board. But the right side USB, doesn’t work as well. I am not sure if the sleep problem is because of that. I had to replace the whole upper body case assembly with keyboard and track pad to solve the keyboard/trackpad issue.

The sensor is part of the I/O board

To make sure I would first take a steel paper clip to locate the magnet in the lid, then carefully fold the lid down a piece so you can locate were the clip would be on the uppercase top (use a piece of tape to part the spot). This is the location you’ll need to slide the magnet across. I use this method as the better way as it also checks the magnet and its location in the lid. I would also make sure the I/O cable is fully seated. You may need a new cable as well. MacBook Air 13" Mid 2013 I/O Board Replacement and heres the needed part: MacBook Air 13" (Mid 2013-2017) I/O BoardMacBook Air 13" Mid 2013 I/O Board Cable Replacement and here’s the needed part MacBook Air 13" (Mid 2013-2017) I/O Board Cable