Sleepdata from MQTT to Sensor

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

Well ok, i digged some deeper into MQTT discovery . And i found that i wasn’t reading close enough.
I had to rearrange MQTT topics tp

sleep/sven/overall=11111
sleep/sven/awake=1111
sleep/sven/sleeping=10000
sleep/sven/up=0
sleep/sven/lightsleep=0
sleep/sven/deepsleep=0
sleep/sven/remsleep=0
sleep/sven/date=2022-11-14

and then setup a config topic to:

homeassistant/sensor/sleepSvenDate/config
{
  "device_class": "date",
  "name": "Datum Schlafdaten Sven",
  "state_topic": "sleep/sven/date",
  "unit_of_measurement": "",
  "value_template": "{{ value_json.date}}"
}
homeassistant/sensor/sleepSvenoverall/config
{
  "device_class": "duration",
  "name": "Gesamt Sven",
  "state_topic": "sleep/sven/overall",
  "unit_of_measurement": "s",
  "value_template": "{{ value_json.duration}}"
}

and so on…

BUT:
homeassistant doesn’t seem to recognize the sensor with auto discovery.
Yes, the integration has autodiscovery turned on.
Yes the Integration can listen to the topics if i tell it to do so and it reports the correct data.
Yes, i have reconfigured the MQTT integration and have re-set the auto discovery switch, the reloaded the integration and just to be save rebooted home-assistant.
Result: Nothing. My sensors won’t appear in home-assistant.

Again, i don’t get it.Is there any way to troubleshoot mqtt auto discovery?

Kind regards

Sven