Skip to content

Commit 7d86902

Browse files
committed
Add Glucose Monitor Widget
1 parent 3baf82d commit 7d86902

File tree

5 files changed

+487
-0
lines changed

5 files changed

+487
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ https://github.com/user-attachments/assets/aab8d8e8-248f-46a1-919c-9b0601236ac1
9999
- **[GlazeWM Binding Mode](https://github.com/amnweb/yasb/wiki/(Widget)-GlazeWM-Binding-Mode)**: GlazeWM binding mode widget.
100100
- **[GlazeWM Tiling Direction](https://github.com/amnweb/yasb/wiki/(Widget)-GlazeWM-Tiling-Direction)**: GlazeWM tiling direction widget.
101101
- **[GlazeWM Workspaces](https://github.com/amnweb/yasb/wiki/(Widget)-GlazeWM-Workspaces)**: GlazeWM workspaces widget.
102+
- **[Glucose Monitor](https://github.com/amnweb/yasb/wiki/(Widget)-Glucose-Monitor)**: Nightscout CGM Widget.
102103
- **[Grouper](https://github.com/amnweb/yasb/wiki/(Widget)-Grouper)**: Groups multiple widgets together in a container.
103104
- **[GPU](https://github.com/amnweb/yasb/wiki/(Widget)-GPU)**: Displays GPU utilization, temperature, and memory usage.
104105
- **[Home](https://github.com/amnweb/yasb/wiki/(Widget)-Home)**: A customizable home widget menu.

docs/assets/glucose_monitor_01.png

17.9 KB
Loading
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# Glucose Monitor Widget
2+
3+
Nightscout (also known as CGM in the Cloud) is an open-source cloud application used by people with diabetes and parents
4+
of kids with diabetes to visualize, store and share the data from their Continuous Glucose Monitoring sensors in
5+
real-time. Once setup, Nightscout acts as a central repository of blood glucose and insulin dosing/treatment data for a
6+
single person, allowing you to view the CGM graph and treatment data anywhere using just a web browser connected to the
7+
internet.
8+
9+
There are several parts to this system. You need somewhere online to store, process and visualize this data (a
10+
Nightscout Site), something to upload CGM data to your Nightscout (an Uploader), and then optionally you can use other
11+
devices to access or view this data (one - or more - Follower).
12+
13+
Go to [Nightscout documentation](https://nightscout.github.io/nightscout/new_user/) for the details.
14+
15+
This widget allows you to monitor someone's blood sugar level
16+
through [Nightscout CGM remote monitor](https://github.com/nightscout/cgm-remote-monitor) API.
17+
18+
| Option | Type | Default | Description |
19+
|-------------------------|---------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------|
20+
| `label` | string | `<span>\ud83e\ude78</span><span class='sgv'>{sgv}</span><span>{direction}</span>` | The format string for the widget. |
21+
| `error_label` | string | `<span>\ud83e\ude78</span>{error_message}` | The format string for the error widget. |
22+
| `tooltip` | string | `({sgv_delta}) {delta_time_in_minutes} min` | The format string for the tooltip. |
23+
| `host` | string | `...` | The URL for your [Nightscout CGM remote monitor](https://github.com/nightscout/cgm-remote-monitor). |
24+
| `secret` | string | `...` | The secret key for the CGM API. |
25+
| `secret_env_name` | string | `...` | If the secret variable is equals to `env` then widget will try to get secret from the environment variable with a name of the `secret_env_name` value. |
26+
| `direction_icons` | dict | `{"double_up": "\u2b06\ufe0f\u2b06\ufe0f", "single_up": "\u2b06\ufe0f", "forty_five_up": "\u2197\ufe0f", "flat": "\u27a1\ufe0f", "forty_five_down": "\u2198\ufe0f", "single_down": "\u2b07\ufe0f", "double_down": "\u2b07\ufe0f\u2b07\ufe0f"}` | Direction icon settings. |
27+
| `sgv_measurement_units` | string | `mmol/l` | SGV measurement units can be `mg/dl` or `mmol/l`. |
28+
| `callbacks` | dict | `{"on_left": "open_cgm", "on_middle": "do_nothing", "on_right": "do_nothing"}` | Callbacks for mouse events on the glucose monitor widget. |
29+
| `notify_on_error` | boolean | `True` | Send a notification on error. |
30+
| `label_shadow` | dict | `None` | Label shadow options. |
31+
| `container_shadow` | dict | `None` | Container shadow options. |
32+
| `sgv_range` | dict | `{"min": 4, "max": 9}` | Normal SGV range to append `in-range` or `out-range` CSS class for span with `.sgv` CSS class. |
33+
34+
## Example Configuration
35+
36+
```yaml
37+
glucose_monitor:
38+
type: "yasb.glucose_monitor.GlucoseMonitor"
39+
options:
40+
label: "<span>\ud83e\ude78</span><span class='sgv'>{sgv}</span><span>{direction}</span>"
41+
error_label: "<span>\ud83e\ude78</span>{error_message}"
42+
tooltip: "({sgv_delta}) {delta_time_in_minutes} min"
43+
host: "https://your-domain.com"
44+
secret: "env"
45+
secret_env_name: "YASB_CGM_YOUR_SECRET_ENV_NAME"
46+
sgv_measurement_units: "mmol/l"
47+
sgv_range:
48+
min: 4
49+
max: 9
50+
```
51+
52+
## Description of Options
53+
54+
- **label:** The format string for the widget.
55+
- **error_label:** The format string for the error widget.
56+
- **tooltip:** The format string for the tooltip.
57+
- **host:** The URL for your [Nightscout CGM remote monitor](https://github.com/nightscout/cgm-remote-monitor).
58+
- **secret:** The secret key for the CGM API.
59+
- **secret_env_name:** If the secret variable is equals to `env` then widget will try to get secret from the environment variable with a name of the `secret_env_name` value.
60+
- **direction_icons:** Direction icon settings.
61+
- **sgv_measurement_units:** SGV measurement units can be `mg/dl` or `mmol/l`.
62+
- **callbacks:** Callbacks for mouse events on the glucose monitor widget.
63+
- **notify_on_error:** Send a notification on error.
64+
- **label_shadow:** Label shadow options.
65+
- **container_shadow:** Container shadow options.
66+
- **sgv_range:** Normal SGV range to append `in-range` or `out-range` CSS class for span with `.sgv` CSS class.
67+
68+
## Example Style
69+
70+
```css
71+
.cgm-widget {
72+
padding: 0 4px 0 4px;
73+
}
74+
75+
.cgm-widget .widget-container {
76+
}
77+
.cgm-widget .label {
78+
}
79+
80+
.cgm-widget .sgv.in-range {
81+
color: green;
82+
}
83+
84+
.cgm-widget .sgv.out-range {
85+
color: red;
86+
}
87+
88+
.cgm-widget .icon {
89+
}
90+
```
91+
92+
## Preview of the Widget
93+
94+
![Glucose Monitor YASB Widget](assets/glucose_monitor_01.png)
Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
DEFAULTS = {
2+
"label": "<span>\ud83e\ude78<span><span class='sgv'>{sgv}</span><span>{direction}</span>",
3+
"error_label": "<span>\ud83e\ude78</span>{error_message}",
4+
"tooltip": "({sgv_delta}) {delta_time_in_minutes} min",
5+
"host": "",
6+
"secret": "",
7+
"secret_env_name": "",
8+
"direction_icons": {
9+
"double_up": "\u2b06\ufe0f\u2b06\ufe0f",
10+
"single_up": "\u2b06\ufe0f",
11+
"forty_five_up": "\u2197\ufe0f",
12+
"flat": "\u27a1\ufe0f",
13+
"forty_five_down": "\u2198\ufe0f",
14+
"single_down": "\u2b07\ufe0f",
15+
"double_down": "\u2b07\ufe0f\u2b07\ufe0f",
16+
},
17+
"sgv_measurement_units": "mmol/l", # "mg/dl" or "mmol/l"
18+
"callbacks": {"on_left": "open_cgm", "on_middle": "do_nothing", "on_right": "do_nothing"},
19+
"notify_on_error": True,
20+
"sgv_range": {
21+
"min": 4,
22+
"max": 9,
23+
},
24+
}
25+
26+
VALIDATION_SCHEMA = {
27+
"label": {
28+
"type": "string",
29+
"required": False,
30+
"default": DEFAULTS["label"],
31+
},
32+
"error_label": {
33+
"type": "string",
34+
"required": False,
35+
"default": DEFAULTS["error_label"],
36+
},
37+
"tooltip": {
38+
"type": "string",
39+
"required": False,
40+
"default": DEFAULTS["tooltip"],
41+
},
42+
"host": {
43+
"type": "string",
44+
"default": DEFAULTS["host"],
45+
},
46+
"secret": {
47+
"type": "string",
48+
"default": DEFAULTS["secret"],
49+
},
50+
"secret_env_name": {
51+
"type": "string",
52+
"required": False,
53+
"default": DEFAULTS["secret_env_name"],
54+
},
55+
"direction_icons": {
56+
"type": "dict",
57+
"required": False,
58+
"schema": {
59+
"double_up": {
60+
"type": "string",
61+
"default": DEFAULTS["direction_icons"]["double_up"],
62+
},
63+
"single_up": {
64+
"type": "string",
65+
"default": DEFAULTS["direction_icons"]["single_up"],
66+
},
67+
"forty_five_up": {
68+
"type": "string",
69+
"default": DEFAULTS["direction_icons"]["forty_five_up"],
70+
},
71+
"flat": {
72+
"type": "string",
73+
"default": DEFAULTS["direction_icons"]["flat"],
74+
},
75+
"forty_five_down": {
76+
"type": "string",
77+
"default": DEFAULTS["direction_icons"]["forty_five_down"],
78+
},
79+
"single_down": {
80+
"type": "string",
81+
"default": DEFAULTS["direction_icons"]["single_down"],
82+
},
83+
"double_down": {
84+
"type": "string",
85+
"default": DEFAULTS["direction_icons"]["double_down"],
86+
},
87+
},
88+
"default": DEFAULTS["direction_icons"],
89+
},
90+
"sgv_measurement_units": {
91+
"type": "string",
92+
"required": False,
93+
"default": DEFAULTS["sgv_measurement_units"],
94+
},
95+
"callbacks": {
96+
"type": "dict",
97+
"schema": {
98+
"on_left": {
99+
"type": "string",
100+
"default": DEFAULTS["callbacks"]["on_left"],
101+
},
102+
"on_middle": {
103+
"type": "string",
104+
"default": DEFAULTS["callbacks"]["on_middle"],
105+
},
106+
"on_right": {
107+
"type": "string",
108+
"default": DEFAULTS["callbacks"]["on_right"],
109+
},
110+
},
111+
"default": DEFAULTS["callbacks"],
112+
},
113+
"notify_on_error": {
114+
"type": "boolean",
115+
"required": False,
116+
"default": DEFAULTS["notify_on_error"],
117+
},
118+
"label_shadow": {
119+
"type": "dict",
120+
"required": False,
121+
"schema": {
122+
"enabled": {"type": "boolean", "default": False},
123+
"color": {"type": "string", "default": "black"},
124+
"offset": {"type": "list", "default": [1, 1]},
125+
"radius": {"type": "integer", "default": 3},
126+
},
127+
"default": {"enabled": False, "color": "black", "offset": [1, 1], "radius": 3},
128+
},
129+
"container_shadow": {
130+
"type": "dict",
131+
"required": False,
132+
"schema": {
133+
"enabled": {"type": "boolean", "default": False},
134+
"color": {"type": "string", "default": "black"},
135+
"offset": {"type": "list", "default": [1, 1]},
136+
"radius": {"type": "integer", "default": 3},
137+
},
138+
"default": {"enabled": False, "color": "black", "offset": [1, 1], "radius": 3},
139+
},
140+
"sgv_range": {
141+
"type": "dict",
142+
"required": False,
143+
"schema": {
144+
"min": {"type": "float", "default": DEFAULTS["sgv_range"]["min"]},
145+
"max": {"type": "float", "default": DEFAULTS["sgv_range"]["max"]},
146+
},
147+
"default": {
148+
"min": DEFAULTS["sgv_range"]["min"],
149+
"max": DEFAULTS["sgv_range"]["max"],
150+
},
151+
},
152+
}

0 commit comments

Comments
 (0)