-
Notifications
You must be signed in to change notification settings - Fork 526
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
Support Trend as a number and now as a string, Dexcom EU changed the type of Trend to string #51
Conversation
At 2021-11-30 17:00+UTC I found that, in the EU region, the Dexcom API switched the format of the Trend property. Where as previously, the Trend property was a number, it is now a string. This breaks the direction feature. here's a snip from my logs after the change: ``` Entries [ { WT: 'Date(1638301612000)', ST: 'Date(1638301612000)', DT: 'Date(1638301612000+0000)', Value: 84, Trend: 'Flat' // Previously this would've been 4 } ``` This change converts the string value back to an integer by finding the correct value in the DIRECTIONS object. This restores the direction feature It is unlikely to be rigorous since I don't now all the string values Dexcom will now return for Trend, but it certainly works for common values (up arrows, down arrows and flat)
This patch resolves #52 |
@cpitchford Good spot. I've observed this too. US users don't appear to be affected...yet. The only trend string I haven't yet seen is the equivalent of Think you'll need to adjust your conversion method for |
Attempt to match the string Trend value passed in by Dexcom. If it is a non-string, it is left unchanged (e.g if it is a integer as we expected previously) If it matches a key in DIRECTIONS, that value is used If it is converted to lowercase and spaces are removed, does it match a value in DIRECTIONS that have been similarly processed This will help if Dexcom's case or usage of spaces is not entirely determined.
Good point, I'm still getting fully up to speed! I've added some code to match the string trend after converted to lowercase and removing spaces. This should cover all eventualities , save the prospect of an entirely new string appearing. This might be worth logging if we happen to fail to match? |
Check that Trend is a number or a string as both may be returned by Dexcom API.
Thanks for improving this! I've retargeted the |
@cpitchford Great work! I was just figuring out why I saw Unicode Character “⇼” (U+21FC) in the direction field in Nightscout. Figured out it was caused by https://github.com/nightscout/cgm-remote-monitor/blob/46418c7ff275ae80de457209c1686811e033b5dd/lib/plugins/direction.js#L54 but then saw you and @bewest created a new share2nightscout-bridge and Nightscout release. Thanks a lot. |
At 2021-11-30 17:00+UTC I found that, in the EU region, the Dexcom API switched the format of the Trend property.
Where as previously, the Trend property was a number, it is now a string. This breaks the direction feature.
here's a snip from my logs after the change:
This change converts the string value back to an integer by finding the correct value in the DIRECTIONS object.
This restores the direction feature
It is unlikely to be rigorous since I don't now all the string values Dexcom will now return for Trend, but it certainly works for common values (up arrows, down arrows and flat)