You can simply go to the configuration page of your HA App for Android, select “configure sensors” and scroll down until you find the sensor “Last Update Trigger”. In the newest version of the HA App there is now the oppurtunity to not just listen to the Boradcasts that come from the Android system but also to listen to custom broadcasts you can define at the bottom of the options. If you're using Gadgetbridge I would recommend you to set the two broadcasts nodomain.freeyourgadget.gadgetbridge.WokeUp as well as nodomain.freeyourgadget.gadgetbridge.FellAsleep. Next got to your Gadgetbridge App and enable under the decive settings the option “Send broadcast”.
And thats it already! Your “Last Update Trigger” will now show one of the two broadcasts you defined above if your fitnesstracker realizes you fell asleep. You can use this e.g. as a trigger to turn off the lights when you fall asleep or just let your alarm stop after your fitnesstracker realized, that you woke up.