Assalamualaikum ustaz. Is it true that when a donkey brays, it is a sign that it sees a devil?
Waalaikumussalam wrt. wbt.,
Alhamdulillah, praise and gratitude to Allah SWT for His countless blessings for us all. Praise and salutations to our beloved Prophet Muhammad PBUH, his family, companions, and all those who follow his footsteps until the Final day.
Allah SWT states:
وَاقْصِدْ فِي مَشْيِكَ وَاغْضُضْ مِن صَوْتِكَ ۚ إِنَّ أَنكَرَ الْأَصْوَاتِ لَصَوْتُ الْحَمِيرِ
“And be moderate in your pace and lower your voice; indeed, the most disagreeable of sounds is the voice of donkeys.” 
In al-Tafsir al-Muyassar, it is stated that the most hated voice is the voice of a donkey which is known for its stupidity and its loud voice. 
The question regarding a donkey’s disagreeable voice as a sign that a donkey sees a devil as stated in a hadith narrated by Abu Hurairah RA, where the Prophet PBUH said:
إِذَا سَمِعْتُمْ صِيَاحَ الدِّيَكَةِ فَاسْأَلُوا اللَّهَ مِنْ فَضْلِهِ، فَإِنَّهَا رَأَتْ مَلَكًا، وَإِذَا سَمِعْتُمْ نَهِيقَ الحِمَارِ فَتَعَوَّذُوا بِاللَّهِ مِنَ الشَّيْطَانِ، فَإِنَّهُ رَأَى شَيْطَانًا
“When you hear the cock’s crow, ask Allah for His favor upon you for surely it has seen an angel. When you hear the bray of a donkey, seek refuge in Allah from Satan, for surely it has seen a devil.” 
In another narration, it is stated from Jabir bin Abdullah RA, Rasullullah PBUH said:
إِذَا سَمِعْتُمْ نُبَاحَ الْكِلَابِ، وَنَهِيقَ الْحُمُرِ بِاللَّيْلِ، فَتَعَوَّذُوا بِاللَّهِ فَإِنَّهُنَّ يَرَيْنَ مَا لَا تَرَوْنَ
“When you hear a dog barking or a donkey braying in the night, then seek refuge in Allah from them, for surely, they have seen what you see not.” 
This hadith shows that not only the voice of a donkey means that it sees a devil, but a dog barking also means as such.
Syeikh Abd al-Muhsin al-Abbad stated in his syarah: This hadith shows the bond in asking for protection at night, however, the previous hadith is general and isn’t bound to time. When people hear the voice of a donkey braying during the day, they should also ask for protection from Allah. This may be due to the reason that the devils usually roam at night. 
Syeikh Athiyah Saqr in his book Fatawa Dar al-Ifta’ al-Misriyyah stated: “The lessons that we can take from these hadiths is that animals are able to see unseen creations of Allah SWT from our sight that we cannot see. However, the relation between what animals can see and we cannot see such as angels and jinn stopped in a hadith of the Prophet PBUH with a sahih route.” 
Asking for protection from Allah
Ibn Hajar al-Asqalani cited ‘Iyadh, he said: Wisdom from this hadith is the commandment of asking protection to Allah SWT from the evils of the devil and its whispers of doubt by asking protection from Allah to avoid their evil. 
Syihabuddin Ahmad bin Muhammad al-Qastalani in his syarah said: When we hear the sound or voice of a donkey braying, then ask for protection from Allah SWT so that we are protected from any evil and harms of doubts from the devil. 
While Syeikh Syams al-Haq al-Azim Abadi stated in his syarah: Allah SWT’s wrath when we see a person who sins descend, hence, it is sunnah for us to ask for protection from Allah SWT. 
Research regarding the eyes of dogs and donkeys 
A study conducted by an Egyptian physician, Dr Hisham Ahmad Taha, has answered why donkeys and dogs can see the devil. From the studies conducted, donkeys and dogs belong to the category of animals that can see infrared rays. These rays are located at wavelengths of 750 nanometers up to 1 millimetre. While the devils that have been studied by scientists are also in the group of infrared waves. The reason is not impossible if donkeys and dogs can see the devil. This is because the devils, demons and jinn were made of fire.
To close, we state that donkeys and dogs can see devils as stated by Rasullullah PBUH in the above hadith. Thus, when a person hears the bray of a donkey or bark of a dog, then we are taught to supplicate asking for Allah SWT to be protected from the disturbances of the devil, jinn and iblees who always try to lead people astray.
Lastly, may Allah SWT grant us understanding in this religion. Amin.
 Surah Luqman: 19
 See al-Tafsir al-Muyassar, hlm. 412.
 Narrated by al-Bukhari, (3058), Muslim (4908), Abu Dawud, (4438) and al-Tirmizi, (3381)
 Narrated by Abu Dawud (5103), al-Nasaie in al-Sunan al-Kubra (10778) and Ahmad (14283). Syeikh Syuaib al-Arnout in Takhrij al-Musnad (14283) the sanad of this hadith is Hasan.
 See Syarh Sunan Abi Dawud li al-Abbad, 8/579
 See Fatawa Dar al-Ifta’ al-Misriyyah, 7/439
 See Fath al-Bari, 6/353
 See Irsyad al-Sari li Syarh Sahih al-Bukhari, 5/309
 See Aun al-Ma’bud, 9/238