Hi there,
i am not new to home assistant nor new to programming or home automation.
I am doing quite well automating my house and my life. But there was one thing missing in automating my life. It was how much i did sleep at night lately. So i wanted to extract the data from my iPhone. Unfortunately that was quite difficult. Apple Health kept saving my sleep time as “time in bed” and not “sleeping”. So Auto Export reported my sleep time daily as 0. Next aproach: I already had Google Fit installed (i moved from Android to Apple - i won’t discuss that here) and yay Google Fit had my data right. Unfortunately Google had their API reconstructed, so almost every HACS integration i tried was getting no sleep data to HASSIO.
With some time and efford i built a PHP script, that was reading the sleep data from Google Fit and publishes them via MQTT in the format:
sleep/MYNAME/2022-11-14/overall=11111
sleep/MYNAME/2022-11-14/awake=1111
sleep/MYNAME/2022-11-14/sleeping=10000
sleep/MYNAME/2022-11-14/up=0
sleep/MYNAME/2022-11-14/lightsleep=0
sleep/MYNAME/2022-11-14/deepsleep=0
sleep/MYNAME/2022-11-14/remsleep=0
(yes my Google Fit doesn’t seem to differ the different sleep stats, but that is ok for now)
I have read many documentations and many how to’s so far and at this point i got stuck. I read the MQTT Sensor Doc and i don’t get it.
Now to my question. How will i be able to get my data from MQTT to a Sensor and from there to an InfluxDB to draw a chart with Grafana or calculate my average sleep time of the last seven days or stuff like that?
Maybe my design of the mqtt data is not that great. But i am strangely stuck in my creativity.
Anybody here who can help me with that?
Greetings
Sven