Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support to a different unit of measurement(mmol/L) on Nightscout #58921

Conversation

marciogranzotto
Copy link
Contributor

Breaking change

Proposed change

Bulding upon #54898 this PR uses the updated py-nightscout lib that has the new unit values conversion done, providing values like sgv_mmol and delta_mmol . If the user selects the mmol/L unit, we just change which property of the response we use on the entity

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • The code has been formatted using Black (black --fast homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description. https://github.com/marciogranzotto/py-nightscout/releases
  • Untested files have been added to .coveragerc.

The integration reached or maintains the following Integration Quality Scale:

  • No score or internal
  • 🥈 Silver
  • 🥇 Gold
  • 🏆 Platinum

To help with the load of incoming pull requests:

@frenck
Copy link
Member

frenck commented Nov 2, 2021

I don't think this needs to be an option flow. As a matter of fact, an option flow will cause problems as it can change the UoM for an entity, which isn't compatible with the long-term statistics.

So the comment of the previous PR still holds.

@marciogranzotto
Copy link
Contributor Author

@frenck what you propose for people that need this value in mmol/L instead of mg/dL? I'm happy to give it a shot with some other kind of implementation

@frenck
Copy link
Member

frenck commented Nov 2, 2021

Provide it as a secondary sensor (but disabled by default?)

@marciogranzotto
Copy link
Contributor Author

btw, the dexcom integration does this in the same way, on the config flow:
https://github.com/home-assistant/core/blob/dev/homeassistant/components/dexcom/config_flow.py

@frenck
Copy link
Member

frenck commented Nov 2, 2021

btw, the dexcom integration does this in the same way, on the config flow:

I see, that will break stuff if the user changes it. So for that matter won't recommend on copying that pattern (nor will I approve such pattern).

@marciogranzotto
Copy link
Contributor Author

marciogranzotto commented Nov 2, 2021

Yeah, I guess that makes sense with the long-term statistics.
I just don't really like the idea of having a disabled secondary sensor for that...
Maybe if we move the unit or measurement to the actual setup and don't allow it to be changed afterwards?

@frenck
Copy link
Member

frenck commented Nov 2, 2021

Maybe if we move the unit or measurement to the actual setup and don't allow it to be changed afterwards?

I don't think that makes sense or is needed. There is nothing wrong with a secondary sensor.

@marciogranzotto
Copy link
Contributor Author

marciogranzotto commented Nov 7, 2021

@frenck I think that the use case here is to always just use mmol/L or mg/dL.
Just to clarify for anyone that is not aware of how blood glucose works:
Different countries use different measurement units, much like the imperial/metric system.
The international standard is mmol/L, but there's a lot of countries that use mg/dL such as the USA, Germany, and here in Brazil.
mg/dL is also the only unit that Nightscout exposes on their API. I think that's because it's an integer number, instead of a float on mmol/L.

Either way, my point is that I think the user should just choose which unit it's used where they live, on the setup flow, and never change it again since there's no need to.

@frenck
Copy link
Member

frenck commented Nov 9, 2021

It could be part of the config flow (not option flow), that way it isn't changeable. But honestly, expose both sensors will satisfy any user. It isn't expensive.

Proposed change to advise on use of an access token rather than API_SECRET, Provide link to nightscout guide.
Proposed change to advise on use of an access token rather than API_SECRET, Provide link to nightscout guide.
advise on use of an access token rather than API_SECRET
@markvader
Copy link
Contributor

markvader commented Nov 23, 2021

mg/dL is also the only unit that Nightscout exposes on their API. I think that's because it's an integer number, instead of a float on mmol/L.

Either way, my point is that I think the user should just choose which unit it's used where they live, on the setup flow, and never change it again since there's no need to.

We've already made our selection into the unit of measurement to be used when we set up our personal nightscout sites and I agree this is unlikely to ever be changed.

@marciogranzotto The unit setting is exposed by the nightscout API (abet on the server_status call rather than individual entries/sgv calls).
Can we use this call server_status.settings["units"] to set the particular sensor that is enabled on sensor setup (and conversely disable the sensor that is not returned from the api call)?

As a user i'd be happy to enable/disable the appropriate sensor if it was not set automatically

@marciogranzotto
Copy link
Contributor Author

@markvader thanks, I'll take a look on it!

@bbredewold
Copy link

@markvader thanks, I'll take a look on it!

Hi @marciogranzotto, did you have any time to look into this? I don't know if I could help, since I've never contributed to HA before... I'm very exciting use the mmol option soon ;)

Integration setup - advice on use of an access token rather than API_SECRET
@github-actions
Copy link

There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days.
Thank you for your contributions.

@github-actions github-actions bot added the stale label Jun 13, 2022
@github-actions github-actions bot closed this Jun 22, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Jun 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

nightscout integration should support mmol/l in addition to mg/ml
6 participants