From f6f5405848f1fb1123685390e3bf9e6f05a975fc Mon Sep 17 00:00:00 2001 From: Jose Paredes Date: Tue, 24 Mar 2020 22:06:14 -0500 Subject: [PATCH 01/51] Test for remote carbs entry --- lib/plugins/loop.js | 15 +++++++++++++++ lib/server/loop.js | 13 +++++++++---- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/lib/plugins/loop.js b/lib/plugins/loop.js index 9b099dd188c..914db5a1f3a 100644 --- a/lib/plugins/loop.js +++ b/lib/plugins/loop.js @@ -245,6 +245,21 @@ function init (ctx) { , split: false , targets: false , submitHook: postLoopNotification + }, + { + val: 'Remote Carbs Entry' + , name: 'Remote Carbs Entry' + , bg: false + , insulin: false + , carbs: true + , prebolus: false + , duration: true + , percent: false + , absolute: false + , profile: false + , split: false + , targets: false + , submitHook: postLoopNotification } ]; }; diff --git a/lib/server/loop.js b/lib/server/loop.js index 6a04fcd73aa..836b2a1c2b1 100644 --- a/lib/server/loop.js +++ b/lib/server/loop.js @@ -68,7 +68,16 @@ function init (env, ctx) { alert = "Cancel Temporary Override"; } else if (data.eventType === 'Temporary Override') { payload["override-name"] = data.reason; + if (data.duration !== undefined && parseInt(data.duration) > 0) { + payload["override-duration-minutes"] = parseInt(data.duration); + } alert = data.reasonDisplay + " Temporary Override"; + } else if (data.eventType === 'Remote Carbs Entry') { + //payload["carbs-entry"] = data.carbsValue; + //payload["absorption-time"] = data.absorptionTime; + //alert = "Remote Carbohydrates Entry: "+data.value+" grams\n"; + //alert += "Absorption Time: "+data.absorptionTime" hours.""; + } else { completion("Loop notification failed: Unhandled event type:", data.eventType); return; @@ -89,10 +98,6 @@ function init (env, ctx) { notification.expiry = Math.round((Date.now() / 1000)) + 60 * 5; // Allow this to enact within 5 minutes. notification.payload = payload; - if (data.duration && parseInt(data.duration) > 0) { - notification.payload["override-duration-minutes"] = parseInt(data.duration); - } - provider.send(notification, [loopSettings.deviceToken]).then( (response) => { if (response.sent && response.sent.length > 0) { completion(); From 03fa2f36b5db86d0567243df638588b6a590a2c4 Mon Sep 17 00:00:00 2001 From: Jose Paredes Date: Tue, 24 Mar 2020 22:20:00 -0500 Subject: [PATCH 02/51] default 180 mins for duration --- lib/plugins/loop.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/plugins/loop.js b/lib/plugins/loop.js index 914db5a1f3a..a0098f0a1bd 100644 --- a/lib/plugins/loop.js +++ b/lib/plugins/loop.js @@ -253,7 +253,7 @@ function init (ctx) { , insulin: false , carbs: true , prebolus: false - , duration: true + , duration: 180 , percent: false , absolute: false , profile: false From e60cbb133c2c4d183852970e5dc327d8282af6de Mon Sep 17 00:00:00 2001 From: Jose Paredes Date: Tue, 24 Mar 2020 22:24:10 -0500 Subject: [PATCH 03/51] debug --- lib/server/loop.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/server/loop.js b/lib/server/loop.js index 836b2a1c2b1..89a26897f9a 100644 --- a/lib/server/loop.js +++ b/lib/server/loop.js @@ -9,6 +9,8 @@ function init (env, ctx) { } loop.sendNotification = function sendNotification (data, remoteAddress, completion) { + + JAP_data = data; if (env.extendedSettings.loop.apnsKey === undefined || env.extendedSettings.loop.apnsKey.length == 0) { completion("Loop notification failed: LOOP_APNS_KEY not set."); return; From 0a82ad652e97af79c2e5f7ca3d6d9565aef5741d Mon Sep 17 00:00:00 2001 From: Jose Paredes Date: Tue, 24 Mar 2020 22:29:20 -0500 Subject: [PATCH 04/51] debug --- lib/server/loop.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/server/loop.js b/lib/server/loop.js index 89a26897f9a..626dc26cf05 100644 --- a/lib/server/loop.js +++ b/lib/server/loop.js @@ -1,4 +1,4 @@ -'use strict'; +#'use strict'; const apn = require('apn'); From 34b299d748abfb8b8e6d2619af935c7f100883eb Mon Sep 17 00:00:00 2001 From: Jose Paredes Date: Tue, 24 Mar 2020 22:38:52 -0500 Subject: [PATCH 05/51] debug --- lib/server/loop.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/server/loop.js b/lib/server/loop.js index 626dc26cf05..9d99a4a4e43 100644 --- a/lib/server/loop.js +++ b/lib/server/loop.js @@ -1,4 +1,4 @@ -#'use strict'; +//'use strict'; const apn = require('apn'); From 675c93cf7104d78c26e5c2135e28e7c0e2136ed4 Mon Sep 17 00:00:00 2001 From: Jose Paredes Date: Tue, 24 Mar 2020 23:03:18 -0500 Subject: [PATCH 06/51] debug --- lib/plugins/loop.js | 8 ++++++-- lib/server/loop.js | 1 - 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/plugins/loop.js b/lib/plugins/loop.js index a0098f0a1bd..28d699fc8ba 100644 --- a/lib/plugins/loop.js +++ b/lib/plugins/loop.js @@ -252,8 +252,9 @@ function init (ctx) { , bg: false , insulin: false , carbs: true - , prebolus: false - , duration: 180 + , protein: true + , prebolus: false + , duration: false , percent: false , absolute: false , profile: false @@ -264,6 +265,9 @@ function init (ctx) { ]; }; + // TODO: Add event listener to customize labels + + loop.updateVisualisation = function updateVisualisation (sbx) { var prop = sbx.properties.loop; diff --git a/lib/server/loop.js b/lib/server/loop.js index 9d99a4a4e43..69fc065038e 100644 --- a/lib/server/loop.js +++ b/lib/server/loop.js @@ -10,7 +10,6 @@ function init (env, ctx) { loop.sendNotification = function sendNotification (data, remoteAddress, completion) { - JAP_data = data; if (env.extendedSettings.loop.apnsKey === undefined || env.extendedSettings.loop.apnsKey.length == 0) { completion("Loop notification failed: LOOP_APNS_KEY not set."); return; From ef25394747fe057810a341d90374e7cee3ee3348 Mon Sep 17 00:00:00 2001 From: Jose Paredes Date: Tue, 24 Mar 2020 23:18:35 -0500 Subject: [PATCH 07/51] debug --- lib/plugins/loop.js | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/lib/plugins/loop.js b/lib/plugins/loop.js index 28d699fc8ba..f8ce08b6c57 100644 --- a/lib/plugins/loop.js +++ b/lib/plugins/loop.js @@ -249,17 +249,8 @@ function init (ctx) { { val: 'Remote Carbs Entry' , name: 'Remote Carbs Entry' - , bg: false - , insulin: false , carbs: true - , protein: true - , prebolus: false - , duration: false - , percent: false - , absolute: false - , profile: false - , split: false - , targets: false + , duration: {displayName: 180 } , submitHook: postLoopNotification } ]; From d731d4b4ecd783c7debd55aabc907314f2d23a3a Mon Sep 17 00:00:00 2001 From: Jose Paredes Date: Tue, 24 Mar 2020 23:24:04 -0500 Subject: [PATCH 08/51] debug --- lib/server/loop.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/server/loop.js b/lib/server/loop.js index 69fc065038e..b13a7a6fca4 100644 --- a/lib/server/loop.js +++ b/lib/server/loop.js @@ -10,6 +10,8 @@ function init (env, ctx) { loop.sendNotification = function sendNotification (data, remoteAddress, completion) { + console.log(data); + if (env.extendedSettings.loop.apnsKey === undefined || env.extendedSettings.loop.apnsKey.length == 0) { completion("Loop notification failed: LOOP_APNS_KEY not set."); return; From c73ad9322d6ea0144d4a425982bc3ff0cda3b425 Mon Sep 17 00:00:00 2001 From: Jose Paredes Date: Tue, 24 Mar 2020 23:38:03 -0500 Subject: [PATCH 09/51] debug --- lib/server/loop.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/server/loop.js b/lib/server/loop.js index b13a7a6fca4..7c09b3cd174 100644 --- a/lib/server/loop.js +++ b/lib/server/loop.js @@ -10,7 +10,8 @@ function init (env, ctx) { loop.sendNotification = function sendNotification (data, remoteAddress, completion) { - console.log(data); + console.log("JAP"); + console.log(data); if (env.extendedSettings.loop.apnsKey === undefined || env.extendedSettings.loop.apnsKey.length == 0) { completion("Loop notification failed: LOOP_APNS_KEY not set."); From ec582e1509c0e65219f2d5cb6764ecf9f1097393 Mon Sep 17 00:00:00 2001 From: Jose Paredes Date: Tue, 24 Mar 2020 23:43:53 -0500 Subject: [PATCH 10/51] debug --- lib/server/loop.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/server/loop.js b/lib/server/loop.js index 7c09b3cd174..27e68624013 100644 --- a/lib/server/loop.js +++ b/lib/server/loop.js @@ -10,8 +10,8 @@ function init (env, ctx) { loop.sendNotification = function sendNotification (data, remoteAddress, completion) { - console.log("JAP"); - console.log(data); + console.info("JAP"); + console.info(data); if (env.extendedSettings.loop.apnsKey === undefined || env.extendedSettings.loop.apnsKey.length == 0) { completion("Loop notification failed: LOOP_APNS_KEY not set."); @@ -77,10 +77,10 @@ function init (env, ctx) { } alert = data.reasonDisplay + " Temporary Override"; } else if (data.eventType === 'Remote Carbs Entry') { - //payload["carbs-entry"] = data.carbsValue; - //payload["absorption-time"] = data.absorptionTime; - //alert = "Remote Carbohydrates Entry: "+data.value+" grams\n"; - //alert += "Absorption Time: "+data.absorptionTime" hours.""; + payload["carbs-entry"] = data.carbs; + payload["absorption-time"] = data.duration/60; + alert = "Remote Carbohydrates Entry: "+data.carbs+" grams\n"; + alert += "Absorption Time: "+data.duration/60" hours.""; } else { completion("Loop notification failed: Unhandled event type:", data.eventType); From ba3ef0feceae7346add22ed0618e66d446ec4410 Mon Sep 17 00:00:00 2001 From: Jose Paredes Date: Tue, 24 Mar 2020 23:47:54 -0500 Subject: [PATCH 11/51] debug --- lib/server/loop.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/server/loop.js b/lib/server/loop.js index 27e68624013..443b966babd 100644 --- a/lib/server/loop.js +++ b/lib/server/loop.js @@ -80,7 +80,7 @@ function init (env, ctx) { payload["carbs-entry"] = data.carbs; payload["absorption-time"] = data.duration/60; alert = "Remote Carbohydrates Entry: "+data.carbs+" grams\n"; - alert += "Absorption Time: "+data.duration/60" hours.""; + alert += "Absorption Time: "+data.duration/60+" hours.""; } else { completion("Loop notification failed: Unhandled event type:", data.eventType); From 51f95f1f244127c910f7f7da1ef8f76a4fa16a21 Mon Sep 17 00:00:00 2001 From: Jose Paredes Date: Tue, 24 Mar 2020 23:52:40 -0500 Subject: [PATCH 12/51] debug --- lib/server/loop.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/server/loop.js b/lib/server/loop.js index 443b966babd..fa36561a6e1 100644 --- a/lib/server/loop.js +++ b/lib/server/loop.js @@ -10,8 +10,8 @@ function init (env, ctx) { loop.sendNotification = function sendNotification (data, remoteAddress, completion) { - console.info("JAP"); - console.info(data); + // console.info("JAP"); + // console.info(data); if (env.extendedSettings.loop.apnsKey === undefined || env.extendedSettings.loop.apnsKey.length == 0) { completion("Loop notification failed: LOOP_APNS_KEY not set."); From 77315109676d2d60f3b9f6351a48906255e7b04f Mon Sep 17 00:00:00 2001 From: Jose Paredes Date: Tue, 24 Mar 2020 23:57:08 -0500 Subject: [PATCH 13/51] debug --- lib/server/loop.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/server/loop.js b/lib/server/loop.js index fa36561a6e1..c13f3e941bb 100644 --- a/lib/server/loop.js +++ b/lib/server/loop.js @@ -77,10 +77,12 @@ function init (env, ctx) { } alert = data.reasonDisplay + " Temporary Override"; } else if (data.eventType === 'Remote Carbs Entry') { - payload["carbs-entry"] = data.carbs; - payload["absorption-time"] = data.duration/60; - alert = "Remote Carbohydrates Entry: "+data.carbs+" grams\n"; - alert += "Absorption Time: "+data.duration/60+" hours.""; + completion("Data:", data); + return; + //payload["carbs-entry"] = data.carbs; + //payload["absorption-time"] = data.duration/60; + //alert = "Remote Carbohydrates Entry: "+data.carbs+" grams\n"; + //alert += "Absorption Time: "+data.duration/60+" hours.""; } else { completion("Loop notification failed: Unhandled event type:", data.eventType); From e475de7ed9aabba1ea91c5ea58e22e2a7fb8f8f3 Mon Sep 17 00:00:00 2001 From: Jose Paredes Date: Wed, 25 Mar 2020 00:03:14 -0500 Subject: [PATCH 14/51] debug --- lib/server/loop.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/server/loop.js b/lib/server/loop.js index c13f3e941bb..f278f02e42e 100644 --- a/lib/server/loop.js +++ b/lib/server/loop.js @@ -77,11 +77,9 @@ function init (env, ctx) { } alert = data.reasonDisplay + " Temporary Override"; } else if (data.eventType === 'Remote Carbs Entry') { - completion("Data:", data); - return; - //payload["carbs-entry"] = data.carbs; + payload["carbs-entry"] = data.carbs; //payload["absorption-time"] = data.duration/60; - //alert = "Remote Carbohydrates Entry: "+data.carbs+" grams\n"; + alert = "Remote Carbohydrates Entry: "+data.carbs+" grams\n"; //alert += "Absorption Time: "+data.duration/60+" hours.""; } else { From 10a79d43f54e82509819c4d2c079a1d4b46de760 Mon Sep 17 00:00:00 2001 From: Jose Paredes Date: Wed, 25 Mar 2020 00:12:00 -0500 Subject: [PATCH 15/51] debug --- lib/server/loop.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/server/loop.js b/lib/server/loop.js index f278f02e42e..1ba4ca11b83 100644 --- a/lib/server/loop.js +++ b/lib/server/loop.js @@ -77,9 +77,9 @@ function init (env, ctx) { } alert = data.reasonDisplay + " Temporary Override"; } else if (data.eventType === 'Remote Carbs Entry') { - payload["carbs-entry"] = data.carbs; + payload["carbs-entry"] = 10.0; //data.carbs; //payload["absorption-time"] = data.duration/60; - alert = "Remote Carbohydrates Entry: "+data.carbs+" grams\n"; + alert = "Remote Carbs Entry: "+data.carbs+" grams\n"; //alert += "Absorption Time: "+data.duration/60+" hours.""; } else { From 25e548d1f765693a8983effcaef58695bb93966c Mon Sep 17 00:00:00 2001 From: Jose Paredes Date: Wed, 25 Mar 2020 00:21:56 -0500 Subject: [PATCH 16/51] debug --- lib/server/loop.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/server/loop.js b/lib/server/loop.js index 1ba4ca11b83..7f6ad03bedd 100644 --- a/lib/server/loop.js +++ b/lib/server/loop.js @@ -77,10 +77,13 @@ function init (env, ctx) { } alert = data.reasonDisplay + " Temporary Override"; } else if (data.eventType === 'Remote Carbs Entry') { - payload["carbs-entry"] = 10.0; //data.carbs; - //payload["absorption-time"] = data.duration/60; - alert = "Remote Carbs Entry: "+data.carbs+" grams\n"; - //alert += "Absorption Time: "+data.duration/60+" hours.""; + payload["carbs-entry"] = parseFloat(data.carbs); + payload["absorption-time"] = 3.0; + if (data.duration !== undefined && parseInt(data.duration) > 0) { + payload["absorption-time"] = parseInt(data.duration) / 60; + } + alert = "Remote Carbs Entry: "+payload["carbs-entry"]+" grams\n"; + alert += "Absorption Time: "+payload["absorption-time"]+" hours.""; } else { completion("Loop notification failed: Unhandled event type:", data.eventType); From d6246574744c4a96c73611e9151d817d44e28648 Mon Sep 17 00:00:00 2001 From: Jose Paredes Date: Wed, 25 Mar 2020 00:28:51 -0500 Subject: [PATCH 17/51] debug --- lib/server/loop.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/server/loop.js b/lib/server/loop.js index 7f6ad03bedd..ea33d5e3e58 100644 --- a/lib/server/loop.js +++ b/lib/server/loop.js @@ -79,11 +79,11 @@ function init (env, ctx) { } else if (data.eventType === 'Remote Carbs Entry') { payload["carbs-entry"] = parseFloat(data.carbs); payload["absorption-time"] = 3.0; - if (data.duration !== undefined && parseInt(data.duration) > 0) { - payload["absorption-time"] = parseInt(data.duration) / 60; + if (data.duration !== undefined && parseFloat(data.duration) > 0) { + payload["absorption-time"] = parseFloat(data.duration) / 60; } alert = "Remote Carbs Entry: "+payload["carbs-entry"]+" grams\n"; - alert += "Absorption Time: "+payload["absorption-time"]+" hours.""; + alert += "Absorption Time: "+payload["absorption-time"]+" hours""; } else { completion("Loop notification failed: Unhandled event type:", data.eventType); From 5b3cbae37fa879fd9607626e36a015d27605f902 Mon Sep 17 00:00:00 2001 From: Jose Paredes Date: Wed, 25 Mar 2020 00:34:33 -0500 Subject: [PATCH 18/51] debug --- lib/server/loop.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/server/loop.js b/lib/server/loop.js index ea33d5e3e58..af8ea40b855 100644 --- a/lib/server/loop.js +++ b/lib/server/loop.js @@ -78,12 +78,12 @@ function init (env, ctx) { alert = data.reasonDisplay + " Temporary Override"; } else if (data.eventType === 'Remote Carbs Entry') { payload["carbs-entry"] = parseFloat(data.carbs); - payload["absorption-time"] = 3.0; - if (data.duration !== undefined && parseFloat(data.duration) > 0) { - payload["absorption-time"] = parseFloat(data.duration) / 60; - } + //payload["absorption-time"] = 3.0; + //if (data.duration !== undefined && parseFloat(data.duration) > 0.0) { + //payload["absorption-time"] = parseFloat(data.duration) / 60.0; + //} alert = "Remote Carbs Entry: "+payload["carbs-entry"]+" grams\n"; - alert += "Absorption Time: "+payload["absorption-time"]+" hours""; + //alert += "Absorption Time: "+payload["absorption-time"]+" hours""; } else { completion("Loop notification failed: Unhandled event type:", data.eventType); From 9028adf15d3dcedb16d94dbd822c917139215ea9 Mon Sep 17 00:00:00 2001 From: Jose Paredes Date: Wed, 25 Mar 2020 00:42:16 -0500 Subject: [PATCH 19/51] debug --- lib/plugins/loop.js | 2 +- lib/server/loop.js | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/plugins/loop.js b/lib/plugins/loop.js index f8ce08b6c57..5c84f0c714e 100644 --- a/lib/plugins/loop.js +++ b/lib/plugins/loop.js @@ -250,7 +250,7 @@ function init (ctx) { val: 'Remote Carbs Entry' , name: 'Remote Carbs Entry' , carbs: true - , duration: {displayName: 180 } + , duration: "180" , submitHook: postLoopNotification } ]; diff --git a/lib/server/loop.js b/lib/server/loop.js index af8ea40b855..96e823670ec 100644 --- a/lib/server/loop.js +++ b/lib/server/loop.js @@ -78,12 +78,12 @@ function init (env, ctx) { alert = data.reasonDisplay + " Temporary Override"; } else if (data.eventType === 'Remote Carbs Entry') { payload["carbs-entry"] = parseFloat(data.carbs); - //payload["absorption-time"] = 3.0; - //if (data.duration !== undefined && parseFloat(data.duration) > 0.0) { - //payload["absorption-time"] = parseFloat(data.duration) / 60.0; - //} + payload["absorption-time"] = 3.0; + if (data.duration !== undefined && parseFloat(data.duration) > 0.0) { + payload["absorption-time"] = parseFloat(data.duration) / 60.0; + } alert = "Remote Carbs Entry: "+payload["carbs-entry"]+" grams\n"; - //alert += "Absorption Time: "+payload["absorption-time"]+" hours""; + alert += "Absorption Time: "+payload["absorption-time"]+" hours"; } else { completion("Loop notification failed: Unhandled event type:", data.eventType); From 8c1cb40173f3cf749f62fd6f64f4d3277304b355 Mon Sep 17 00:00:00 2001 From: Jose Paredes Date: Wed, 25 Mar 2020 01:15:28 -0500 Subject: [PATCH 20/51] debug --- lib/plugins/loop.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/plugins/loop.js b/lib/plugins/loop.js index 5c84f0c714e..dc6f9f7f7bb 100644 --- a/lib/plugins/loop.js +++ b/lib/plugins/loop.js @@ -250,7 +250,7 @@ function init (ctx) { val: 'Remote Carbs Entry' , name: 'Remote Carbs Entry' , carbs: true - , duration: "180" + , duration: true , submitHook: postLoopNotification } ]; From c586c55b93d205e484286d9d60bfbacd7c522738 Mon Sep 17 00:00:00 2001 From: Jose Paredes Date: Wed, 25 Mar 2020 11:35:13 -0500 Subject: [PATCH 21/51] New Treatement Entries --- views/index.html | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/views/index.html b/views/index.html index 7690dcc848c..5829539af76 100644 --- a/views/index.html +++ b/views/index.html @@ -331,6 +331,18 @@ Sensor
+ + +
+