Frontend Panel for Diabetics using a Dexcom CGM

I have now started a new topic for the

Dwains Dashboard Dexcom position!

Hope its spelt correctly enough for you! x fingers it is :slight_smile:

Because…

And …

1 Like

Thanks for the reminder, so how do I get lights now to go red when low Blood levels and Blue when normal levels. I’ve tried to do it but the lights go red when Im low with the sensor but when back to Normal the light still stops red! Im not sure what I’m doing wrong on this automation or how to use the helpers I made instead.

I’m also not sure what code to post to give you some clues what I’m trying to do! Can you help on thid in here? As its Dexcom CGM I’m trying to do it with.

I thought it might be better or easier to use the Config.yaml file but I know this can mess HA up so I have to be careful on doign so.

This what I have at moment and also now made two Threshold Helpers but not added or attempted to add yet, as Im not sure how too or where too.

alias: Turn Lights on if low - colour
description: Turns light on if low with colour change to red
trigger:
  - platform: numeric_state
    entity_id:
      - sensor.blood_sugar
    id: Low-readings
    above: 0
    below: 70
  - platform: numeric_state
    entity_id:
      - sensor.blood_sugar
    id: normal-readings
    above: 75
  - platform: numeric_state
    entity_id:
      - sensor.blood_sugar
    for:
      hours: 0
      minutes: 2
      seconds: 0
    id: Normal-readings-turn off light
    above: 76
condition: []
action:
  - choose:
      - conditions:
          - condition: time
            after: "22:00:00"
            before: "08:00:00"
            weekday:
              - sun
              - mon
              - tue
              - wed
              - thu
              - fri
              - sat
        sequence: []
      - conditions:
          - condition: trigger
            id:
              - Low-readings
        sequence:
          - action: light.turn_on
            target:
              entity_id: light.bedroom_led
            data: {}
          - action: light.turn_on
            target:
              entity_id: light.bed_side_lamp
            data:
              rgb_color:
                - 255
                - 0
                - 0
      - conditions:
          - condition: trigger
            id:
              - normal-readings
        sequence:
          - action: light.toggle
            target:
              entity_id:
                - light.bed_side_lamp
                - light.bedroom_led
            data:
              rgb_color:
                - 5
                - 159
                - 255
          - action: light.turn_off
            target:
              entity_id:
                - light.bedroom_led
                - light.bed_side_lamp
            data: {}
mode: single

Low Blood Reading Helper:

High Blood Reading Helper:

Normal Blood Range:

I am far, far from a YAML expert, but I suspect that it is because you are trying to put two triggers in one automation. I do something similar to this, but I use two automations. One for when the glucose goes low and another when it goes up.

Keep it simple.

Yes, I normally do it like you say but got used to doing more triggers! But this trigger needs 3 now has one for Low one for High and one for Normal

The Normal one wants to be Between 72 and 162 and be Blue light:

The Low needs to be 72 and anything below that: For red Light:

And High needs to be 162 and anything after for Red colour again.

They are helpers I have made but not added them to the Automation as I do not know how to add helpers yet!

But I will try to see if doing two Automation might help!

I know the red light comes on ok and goes off ok but it just does not go back to blue colour.

The helper is simply an entity. You use its state in an automation like any other entity. Do you mean how to create helpers? You just go to settings → devices → helpers and click on “Add a helper”. For this you probably want a number helper.

I mean to add it to here!

Or will it be at the trigger part when I add them?

I know how to Make a helper!

e.g

I made 3 helpers!

I have made a new Topic here to ask how to do it!
How do i add a threshold helper to an automation

I think I have figured how to get the Helper into a Automation with getting the entity of the helper!

Helper
Entity:
binary_sensor.normal_blood_reading

And add the name I gave the Helper to the Entity State then give it a Id name
The add an

Binary helper is on or off.

Come to think of it, why would you need to use a helper at all?

As I said, I am hopelessly lost in YAML, but I try.
Something like this in three automations:

{% if states("sensor.sensor.blood_sugar")|float > 75}
# Light turn on
{% else %}
# Light turn off
{% endif %}
1 Like

