Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nightscout Plugin #108

Merged
merged 13 commits into from
Feb 6, 2021
62 changes: 35 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Generate your metrics that you can embed everywhere, including your GitHub profi
<table>
<tr>
<th colspan="2" align="center">
<a href="source/plugins/README.md">🧩 19 plugins</a>
<a href="source/plugins/README.md">🧩 20 plugins</a>
</th>
</tr>
<tr>
Expand Down Expand Up @@ -100,7 +100,7 @@ Generate your metrics that you can embed everywhere, including your GitHub profi
</tr>
<tr>
<th><a href="source/plugins/music/README.md">🎼 Music plugin</a></th>
<th><a href="source/plugins/pagespeed/README.md">⏱️ Website performances</a></th>
<th><a href="source/plugins/nightscout/README.md">💉 Nightscout</a></th>
</tr>
<tr>
<td align="center">
Expand All @@ -112,6 +112,16 @@ Generate your metrics that you can embed everywhere, including your GitHub profi
</details>
<img width="900" height="1" alt="">
</td>
<td align="center">
<img alt="" width="400" src="https://github.com/legoandmars/legoandmars/blob/master/metrics.plugin.nightscout.svg">
<img width="900" height="1" alt="">
</td>
</tr>
<tr>
<th><a href="source/plugins/pagespeed/README.md">⏱️ Website performances</a></th>
<th><a href="source/plugins/people/README.md">🧑‍🤝‍🧑 People plugin</a></th>
</tr>
<tr>
<td align="center">
<img alt="" width="400" src="https://github.com/lowlighter/lowlighter/blob/master/metrics.plugin.pagespeed.svg">
<details><summary>Detailed version</summary>
Expand All @@ -122,12 +132,6 @@ Generate your metrics that you can embed everywhere, including your GitHub profi
</details>
<img width="900" height="1" alt="">
</td>
</tr>
<tr>
<th><a href="source/plugins/people/README.md">🧑‍🤝‍🧑 People plugin</a></th>
<th><a href="source/plugins/posts/README.md">✒️ Recent posts</a></th>
</tr>
<tr>
<td align="center">
<img alt="" width="400" src="https://github.com/lowlighter/lowlighter/blob/master/metrics.plugin.people.followers.svg">
<details><summary>Followed people version</summary>
Expand All @@ -141,65 +145,64 @@ Generate your metrics that you can embed everywhere, including your GitHub profi
</details>
<img width="900" height="1" alt="">
</td>
<td align="center">
<img alt="" width="400" src="https://github.com/lowlighter/lowlighter/blob/master/metrics.plugin.posts.svg">
<img width="900" height="1" alt="">
</td>
</tr>
<tr>
<th><a href="source/plugins/posts/README.md">✒️ Recent posts</a></th>
<th><a href="source/plugins/projects/README.md">🗂️ Projects</a></th>
<th><a href="source/plugins/stargazers/README.md">✨ Stargazers over last weeks</a></th>
</tr>
<tr>
<td align="center">
<img alt="" width="400" src="https://github.com/lowlighter/lowlighter/blob/master/metrics.plugin.projects.svg">
<img alt="" width="400" src="https://github.com/lowlighter/lowlighter/blob/master/metrics.plugin.posts.svg">
<img width="900" height="1" alt="">
</td>
<td align="center">
<img alt="" width="400" src="https://github.com/lowlighter/lowlighter/blob/master/metrics.plugin.stargazers.svg">
<img alt="" width="400" src="https://github.com/lowlighter/lowlighter/blob/master/metrics.plugin.projects.svg">
<img width="900" height="1" alt="">
</td>
</tr>
<tr>
<th><a href="source/plugins/stargazers/README.md">✨ Stargazers over last weeks</a></th>
<th><a href="source/plugins/stars/README.md">🌟 Recently starred repositories</a></th>
<th><a href="source/plugins/topics/README.md">📌 Starred topics</a></th>
</tr>
<tr>
<td align="center">
<img alt="" width="400" src="https://github.com/lowlighter/lowlighter/blob/master/metrics.plugin.stars.svg">
<img alt="" width="400" src="https://github.com/lowlighter/lowlighter/blob/master/metrics.plugin.stargazers.svg">
<img width="900" height="1" alt="">
</td>
<td align="center">
<img alt="" width="400" src="https://github.com/lowlighter/lowlighter/blob/master/metrics.plugin.topics.svg">
<details open><summary>Mastered and known technologies version</summary>
<img alt="" width="400" src="https://github.com/lowlighter/lowlighter/blob/master/metrics.plugin.topics.mastered.svg">
</details>
<img alt="" width="400" src="https://github.com/lowlighter/lowlighter/blob/master/metrics.plugin.stars.svg">
<img width="900" height="1" alt="">
</td>
</tr>
<tr>
<th><a href="source/plugins/topics/README.md">📌 Starred topics</a></th>
<th><a href="source/plugins/traffic/README.md">🧮 Repositories traffic</a></th>
<th><a href="source/plugins/tweets/README.md">🐤 Latest tweets</a></th>
</tr>
<tr>
<td align="center">
<img alt="" width="400" src="https://github.com/lowlighter/lowlighter/blob/master/metrics.plugin.traffic.svg">
<img alt="" width="400" src="https://github.com/lowlighter/lowlighter/blob/master/metrics.plugin.topics.svg">
<details open><summary>Mastered and known technologies version</summary>
<img alt="" width="400" src="https://github.com/lowlighter/lowlighter/blob/master/metrics.plugin.topics.mastered.svg">
</details>
<img width="900" height="1" alt="">
</td>
<td align="center">
<img alt="" width="400" src="https://github.com/lowlighter/lowlighter/blob/master/metrics.plugin.tweets.svg">
<img width="900" height="1" alt="">
<img alt="" width="400" src="https://github.com/lowlighter/lowlighter/blob/master/metrics.plugin.traffic.svg">
</td>
</tr>
<tr>
<th><a href="source/plugins/tweets/README.md">🐤 Latest tweets</a></th>
<th><a href="source/plugins/wakatime/README.md">⏰ WakaTime plugin</a></th>
<th><a href="source/plugins//README.md"></a></th>
</tr>
<tr>
<td align="center">
<img alt="" width="400" src="https://github.com/lowlighter/lowlighter/blob/master/metrics.plugin.tweets.svg">
<img width="900" height="1" alt="">
</td>
<td align="center">
<img alt="" width="400" src="https://github.com/lowlighter/lowlighter/blob/master/metrics.plugin.wakatime.svg">
<img width="900" height="1" alt="">
</td>
<td align="center"><img width="900" height="1" alt=""></td>
</tr>
<tr>
<th colspan="2" align="center">
Expand Down Expand Up @@ -551,6 +554,7 @@ https://my-personal-domain.com/my-github-user?base=0&base.repositories=1
<th nowrap="nowrap" align="center">🈷️</th>
<th nowrap="nowrap" align="center">👨‍💻</th>
<th nowrap="nowrap" align="center">🎼</th>
<th nowrap="nowrap" align="center">💉</th>
<th nowrap="nowrap" align="center">⏱️</th>
<th nowrap="nowrap" align="center">🧑‍🤝‍🧑</th>
<th nowrap="nowrap" align="center">✒️</th>
Expand All @@ -574,6 +578,7 @@ https://my-personal-domain.com/my-github-user?base=0&base.repositories=1
<th nowrap="nowrap" align="center" data-plugin="languages">✔️</th>
<th nowrap="nowrap" align="center" data-plugin="lines">✔️</th>
<th nowrap="nowrap" align="center" data-plugin="music">✔️</th>
<th nowrap="nowrap" align="center" data-plugin="nightscout">✔️</th>
<th nowrap="nowrap" align="center" data-plugin="pagespeed">✔️</th>
<th nowrap="nowrap" align="center" data-plugin="people">✔️</th>
<th nowrap="nowrap" align="center" data-plugin="posts">✔️</th>
Expand All @@ -597,6 +602,7 @@ https://my-personal-domain.com/my-github-user?base=0&base.repositories=1
<th nowrap="nowrap" align="center" data-plugin="languages">✔️</th>
<th nowrap="nowrap" align="center" data-plugin="lines">✔️</th>
<th nowrap="nowrap" align="center" data-plugin="music">❌</th>
<th nowrap="nowrap" align="center" data-plugin="nightscout">❌</th>
<th nowrap="nowrap" align="center" data-plugin="pagespeed">✔️</th>
<th nowrap="nowrap" align="center" data-plugin="people">✔️</th>
<th nowrap="nowrap" align="center" data-plugin="posts">❌</th>
Expand All @@ -620,6 +626,7 @@ https://my-personal-domain.com/my-github-user?base=0&base.repositories=1
<th nowrap="nowrap" align="center" data-plugin="languages">✔️</th>
<th nowrap="nowrap" align="center" data-plugin="lines">✔️</th>
<th nowrap="nowrap" align="center" data-plugin="music">❌</th>
<th nowrap="nowrap" align="center" data-plugin="nightscout">❌</th>
<th nowrap="nowrap" align="center" data-plugin="pagespeed">✔️</th>
<th nowrap="nowrap" align="center" data-plugin="people">❌</th>
<th nowrap="nowrap" align="center" data-plugin="posts">❌</th>
Expand Down Expand Up @@ -659,6 +666,7 @@ See their respective documentation for more informations about how to setup them
* [🈷️ Most used languages](/source/plugins/languages/README.md)
* [👨‍💻 Lines of code changed](/source/plugins/lines/README.md)
* [🎼 Music plugin](/source/plugins/music/README.md)
* [💉 Nightscout](/source/plugins/nightscout/README.md)
* [⏱️ Website performances](/source/plugins/pagespeed/README.md)
* [🧑‍🤝‍🧑 People plugin](/source/plugins/people/README.md)
* [✒️ Recent posts](/source/plugins/posts/README.md)
Expand Down
38 changes: 38 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,44 @@ inputs:
description: Music provider username
default: .user.login

