Diabetes badge with dexcom and mushroom template

Hi,

one of the family members has diabetes and uses a dexcom glucose sensor (version 6, sometimes 7) which integrates via bluetooth with the dexcom app on his android phone.

The dexcom app sends it’s data to the cloud mothership and the cloud mothership has an api, which is conveniently interfaced with by the dexcom integration of home assistant (that uses the pydexcom library).
The integration exposes the glucose value and the glucose trend (rising/falling etc)

I’ve used this sensors glucose reading for adjusting light settings in my bedroom at night (red for low values, 100% bright red if crashing, nothing if ok, orange if high) so I’m warned and can take action if necessary.

His ulanzi clock with awtrix on it has colored arrows indicating direction and color for where in the gluco range he is, so he can quickly see what’s up at night.

Today I created a badge with the mushroom template badge so I have person location and the glucose value and trend (indicated by arrows) in a single badge.

the ‘label’ part of the mushroom badge contains this code. and using this it resembles a basic entity badge with a person entity (showing the picture of the entity and the location/state of the entity

type: custom:mushroom-template-badge
content: "{{states.person.straightuphunk.state | capitalize }}"
icon: mdi:diabetes
color: >-
  {% set glucose_value = states.sensor.patientzero_glucose_value.state |
  default('-', true) %}

  {% if glucose_value == '-' %}
    blue
  {% elif glucose_value | float < 4 %}
    red
  {% elif glucose_value | float >= 4 and glucose_value | float <= 10 %}
    green
  {% else %}
    orange
  {% endif %}
entity: sensor.patientzero_glucose_value
label: >-
  namehere

  {% set trend_value = states.sensor.patientzero_glucose_trend.state |
  default('-', true) | lower -%}

  {% if trend_value == 'steady' -%}

  ➡️

  {%- elif trend_value == 'rising_quickly' -%}

  ⬆️

  {% elif trend_value == 'rising_slightly' -%}

  ↗️

  {% elif trend_value == 'rising' -%}

  ⤴️

  {% elif trend_value == 'falling' -%}

  ⤵️

  {% elif trend_value == 'falling_slightly' -%}

  ↘️

  {% elif trend_value == 'falling_quickly' -%}

  ⬇️

  {% else -%}

  {% endif -%}

  {{ states.sensor.patientzero_glucose_value.state | default('-', true)
  }} 
hold_action:
  action: more-info
picture: /api/image/serve/86dcc67c7c079c5bcc0762375ea31e3b/512x512
tap_action:
  action: more-info
  entity: person.straightuphunk
double_tap_action:
  action: more-info
  entity: sensor.patientzero_glucose_value

hope it helps someone with diabetes in the family for inspiration :wink: