Facedown function in IOS app

I would like a facedown detection in the IOS-app to get an signal in Home Assistant that the phone is still and facing display down.
This could be a really simple and effective way to trigger night mode something i haven’t figured out a good way to automate yet, and maybe also a morning mode trigger.
The feature should already exist in IOS since the display don’t light up when there is a notification when the display are facing downwards.

Thanks

/Andreas

iOS developer here.

What you want is doable while an application is active, on-screen, and the device is unlocked. At all other times it ranges from less-doable to impossible.

What I would do is use the new Bayesian sensor to bring together: the reported charging state of the phone, the time of day (sun.state == below_horizon), and perhaps a light that’s off or a motion sensor that’s cleared. Together you can estimate the probability that it’s “night” and do the needful.

Personally, I use the sun’s elevation to trigger evening (sun.elevation is trending down and is currently below 12º) and then just tell Alexa when I’m in bed with an intent script (“Alexa, tell Rosie good night”).

Ok that’s to bad, would have been a nice solution.
I will look in to the bayesian sensor that’s something new for me. Cheers