burnedikt / diasend-nightscout-bridge

Synchronize your diasend data to nightscout.
MIT License
18 stars 18 forks source link

feat: scrape basal rate from diasend website #6

Closed burnedikt closed 2 years ago

burnedikt commented 2 years ago

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 ]
>>> ]
burnedikt commented 2 years ago

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

github-actions[bot] commented 2 years ago

:tada: This PR is included in version 0.5.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: