Created
April 23, 2018 18:22
-
-
Save mwilliams/db470985c2f7121a260742f52b0bb29f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
URL = '<nightscout url>/api/v1/entries.json'.freeze | |
def index | |
response = JSON.parse(HTTParty.get(URL).body) | |
chart_data = response.map {|r| r["glucose"].to_i} | |
payload = { | |
"frames": [ | |
{ | |
"text": response[0]['glucose'].to_s, | |
"icon": 'i20045', # Blue circle logo | |
"index": 0 # Latest glucose reading | |
}, | |
{ | |
"index": 1, # Sparkline | |
"chartData": chart_data.reverse | |
} | |
] | |
} | |
render json: payload | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment