Dexcom CGM G6 publishes the glucose readings to the Dexcom servers so that the user can read the data with an app. It is also possible to share the data to other people, like family members, that uses the Dexcom Share app. I wanted to include the data in Home Assistant, a platform for home automation.
The easiest, and really the preferred, way to communicate with Home Assistant is with MQTT. It is a light weight communication protocol that is already included in Home Assistant. Home Assistant also has functionality to track and automate things based on MQTT data.
The only piece that was missing was a script that could read the data from Dexcom and publish to MQTT and that was what I built. It fetches the data from the API that supplies the Dexcom Follows app, so you'll need to create a new user and share the data with. The data is fetched, parsed and transformed from mg/dL (milligram per deciliter) to mmol/L (millimol per liter) which is the unit most used in Sweden. The script makes this once per execution, so it will need to be automated to run multiple times to get readings continuously. This is easy to achieve with cron.