For the use case (personal tracking) the code is just fine, possibly perfect because you don't want to over-engineer something that's only for your own use.
If you don't mind, what tracker do you use? I am bipolar as well and have a fitbit Alta HR. I wonder if I could do something similar, maybe even borrowing from dev.to/hiway/so-i-tracked-a-breaku... to input some kind of "mood" tracker.
Anything that interfaces with Apple's HealthKit is going to do a pretty good job at letting you track data. I personally use Sleep Cycle and Good Morning Alarm Clock for sleep tracking (I switched from, then back to, Sleep Cycle). Now I'm curious as to whether HealthKit has a 'mood' tracker and if any apps exist for that. If not, maybe we should make one!
Quick edit: I don't have any IoT or wearable devices, so I'm not sure what the FitBit tracks for you. I'm assuming sleep and exercise patterns are included, and the latter could make an interesting addition
Any fitbit with a heart rate monitor (it'll have "HR" in the name) can show you hours slept and break it down into time spent in: Awake, REM, Light, and Deep sleep. It will also give expected healthy range bands for each of those so you know if your numbers are good.
Exercise is also tracked. But it doesn't look like Fitbit shares its data with HealthKit, unless you go with a 3P solution like syncsolver
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.