This is one area where Apple seriously falls behind Android. Shortcuts just pales in comparison to the power and depth that Tasker offers Android users. Tasker lets you delve into reading and often modifying all sorts of system and app variables. For example on iOS I still cannot test (read only) for a condition of a WiFi network being lost (only tests for connected to a network - why?).
In the case of this post it is Google that has exposed an API for sleep tracking features which Tasker can make use of locally on your phone. This means instead of subscribing to, or passing sleep data to a cloud service, you could use Tasker locally to achieve a lot of functionality. Even if you cannot "program" or "script" Tasker, Tasker does allow others to save those scripts and share them for others to use or modify.
App developers will likely also be interested in making use of this API as it will greatly simplify what is needed within the app to achieve this.
See Tasker's latest beta lets you create a custom sleep tracker on Android
The developer of Tasker has implemented Google's new Sleep API into a new beta, allowing users to create a custom sleep tracker on Android.