Skip to content
This repository has been archived by the owner on Apr 6, 2024. It is now read-only.

feat: scrape basal rate from diasend website #6

Merged
merged 9 commits into from
Aug 27, 2022

Conversation

burnedikt
Copy link
Owner

This serves as an example on how to obtain additional diasend data (like basal profile) from the diasend website instead of the API (since the API doesn't provide the desired data, also see #1).

Scraping is definitely not ideal as the website could change but I don't expect that to happen considering the switch to glooko at some point.

Either way, it can be used like:

import { getPumpSettings, getAuthenticatedScrapingClient } from "./diasend";

const username = "my.user@diasend.com";
const password = "super-secret-password";

const { client, userId } = await getAuthenticatedScrapingClient({
  username, password
});

console.log(await getPumpSettings(client, userId));

>>> [
>>>  [ '00:00:00', 1.2 ],
>>>  [ '01:00:00', 0.8 ],
>>>  [ '05:00:00', 0.5 ],
>>>  [ '08:00:00', 0.3 ],
>>>  [ '11:00:00', 0.5 ],
>>>  [ '13:00:00', 0.6 ],
>>>  [ '15:00:00', 0.8 ],
>>>  [ '19:00:00', 1 ]
>>> ]

export async function getAuthenticatedScrapingClient({
username,
password,
country = 108,
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

108 is Germany, not sure what the country is used for but probably other values need to be supported as well

@burnedikt
Copy link
Owner Author

Update: It can now fetch the following pump settings from diasend and forward them to the nightscout profile (or do something else with it):

  • Basal Profile
  • I:C profile (Insulin / Carb Ratio)
  • ISF profiel (Insulin Sensitivity Factor)
  • Low / High targets for blood glucose
  • units configured in diasend (mg/dl or mmol/l)
  • insulin on board time (in hours)

@burnedikt burnedikt merged commit a8cb47b into main Aug 27, 2022
@burnedikt burnedikt deleted the feat/scrape-pump-settings branch August 27, 2022 23:59
@github-actions
Copy link

🎉 This PR is included in version 0.5.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant