Skip to content

Comments

Fix value_mmol_l returning mg/dL value when app native unit is mg/dL#50

Merged
PTST merged 2 commits intomainfrom
copilot/fix-value-mmol-l-issue
Feb 20, 2026
Merged

Fix value_mmol_l returning mg/dL value when app native unit is mg/dL#50
PTST merged 2 commits intomainfrom
copilot/fix-value-mmol-l-issue

Conversation

Copy link
Contributor

Copilot AI commented Feb 20, 2026

When the LibreView app's native unit is set to mg/dL, value_mmol_l incorrectly reported the raw mg/dL reading instead of converting it to mmol/L (e.g. 184 instead of ~10.22).

Root cause

Typo in get_mmol_l_value: self.gcm_value_in_mg_per_dl (non-existent attribute) instead of self.gcm.value_in_mg_per_dl.

# Before (broken — AttributeError or wrong value)
return self.gcm_value_in_mg_per_dl / 18.0

# After
return self.gcm.value_in_mg_per_dl / 18.0

Changes

  • sensor.py: Fix typo in get_mmol_l_valueself.gcm_value_in_mg_per_dlself.gcm.value_in_mg_per_dl. When app_uom == 1 (mg/dL), mmol/L is now correctly derived from the always-in-mg/dL value_in_mg_per_dl field divided by 18.0.
  • manifest.json: Bump version 1.0.01.1.6 to match release tag.
Original prompt

This section details on the original issue you should resolve

<issue_title>value_mmol_l bad value ?</issue_title>
<issue_description>Thanks to all contributors for this great work.

Checked state of variable sensor.user_name_glucose_level in Developer tools -> states.
I found a possible glitch, value_mmol_l and value_mg_dl seem to be the same:

state_class: measurement
value_mmol_l: 184
value_mg_dl: 184
target_high_mmol_l: 10
target_low_mmol_l: 3.9
target_high_mg_dl: 180
target_low_mg_dl: 70
trend: decreasing
measurement_timestamp: "2026-02-19T21:00:58+00:00"
unit_of_measurement: mg/dl
icon: mdi:arrow-bottom-right-thick
friendly_name: glucose

In current example I think that value_mmol_l should be a bit above 10 instead of 184

Please correct me if I'm wrong.

using Version 1.0.0</issue_description>

Comments on the Issue (you are @copilot in this section)

@PTST I am unable to reproduce this issue on my end. Do you use mmol/l or mg/dl as your native measurement in the app? And which unit is the integrations set to use?

But yes, that mmol value is definitely wrong unless you are in a diabetic coma or similar right now.</comment_new>
<comment_new>@PTST
My app is set to use mmol, and I guess something acts differently in the api then. I will look into it tomorrow and see if i can reproduce it if changing the units in my app as well</comment_new>
<comment_new>@PTST
It seems that you cannot change your unit of measurement in the app at all 😑

If your are up for it i will send some commands for you to execute tomorrow that will call the api. But that would include sharing the returned data with me. So that is up to you to decide whether you would be willing to do so?</comment_new>
<comment_new>@PTST
I have released v.1.1.6 which should fix this issue.
I had some wrong assumptions on how the api behaved.
Please let me know whether this release fixes the issue for you, otherwise please just reopen this issue</comment_new>
<comment_new>@PTST
Could you please provide me with the logs from
https://my.home-assistant.io/redirect/logs/</comment_new>


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Co-authored-by: PTST <17211264+PTST@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix incorrect value_mmol_l representation in glucose readings Fix value_mmol_l returning mg/dL value when app native unit is mg/dL Feb 20, 2026
Copilot AI requested a review from PTST February 20, 2026 14:20
@PTST PTST marked this pull request as ready for review February 20, 2026 14:24
@PTST PTST closed this Feb 20, 2026
@PTST PTST reopened this Feb 20, 2026
@PTST PTST merged commit 503c04f into main Feb 20, 2026
10 checks passed
@PTST PTST deleted the copilot/fix-value-mmol-l-issue branch February 20, 2026 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

value_mmol_l bad value ?

2 participants