tomx101
(Tomas)
January 18, 2024, 6:43pm
92
Hi dapalma,
Sorry for late response. I forgot to mention I use this helper to define change between readings. You can remove it from the config or create your own.
You will need to create a helper under Settings > Devices > Helpers. This is a input_number helper. My helper is called Dexcom Change.
Afterwards, create this automation:
alias: Glucose change helper
description: ""
trigger:
- platform: state
entity_id:
- sensor.dexcom_YOURSENSOR_glucose_value
condition: []
action:
- service: input_number.set_value
data:
value: >-
{{ ((trigger.to_state.state | int) - (trigger.from_state.state | int))
}}
target:
entity_id: input_number.dexcom_change
mode: single
mck165
(Mck165)
January 19, 2024, 10:34pm
93
Hi Tomas. I am just picking this back up now but I still can’t figure out where I am going wrong. I have the custom button card installed along with the icons. I am in lovelace and manually adding the code. I took a screenshot as I don’t know how to format the code here
mck165
(Mck165)
January 19, 2024, 10:36pm
94
this looks awesome. I tried to replicate but no luck:
wiltodelta
(Victor Kuznetsov)
January 19, 2024, 10:41pm
95
It looks like value_entity and trend_entity are incorrect.
mck165
(Mck165)
January 19, 2024, 10:45pm
96
thanks for the reply. i saw my error. is there a way to resize it? also, is there a way to adjust the time format? sorry i am a HA novice
tomx101
(Tomas)
January 22, 2024, 4:51pm
97
Make sure you create all supporting templates in templates.yaml (or your config if you’re not splitting templates.yaml). The error above means you have not defined the sensor.dexcom_glucose_status (which is a template showing in range / out of range).
mck165
(Mck165)
January 22, 2024, 4:55pm
98
thanks I am trying to paste my template.yaml here but I am not sure how to format it. from what i can tell, everything looks to be correct
tomx101
(Tomas)
January 25, 2024, 9:59pm
100
Everything looks good except the “- sensor:” part. Push that two empty spaces to the right.
Also, make sure you reference this file in your config.yaml. In your case, it should say:
template: !include templates.yaml
mck165
(Mck165)
January 26, 2024, 4:27pm
103
With your help I was able to get rid of all of the errors. There are no errors now, but nothing is displaying on the dashboard. I have all of the icons in the www folder and my config.yaml references the template now. Below is the lovelace yaml
views:
- title: Home
cards:
- type: custom:button-card
entity: sensor.dexcom_arianaeve2015_glucose_value
show_entity_picture: false
show_last_changed: false
show_icon: false
show_name: false
name: |
[[[
return `<span>${(states['sensor.dexcom_arianaeve2015_glucose_value'].state)} mg/dL</span>`
]]]
styles:
card:
- border-radius: 2%
- padding: 2.5%
- color: ivory
- font-size: 12px
- border-width: >
[[[ if (states['sensor.dexcom_glucose_status'].state === 'In Range')
return '0px';
else return '2px';
]]]
- border-color: >
[[[ if (states['sensor.dexcom_glucose_status'].state === 'Very Low')
return 'red';
if (states['sensor.dexcom_glucose_status'].state === 'Low') return 'orange';
if (states['sensor.dexcom_glucose_status'].state === 'High') return 'orange';
if (states['sensor.dexcom_glucose_status'].state === 'Very High') return 'red';
else return 'none';
]]]
grid:
- grid-template-areas: '"img img" "trend trend" "update update" "range range"'
- grid-template-columns: 1fr 1fr
- grid-template-rows: 1fr min-content min-content min-content
img_cell:
- justify-content: middle
- align-items: start
- margin: none
- padding-bottom: 5px
icon:
- width: 15%
- margin-top: 0%
- color: red
- padding-bottom: 0px
custom_fields:
state:
- align-self: start
- justify-self: end
- font-size: 17px
- padding-bottom: 5px
update:
- font-family: helvetica neue, helvetica, Arial
- font-weight: 500
- font-size: 15px
- color: grey
- align-self: middle
- justify-content: middle
- padding-bottom: 5px
- margin-top: 0px
trend:
- font-family: helvetica neue, helvetica, Arial
- color: rgba(255, 255, 255, 0.7)
- font-size: 15px
- font-weight: 300
- text-align: center
- padding-bottom: 5px
range:
- font-family: helvetica neue, helvetica, Arial
- font-size: 15px
- font-weight: 500
- text-align: center
- line-height: 30px
- color: white
- background-color: |
[[[
if ((states['sensor.dexcom_glucose_status'].state === 'Very Low'))
return "red";
if ((states['sensor.dexcom_glucose_status'].state === 'Low'))
return "orange";
if ((states['sensor.dexcom_glucose_status'].state === 'High'))
return "orange";
if ((states['sensor.dexcom_glucose_status'].state === 'Very High'))
return "red";
else
return "none";
]]]
img:
- font-weight: bold
- font-size: 15px
- color: >
[[[ if (states['sensor.dexcom_glucose_status'].state === 'In Range')
return 'grey';
if ((states['sensor.dexcom_glucose_status'].state === 'Low'))
return "orange";
if ((states['sensor.dexcom_glucose_status'].state === 'High'))
return "orange";
else return 'red';
]]]
- align-self: middle
- justify-content: middle
- padding-bottom: 65px
custom_fields:
trend: |
[[[ if (states['input_number.dexcom_change'].state > 0)
return `${(states['sensor.dexcom_arianaeve2015_glucose_trend'].state)} (+${Math.round(states['input_number.dexcom_change'].state)})`;
return `${(states['sensor.dexcom_arianaeve2015_glucose_trend'].state)} (${Math.round(states['input_number.dexcom_change'].state)})`;
]]]
update: |
[[[ return `${(states['sensor.dexcom_last_update'].state)}`; ]]]
range: |
[[[
if ((states['sensor.dexcom_glucose_status'].state === 'Very Low'))
return "VERY LOW";
if ((states['sensor.dexcom_glucose_status'].state === 'Low'))
return "LOW";
if ((states['sensor.dexcom_glucose_status'].state === 'High'))
return "HIGH";
if ((states['sensor.dexcom_glucose_status'].state === 'Very High'))
return "VERY HIGH";
if ((states['sensor.dexcom_glucose_status'].state === 'In Range'))
return "IN RANGE";
else
return "N/A";
]]]
img: |
[[[
if (states['sensor.dexcom_arianaeve2015_glucose_trend'].state == "steady")
return `<img src=/local/icons/dexcom-steady.png
style="width: 170px; height: 170px; color: #00def;">
</ha-icon><span style="font-size:30px; margin-top:-111px; display:block;">${(states['sensor.dexcom_glucose_value'].state)}</span><span style="font-size:13px; margin-top:0px; display:block;">mg/dL</span>`;
if (states['sensor.dexcom_arianaeve2015_glucose_trend'].state == "rising slightly")
return `<img src=/local/icons/dexcom-risingslightly.png
style="width: 170px; height: 170px; color: #00def;">
</ha-icon><span style="font-size:30px; margin-top:-111px; display:block;">${(states['sensor.dexcom_glucose_value'].state)}</span><span style="font-size:13px; margin-top:0px; display:block;">mg/dL</span>`;
if (states['sensor.dexcom_arianaeve2015_glucose_trend'].state == "falling slightly")
return `<img src=/local/icons/dexcom-fallingslightly.png
style="width: 170px; height: 170px; color: #00def;">
</ha-icon><span style="font-size:30px; margin-top:-111px; display:block;">${(states['sensor.dexcom_glucose_value'].state)}</span><span style="font-size:13px; margin-top:0px; display:block;">mg/dL</span>`;
if (states['sensor.dexcom_arianaeve2015_glucose_trend'].state == "falling")
return `<img src=/local/icons/dexcom-falling.png
style="width: 170px; height: 170px; color: #00def;">
</ha-icon><span style="font-size:30px; margin-top:-111px; display:block;">${(states['sensor.dexcom_glucose_value'].state)}</span><span style="font-size:13px; margin-top:0px; display:block;">mg/dL</span>`;
if (states['sensor.dexcom_arianaeve2015_glucose_trend'].state == "rising")
return `<img src=/local/icons/dexcom-rising.png
style="width: 170px; height: 170px; color: #00def;">
</ha-icon><span style="font-size:30px; margin-top:-111px; display:block;">${(states['sensor.dexcom_glucose_value'].state)}</span><span style="font-size:13px; margin-top:0px; display:block;">mg/dL</span>`;
if (states['sensor.dexcom_arianaeve2015_glucose_trend'].state == "falling quickly")
return `<img src=/local/icons/dexcom-fallingquickly1.png
style="width: 170px; height: 170px; color: #00def;">
</ha-icon><span style="font-size:30px; margin-top:-111px; display:block;">${(states['sensor.dexcom_glucose_value'].state)}</span><span style="font-size:13px; margin-top:0px; display:block;">mg/dL</span>`;
if (states['sensor.dexcom_arianaeve2015_glucose_trend'].state == "rising quickly")
return `<img src=/local/icons/dexcom-risingquickly1.png
style="width: 170px; height: 170px; color: #00def;">
</ha-icon><span style="font-size:30px; margin-top:-111px; display:block;">${(states['sensor.dexcom_glucose_value'].state)}</span><span style="font-size:13px; margin-top:0px; display:block;">mg/dL</span>`;
return `<img src=/local/icons/dexcom-steady.png
style="width: 170px; height: 170px; color: #00def;">
</ha-icon><span style="font-size:30px; margin-top:-111px; display:block;">N/A</span><span style="font-size:13px; margin-top:0px; display:block;">mg/dL</span>`;
]]]
tap_action:
action: none
tomx101
(Tomas)
January 26, 2024, 7:36pm
104
This looks fine to me. Are you sure the icons are in /www/icons folder? The path is e.g., www/icons/dexcom-steady.png. That’s the only potential issue I think of.
mck165
(Mck165)
January 26, 2024, 8:59pm
105
Thanks and Yes they are in the www. I will keep playing around with it
wiltodelta
(Victor Kuznetsov)
February 1, 2024, 4:55pm
106
Update to the latest version, it automatically uses local time settings.
1 Like
Apologize for the (very) late reply. The Medtronic provides a TiR sensor. However, I think you could use the MeasureIt integration via HACS to do the same.
teskanoo
(Teska Noo)
April 27, 2024, 7:52am
109
Thanks. Never too late… I did not know about the Measure It integration. Saved me an extra step in my calculations. I’ll try that out this weekend.
Cheers
Typ1er
(Jens)
May 3, 2024, 2:54pm
110
I use the Nightscout integration, where I have the smoothed values with the G7.
How do I reproduce the glucose trend, which is missing in Nigthscout?
nickrout
(Nick Rout)
May 3, 2024, 9:28pm
111
I don’t think you can get that in the nightscout integration, but you can with a rest sensor. I have posted how in another thread. I’m away from home, on holiday, so I’ll try to find the thread.
Edit see Using Continuous Glucose Monitor (CGM) Data - #60 by nickrout