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

Fix reservoir amount in Nightscout uploader #89

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

yo-han
Copy link
Owner

@yo-han yo-han commented Dec 6, 2024

fixes #88

Change the reservoir amount to use rawdata["reservoirRemainingUnits"] instead of rawdata["activeInsulin"]["amount"].

  • Modify custom_components/carelink/nightscout_uploader.py to update the reservoir parameter.
  • Update the __getDeviceStatus method to reflect this change.

For more details, open the Copilot Workspace session.

Related to #88

Change the reservoir amount to use `rawdata["reservoirRemainingUnits"]` instead of `rawdata["activeInsulin"]["amount"]`.

* Modify `custom_components/carelink/nightscout_uploader.py` to update the `reservoir` parameter.
* Update the `__getDeviceStatus` method to reflect this change.

---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/yo-han/Home-Assistant-Carelink/issues/88?shareId=XXXX-XXXX-XXXX-XXXX).
@yo-han yo-han mentioned this pull request Dec 6, 2024
@sedy89
Copy link
Contributor

sedy89 commented Dec 6, 2024

I just wanted to mention that I did that on purpose because otherwise, there is no IOB at all. I considered the amount of active insulin as more important than the remaining units in the reservoir. I mentioned that in the Readme. It is up to you to change it, but you would need to update the Readme too

@yo-han
Copy link
Owner Author

yo-han commented Dec 6, 2024

Ah, so it would maybe better to create an extra sensor to represent the reservoirRemainingUnits amount.

@sedy89
Copy link
Contributor

sedy89 commented Dec 6, 2024

In the HA integration we do have that sensor, but in nightscout I only figured out how to set the values for existing plug-ins like the pump plug-in I used. Unfortunately, there were only limited parameters to set and no dedicated IOB field. Therefore, I reused the remaining amount in the reservoir field

@rgsearley
Copy link

In the HA integration we do have that sensor, but in nightscout I only figured out how to set the values for existing plug-ins like the pump plug-in I used. Unfortunately, there were only limited parameters to set and no dedicated IOB field. Therefore, I reused the remaining amount in the reservoir field

the issue with using IOB as the remaining insulin is that an alarm state is created within NS showing low insulin.. if profiles are setup within NS then there is an IOB pill which is fairly accurate

also as far as im aware IOB can be set via the api

Data to send:
"type": "iob": Specify the data type as "iob" to indicate it's an IOB value.
"value": "your_iob_value": Enter the calculated IOB value.
"created_at": "timestamp": Include a timestamp for when the IOB was calculated.

curl -H "Content-Type: application/json" -X POST -d '{"type": "iob", "value": "1.2", "created_at": "2023-08-24T10:00:00Z"}' "https://yournightscoutsite.herokuapp.com/api/v1/treatments" -u "your_api_secret"

@sedy89
Copy link
Contributor

sedy89 commented Jan 24, 2025

I will check it again as soon as I have some time

@sedy89
Copy link
Contributor

sedy89 commented Jan 25, 2025

In the HA integration we do have that sensor, but in nightscout I only figured out how to set the values for existing plug-ins like the pump plug-in I used. Unfortunately, there were only limited parameters to set and no dedicated IOB field. Therefore, I reused the remaining amount in the reservoir field

the issue with using IOB as the remaining insulin is that an alarm state is created within NS showing low insulin.. if profiles are setup within NS then there is an IOB pill which is fairly accurate

also as far as im aware IOB can be set via the api

Data to send: "type": "iob": Specify the data type as "iob" to indicate it's an IOB value. "value": "your_iob_value": Enter the calculated IOB value. "created_at": "timestamp": Include a timestamp for when the IOB was calculated.

curl -H "Content-Type: application/json" -X POST -d '{"type": "iob", "value": "1.2", "created_at": "2023-08-24T10:00:00Z"}' "https://yournightscoutsite.herokuapp.com/api/v1/treatments" -u "your_api_secret"

I checked again, and it appears that your statement is not correct. The IOB value in Nightscout is comming from the treatment portal and is claculated by the information of all treatments. Check the API at YOUR_NS_URL/api-docs/ on your own NS server. You will find the API for treatments, with no option to set an overall IOB value. Treatments are only those notes within the graph which have information about carbs and insulin.
I do understand your point that you might have problems, having the IOB value reported as the reservoir amount, but you can update the code yourself in your checked out files and just give HA a restart.
Personally, I don't like the calculated IOB value in xdrip or NS and I would rather have the pump IOB than the reservoir amount.
But if people in general prefer it the other way around, it can be changed globally. I would just modify it again in my own instance - no problem.

If you think you have found a way to set the overall IOB value, try it yourself and report back. I would be happy if it is possible, but it didn't work for me (it just created a note in the graph, without information - just the time).

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.

pump reservoir
3 participants