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 mmol support to nightscout #126602

Closed

Conversation

danielwindit
Copy link

Breaking change

Proposed change

This PR adds mmol/l support to the existing Nightscout integration. Mmol/l is mostly used in Europe for glucose readings.

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)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:

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
  • I have followed the perfect PR recommendations
  • The code has been formatted using Ruff (ruff format 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.

To help with the load of incoming pull requests:

Signed-off-by: Daniel Wind <[email protected]>
Copy link

@home-assistant home-assistant bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @danielwindit

It seems you haven't yet signed a CLA. Please do so here.

Once you do that we will be able to review and accept this pull request.

Thanks!

@home-assistant home-assistant bot marked this pull request as draft September 24, 2024 09:10
@home-assistant
Copy link

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍

Learn more about our pull request process.

@home-assistant
Copy link

Hey there @marciogranzotto, mind taking a look at this pull request as it has been labeled with an integration (nightscout) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of nightscout can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign nightscout Removes the current integration label and assignees on the pull request, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the pull request.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the pull request.

homeassistant/components/nightscout/config_flow.py Outdated Show resolved Hide resolved
homeassistant/components/nightscout/sensor.py Outdated Show resolved Hide resolved
@epenet epenet changed the title Added mmol support Added mmol support to nightscout Sep 24, 2024
@epenet epenet changed the title Added mmol support to nightscout Add mmol support to nightscout Sep 24, 2024
@danielwindit danielwindit marked this pull request as ready for review September 24, 2024 14:47
@home-assistant home-assistant bot requested a review from joostlek September 24, 2024 14:47
Copy link
Contributor

@epenet epenet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add the unit constants to const.py

homeassistant/components/nightscout/config_flow.py Outdated Show resolved Hide resolved
homeassistant/components/nightscout/config_flow.py Outdated Show resolved Hide resolved
homeassistant/components/nightscout/manifest.json Outdated Show resolved Hide resolved
homeassistant/components/nightscout/sensor.py Outdated Show resolved Hide resolved
homeassistant/components/nightscout/sensor.py Outdated Show resolved Hide resolved
homeassistant/components/nightscout/sensor.py Outdated Show resolved Hide resolved
homeassistant/components/nightscout/sensor.py Outdated Show resolved Hide resolved
@home-assistant home-assistant bot marked this pull request as draft September 24, 2024 15:03
@epenet
Copy link
Contributor

epenet commented Sep 24, 2024

Version is required for local testing as s custom component
It is forbidden on core

@danielwindit
Copy link
Author

Version is required for local testing as s custom component It is forbidden on core

Ok, I removed it again. The hassfest test was complaining about it. Sorry for all the commits, this is the first time I contribute.

@danielwindit danielwindit marked this pull request as ready for review September 24, 2024 17:07
@home-assistant home-assistant bot requested a review from epenet September 24, 2024 17:07
homeassistant/components/nightscout/strings.json Outdated Show resolved Hide resolved
homeassistant/components/nightscout/config_flow.py Outdated Show resolved Hide resolved
homeassistant/components/nightscout/sensor.py Outdated Show resolved Hide resolved
homeassistant/components/nightscout/sensor.py Outdated Show resolved Hide resolved
@home-assistant home-assistant bot marked this pull request as draft September 25, 2024 06:35
danielwindit and others added 4 commits September 25, 2024 08:38
Co-authored-by: epenet <[email protected]>
Co-authored-by: epenet <[email protected]>
Co-authored-by: epenet <[email protected]>
Co-authored-by: epenet <[email protected]>
@danielwindit danielwindit marked this pull request as ready for review September 25, 2024 12:52
@home-assistant home-assistant bot requested a review from epenet September 25, 2024 12:52
Co-authored-by: epenet <[email protected]>
@danielwindit danielwindit requested a review from epenet September 25, 2024 12:59
@danielwindit danielwindit requested a review from epenet September 25, 2024 13:04
@epenet
Copy link
Contributor

epenet commented Sep 25, 2024

@danielwindit thanks for your contribution thus far.
However, discussing some more with @joostlek we are unsure if this should be part of the config_flow.

Maybe it should simply be handled outside of the integration, using a Template instead.
Is there a reason that you are not using a Template entity?

Co-authored-by: Joost Lekkerkerker <[email protected]>
@danielwindit
Copy link
Author

@danielwindit thanks for your contribution thus far. However, discussing some more with @joostlek we are unsure if this should be part of the config_flow.

Maybe it should simply be handled outside of the integration, using a Template instead. Is there a reason that you are not using a Template entity?

@epenet that's what I have been using before but I couldn't get the arrow working showing which shows the delta direction. mmol/L is the most common measurement used in the UK with mg/dL predominantly used in the USA and continental Europe, that given I figured more would benefit this addition.

Copy link
Member

@frenck frenck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a duplicate of #58921, #54898, and #41382 (all closed)

We concluded this should not be part of an option flow, as that would break statistics, config flow seemed to be the better option at the time (which is in this PR).

#58921 (comment)

However; nowadays we added reconfiguration for config flows as well (which will be part of the next quality scale iteration requirements). Therefore, IMHO, both are bad options.

I think at this point there are 2 possible solutions:

  • Expose 2 sensors (also not really nice)
  • HA support unit conversations nowadays, in which the user can decide the unit to show. We could explore the ability to add a unit of measurement for this with both units.

@home-assistant home-assistant bot marked this pull request as draft September 26, 2024 11:03
@epenet
Copy link
Contributor

epenet commented Sep 26, 2024

I have opened an arch discussion for this: home-assistant/architecture#1146

@frenck frenck self-assigned this Nov 8, 2024
@frenck
Copy link
Member

frenck commented Nov 9, 2024

Replaced by #129340

With that, a user can now just select the unit they prefer on the sensor level.

../Frenck

@frenck frenck closed this Nov 9, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Nov 10, 2024
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.

4 participants