Skip to content

Commit fe5b6ad

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

File tree

5 files changed

+443
-0
lines changed

5 files changed

+443
-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: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
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>{sgv}<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 | `mg/dl` | 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+
33+
## Example Configuration
34+
35+
```yaml
36+
glucose_monitor:
37+
type: "yasb.glucose_monitor.GlucoseMonitor"
38+
options:
39+
label: "<span>\ud83e\ude78</span>{sgv}<span>{direction}</span>"
40+
error_label: "<span>\ud83e\ude78</span>{error_message}"
41+
tooltip: "({sgv_delta}) {delta_time_in_minutes} min"
42+
host: "https://your-domain.com"
43+
secret: "env"
44+
secret_env_name: "YASB_CGM_YOUR_SECRET_ENV_NAME"
45+
sgv_measurement_units: "mg/dl"
46+
label_shadow:
47+
enabled: true
48+
color: "black"
49+
radius: 3
50+
offset: [ 1, 1 ]
51+
```
52+
53+
## Description of Options
54+
55+
- **label:** The format string for the widget.
56+
- **tooltip:** The format string for the tooltip
57+
- **host:** The URL for the CGM
58+
- **secret:** The secret key for the CGM API
59+
- **direction_icons:** Direction icon settings
60+
- **sgv_measurement_units:** SGV measurement units can be `mg/dl` or `mmol/l`
61+
- **callbacks:** Callbacks for mouse events on the glucose monitor widget
62+
63+
## Example Style
64+
65+
```css
66+
.cgm-widget {
67+
padding: 0 4px 0 4px;
68+
}
69+
70+
.cgm-widget .widget-container {
71+
}
72+
73+
.cgm-widget .label {
74+
}
75+
76+
.cgm-widget .icon {
77+
}
78+
```
79+
80+
## Preview of the Widget
81+
82+
![Glucose Monitor YASB Widget](assets/glucose_monitor_01.png)
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
DEFAULTS = {
2+
"label": "<span>\ud83e\ude78<span>{sgv}<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": "mg/dl", # "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+
}
21+
22+
VALIDATION_SCHEMA = {
23+
"label": {
24+
"type": "string",
25+
"required": False,
26+
"default": DEFAULTS["label"],
27+
},
28+
"error_label": {
29+
"type": "string",
30+
"required": False,
31+
"default": DEFAULTS["error_label"],
32+
},
33+
"tooltip": {
34+
"type": "string",
35+
"required": False,
36+
"default": DEFAULTS["tooltip"],
37+
},
38+
"host": {
39+
"type": "string",
40+
"default": DEFAULTS["host"],
41+
},
42+
"secret": {
43+
"type": "string",
44+
"default": DEFAULTS["secret"],
45+
},
46+
"secret_env_name": {
47+
"type": "string",
48+
"required": False,
49+
"default": DEFAULTS["secret_env_name"],
50+
},
51+
"direction_icons": {
52+
"type": "dict",
53+
"required": False,
54+
"schema": {
55+
"double_up": {
56+
"type": "string",
57+
"default": DEFAULTS["direction_icons"]["double_up"],
58+
},
59+
"single_up": {
60+
"type": "string",
61+
"default": DEFAULTS["direction_icons"]["single_up"],
62+
},
63+
"forty_five_up": {
64+
"type": "string",
65+
"default": DEFAULTS["direction_icons"]["forty_five_up"],
66+
},
67+
"flat": {
68+
"type": "string",
69+
"default": DEFAULTS["direction_icons"]["flat"],
70+
},
71+
"forty_five_down": {
72+
"type": "string",
73+
"default": DEFAULTS["direction_icons"]["forty_five_down"],
74+
},
75+
"single_down": {
76+
"type": "string",
77+
"default": DEFAULTS["direction_icons"]["single_down"],
78+
},
79+
"double_down": {
80+
"type": "string",
81+
"default": DEFAULTS["direction_icons"]["double_down"],
82+
},
83+
},
84+
"default": DEFAULTS["direction_icons"],
85+
},
86+
"sgv_measurement_units": {
87+
"type": "string",
88+
"required": False,
89+
"default": DEFAULTS["sgv_measurement_units"],
90+
},
91+
"callbacks": {
92+
"type": "dict",
93+
"schema": {
94+
"on_left": {
95+
"type": "string",
96+
"default": DEFAULTS["callbacks"]["on_left"],
97+
},
98+
"on_middle": {
99+
"type": "string",
100+
"default": DEFAULTS["callbacks"]["on_middle"],
101+
},
102+
"on_right": {
103+
"type": "string",
104+
"default": DEFAULTS["callbacks"]["on_right"],
105+
},
106+
},
107+
"default": DEFAULTS["callbacks"],
108+
},
109+
"notify_on_error": {
110+
"type": "boolean",
111+
"required": False,
112+
"default": DEFAULTS["notify_on_error"],
113+
},
114+
"label_shadow": {
115+
"type": "dict",
116+
"required": False,
117+
"schema": {
118+
"enabled": {"type": "boolean", "default": False},
119+
"color": {"type": "string", "default": "black"},
120+
"offset": {"type": "list", "default": [1, 1]},
121+
"radius": {"type": "integer", "default": 3},
122+
},
123+
"default": {"enabled": False, "color": "black", "offset": [1, 1], "radius": 3},
124+
},
125+
"container_shadow": {
126+
"type": "dict",
127+
"required": False,
128+
"schema": {
129+
"enabled": {"type": "boolean", "default": False},
130+
"color": {"type": "string", "default": "black"},
131+
"offset": {"type": "list", "default": [1, 1]},
132+
"radius": {"type": "integer", "default": 3},
133+
},
134+
"default": {"enabled": False, "color": "black", "offset": [1, 1], "radius": 3},
135+
},
136+
}

0 commit comments

Comments
 (0)