# ====================================================================================
# 💉 Nightscout

# Enable or disable plugin
plugin_nightscout:
description: Displays Blood Glucose
default: no

# Nightscout site URL
plugin_nightscout_url:
description: Your Nightscout site URL
default: https://example.herokuapp.com

# Controls how big the graph is
plugin_nightscout_datapoints:
description: How many datapoints to show on the graph. 0 and 1 disable the graph.
default: 12

# Low value used for colors and text alerts
plugin_nightscout_lowalert:
description: When the blood sugar is considered low
default: 80

# High value used for colors and text alerts
plugin_nightscout_highalert:
description: When the blood sugar is considered high
default: 180

# Urgent low value used for colors and text alerts
plugin_nightscout_urgentlowalert:
description: When the blood sugar is considered urgently low
default: 50

# Urgent high value used for colors and text alerts
plugin_nightscout_urgenthighalert:
description: When the blood sugar is considered urgently high
default: 250

# ====================================================================================
# ⏱️ Website performances

Expand Down
3 changes: 3 additions & 0 deletions settings.example.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@
"token": null, "//":"Music provider personal token",
"enabled": false, "//": "Display your music tracks"
},
"nightscout":{
"enabled": false, "//": "Displays Blood Glucose"
},
"pagespeed":{
"token": null, "//":"PageSpeed token",
"enabled": false, "//": "Display a website Google PageSpeed metrics"
Expand Down
31 changes: 31 additions & 0 deletions source/app/mocks/api/axios/get/nightscout.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**Mocked data */
export default function({faker, url}) {
//Last.fm api
if (/^https:..testapp.herokuapp.com.*$/.test(url)) {
//Get Nightscout Data
console.debug(`metrics/compute/mocks > mocking nightscout api result > ${url}`)
const lastInterval = Math.floor(new Date() / 300000) * 300000
const directionArray = ["SingleUp", "DoubleUp", "FortyFiveUp", "Flat", "FortyFiveDown", "SingleDown", "DoubleDown"]
return ({
status:200,
data:{
data:[{
_id:faker.git.commitSha().substring(0, 23),
device:"xDrip-DexcomG5",
date:lastInterval,
dateString:new Date(lastInterval).toISOString(),
sgv:faker.random.number({min:40, max:400}),
delta:faker.random.number({min:-10, max:10}),
direction:directionArray[Math.floor(Math.random() * directionArray.length)],
type:"sgv",
filtered:0,
unfiltered:0,
rssi:100,
noise:1,
sysTime:new Date(lastInterval).toISOString(),
utcOffset:faker.random.number({min:-12, max:14})*60,
}],
},
})
}
}
11 changes: 11 additions & 0 deletions source/app/web/statics/app.placeholder.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,17 @@
}))
}
}) : null),
//Nightscout
...(set.plugins.enabled.nightscout ? ({
nightscout:{
url: options["nightscout.url"] != null && options["nightscout.url"] != "https://example.herokuapp.com" ? options["nightscout.url"]: "https://testapp.herokuapp.com/",
datapoints: faker.random.number({min: 8, max: 12}),
lowalert: faker.random.number({min: 60, max: 90}),
highalert: faker.random.number({min: 150, max: 200}),
urgentlowalert: faker.random.number({min: 40, max: 59}),
urgenthighalert: faker.random.number({min: 201, max: 300})
}
}) : null),
//Pagespeed
...(set.plugins.enabled.pagespeed ? ({
pagespeed:{
Expand Down
1 change: 1 addition & 0 deletions source/plugins/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ See their respective documentation for more informations about how to setup them
* [🈷️ Most used languages](/source/plugins/languages/README.md)
* [👨‍💻 Lines of code changed](/source/plugins/lines/README.md)
* [🎼 Music plugin](/source/plugins/music/README.md)
* [💉 Nightscout](/source/plugins/nightscout/README.md)
* [⏱️ Website performances](/source/plugins/pagespeed/README.md)
* [🧑‍🤝‍🧑 People plugin](/source/plugins/people/README.md)
* [✒️ Recent posts](/source/plugins/posts/README.md)
Expand Down
34 changes: 34 additions & 0 deletions source/plugins/nightscout/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
### 💉 Nightscout

The *Nightscout* plugin lets you display blood sugar values from a [Nightscout](http://nightscout.info) site.

<table>
<td align="center">
<img src="https://github.com/legoandmars/legoandmars/blob/master/metrics.plugin.nightscout.svg">
<img width="900" height="1" alt="">
</td>
</table>

<details>
<summary>💬 Setting up a nightscout site</summary>

The [nightscout website](http://www.nightscout.info/) details how to self-host a nightscout site. Check out the instructions there.

</details>

#### ℹ️ Examples workflows

[➡️ Available options for this plugin](metadata.yml)

```yaml
- uses: lowlighter/metrics@master
with:
# ... other options
plugin_nightscout: yes
plugin_nightscout_url: ${{ secrets.NIGHTSCOUT_URL }} # Use the github actions "NIGHTSCOUT_URL" secret as your nightscout site
plugin_nightscout_datapoints: 12 # Use the latest 12 blood sugar datapoints to create a graph
plugin_nightscout_lowalert: 80 # Blood sugars below 80 will be considered low
plugin_nightscout_highalert: 180 # Blood sugars above 180 will be considered high
plugin_nightscout_urgentlowalert: 50 # Blood sugars below 50 will be considered urgently low
plugin_nightscout_urgenthighalert: 250 # Blood sugars above 250 will be considered urgently high
```