I am trying to get HA to provide a better way of managing my wife’s Type1 Diabetes and I have been trawling through these very forums and the internet on ideas / suggestions / etc on how best to do this.
I have integrations with the Dexcom, i have a decent range of 90 days of historical data and though I am making great process I am stumped on how best to achieve the following result.
For clarity I have the following sensor created and running which provides a multitude of states, this is mainly in place to produce ‘Time in Range’ graphs.
The sensor is a s follows;
- platform: template
sensors:
emily_time_in_range:
unique_id: emily_time_in_range
value_template: >-
{% set bloods_inrange = states('sensor.emily_glucose_value') | float %}
{% if bloods_inrange >= 20 %}
Very High
{% elif bloods_inrange > 14 %}
High
{% elif bloods_inrange >= 6 %}
InRange
{% elif bloods_inrange >= 3 %}
Low
{% elif bloods_inrange >= 0.0 %}
Very Low
{% else %}
Undefined
{% endif %}
What I wish to reproduce is the following, i can select the date range accordingly but ultimately it will always total 100% with each individual state being a percentage of the total
For me this is a head scratcher so any advice would be greatly appreciated