I was told better to use a helpers though at first I was trying in one Automation but now its better even harder with what to do really. Also hard for me to explain it all and how the lamp is behaving! I have two sets of light one are Leds the other Beside lamp and I want both to run like sunset sunrise. but then after this th exchanging of the light colour only on the lamp so the other will turn on as normal when I used the motion sensor I have setup to detect me when I stick my hand out to go to my mobile, this triggers the Leds to come on!

I’m also no good on Yaml only to copy and past into it or try to change the code a little if I feel its right and I have backed up.

Not at all sure where I would put this code your showing me. I been side tracked due to a shed coming to be thinking on this! Takes me ages to get my head around to knowing what to try.

Too many variables really but should be easy is maybe I should start again with a new lamp and keep it off the other things I already have setup! Then is one fails the other will work as normal :slight_smile: Also any excuse for a new Lamp :rofl: :rofl: :kissing_closed_eyes:

Not sure what a Binary helper is on or off is? never used it before!

It’s getting it to the colour but its harder to get it to go back to a normal colour!

@Bart_Huitsing Love the idea of the radial chart and im playing about with Measureit as suggested though it appears to measure in seconds … what scale is this graoh using as right now the % are not what they should be

image

Based on the initial dashboard by @CaptainSweatpants I created a single Lovelace card which basically holds all the current information in one mini graph. I decided to share it as it might be of value to others.

For the trend I would have loved to use built-in icons in the state mapping (or just refer to the current icon of the trend sensor instead of including the trend sensor as an entity with a state mapping) but afaik this is not possible: hence I used unicode arrows that also show well on my iOS devices (which is not as obvious as one would expect).

IMG_0798

The configuration for this card:

type: custom:mini-graph-card
animate: true
entities:
  - entity: sensor.dexcom_glucose_value
    name: Dexcom CGM
  - entity: sensor.dexcom_glucose_trend
    show_graph: false
    show_state: true
state_map:
  - value: falling_quickly
    label: ⇊
  - value: falling
    label: ↓
  - value: falling_slightly
    label: ⬊
  - value: steady
    label: →
  - value: rising_slightly
    label: ⬈
  - value: rising
    label: ↑
  - value: rising_quickly
    label: ⇈
smoothing: true
hours_to_show: 24
line_width: 3
points_per_hour: 12
hour24: true
show:
  graph: line
  labels: false
  state: true
  name: true
  icon: false
  extrema: true
  average: true
  fill: false
color_thresholds:
  - color: "#8B0000"
    value: 0
  - color: "#FF0000"
    value: 3
  - color: "#0DA035"
    value: 4
  - color: "#E0B400"
    value: 10
  - color: "#FF0000"
    value: 14
color_thresholds_transition: hard
decimals: 1
icon: mdi:diabetes
lower_bound: ~4
upper_bound: ~14
2 Likes

Shouldn’t this be true?

No, it shouldn’t as it applies to the second entity only. This way I don’t print a graph for the glucose trend, but I do use the state_map on it to translate the sensor values to an arrow (you did notice the trend arrow in the upper right of the graph, didn’t you?)

AHA! I had the trend first… (Maybe if I had read the docs for the mini-graph card.)

I wonder if the average could be used to project an A1C estimate?

Updated SugarTV, now supports any size card and visual editor, please let me know if you have any questions about how to use it. Thank you!


1 Like

Excellent post, many thanks.

For those using nightscout trend sensor, the names are different, for example instead of rising_slightly it shoes FortyfiveUp. Hence I changed the map part to

state_map:
  - value: DoubleDown
    label: ⇊
  - value: SingleDown
    label: ↓
  - value: FortyFiveDown
    label: ⬊
  - value: Flat
    label: →
  - value: FortyFiveUp
    label: ⬈
  - value: SingleUp
    label: ↑
  - value: DoubleUp
    label: ⇈
  - value: unknown
    label: "--"

I removed that entry (probably after you copied it) as the state map of the mini graph card cannot be defined per entity. As a consequence adding “unknown” to the state map resulted in spikes in the glucose value graph.

Thanks :slight_smile: