The sensor is in the left hand bonnet switch, and if it fails or stops working properly, you will get the warning message that the bonnet is open and the alarm will malfunction because it also senses that the bonnet is open.
Sometimes, cleaning and lubrication of the catch and switch can help. Eventually, it may need replacing.
This may help:
https://www.volvov40club.com/threads...9/#post-310134