Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 101 additions & 3 deletions lib/language.js
Original file line number Diff line number Diff line change
Expand Up @@ -12078,7 +12078,7 @@ function init() {
'alexaIobIntent': {
bg: 'Máte %1 jednotek aktivního inzulínu'
, cs: 'You have %1 insulin on board'
, de: 'Du hast noch %1 Insulin wirkend'
, de: 'Du hast %1 Insulin wirkend'
, dk: 'Du har %1 insulin i kroppen'
, el: 'You have %1 insulin on board'
, en: 'You have %1 insulin on board'
Expand Down Expand Up @@ -12137,7 +12137,7 @@ function init() {
, fr: 'Your'
, he: 'Your'
, hr: 'Your'
, it: 'Tuo'
, it: 'La tua'
, ko: 'Your'
, nb: 'Your'
, pl: 'twój'
Expand All @@ -12150,6 +12150,31 @@ function init() {
, zh_cn: '你的'
, zh_tw: 'Your'
},
'alexaPreambleHaving': {
bg: 'You have'
, cs: 'You have'
, de: 'Du hast'
, dk: 'You have'
, el: 'You have'
, en: 'You have'
, es: 'You have'
, fi: 'You have'
, fr: 'You have'
, he: 'You have'
, hr: 'You have'
, it: 'Tu hai'
, ko: 'You have'
, nb: 'You have'
, pl: 'You have'
, pt: 'You have'
, nl: 'You have'
, ro: 'You have'
, ru: 'You have'
, sk: 'You have'
, sv: 'You have'
, zh_cn: 'You have'
, zh_tw: 'You have'
},
'alexaPreamble3person': {
bg: '%1 has a '
, cs: '%1 má '
Expand All @@ -12175,7 +12200,32 @@ function init() {
, zh_cn: '%1 有一个 '
, zh_tw: '%1 has a '
},
'alexaNoInsulin': {
'alexaPreamble3person': {
bg: '%1 has a '
, cs: '%1 má '
, de: '%1 hat eine'
, dk: '%1 har en '
, el: '%1 has a '
, en: '%1 has a '
, es: '%1 tiene un '
, fi: '%1 on '
, fr: '%1 has a '
, he: '%1 has a '
, hr: '%1 has a '
, it: '%1 ha un '
, ko: '%1 has a '
, nb: '%1 has a '
, nl: '%1 heeft een '
, pl: '%1 ma '
, pt: '%1 has a '
, ro: '%1 are '
, ru: '%1 имеет '
, sk: '%1 has a '
, sv: '%1 has a '
, zh_cn: '%1 有一个 '
, zh_tw: '%1 has a '
},
'alexaNo': {
bg: 'no'
, cs: 'žádný'
, de: 'kein'
Expand Down Expand Up @@ -12206,6 +12256,7 @@ function init() {
, en: 'Your uploader battery is at %1'
, de: 'Der Akku deines Uploader Handys ist bei %1'
, dk: 'Din uploaders batteri er %1'
, it: 'La batteria del tuo dispositivo è %1'
, nl: 'De batterij van je mobiel is bij %l'
,zh_cn: '你的手机电池电量是 %1 '
, sv: 'Din uppladdares batteri är %1'
Expand All @@ -12220,6 +12271,7 @@ function init() {
, en: 'You have %1 units remaining'
, de: 'Du hast %1 Einheiten übrig'
, dk: 'Du har %1 enheder tilbage'
, it: 'Ci sono ancora %1 unità rimanenti'
, nl: 'Je hebt nog %l eenheden in je reservoir'
,zh_cn: '你剩余%1 U的胰岛素'
, sv: 'Du har %1 enheter kvar'
Expand All @@ -12234,6 +12286,7 @@ function init() {
, en: 'Your pump battery is at %1 %2'
, de: 'Der Batteriestand deiner Pumpe ist bei %1 %2'
, dk: 'Din pumpes batteri er %1 %2'
, it: 'La batteria del microinfusore è al %1 %2'
, nl: 'Je pomp batterij is bij %1 %2'
,zh_cn: '你的泵电池电量是%1 %2'
, sv: 'Din pumps batteri är %1 %2'
Expand All @@ -12248,6 +12301,7 @@ function init() {
, en: 'The last successful loop was %1'
, de: 'Der letzte erfolgreiche Loop war %1'
, dk: 'Seneste successfulde loop var %1'
, it: 'L ultimo loop riuscito di %1'
, nl: 'De meest recente goede loop was %1'
,zh_cn: '最后一次成功闭环的是在%1'
, sv: 'Senaste lyckade loop var %1'
Expand All @@ -12262,6 +12316,7 @@ function init() {
, en: 'Loop plugin does not seem to be enabled'
, de: 'Das Loop Plugin scheint nicht aktiviert zu sein'
, dk: 'Loop plugin lader ikke til at være slået til'
, it: 'Non è attivato il plugin di Loop'
, nl: 'De Loop plugin is niet geactiveerd'
,zh_cn: 'Loop插件看起来没有被启用'
, sv: 'Loop plugin verkar inte vara aktiverad'
Expand All @@ -12276,6 +12331,7 @@ function init() {
, en: 'According to the loop forecast you are expected to be %1 over the next %2'
, de: 'Entsprechend der Loop Vorhersage landest du bei %1 während der nächsten %2'
, dk: 'Ifølge Loops forudsigelse forventes du at blive %1 i den næste %2'
, it: 'In base alla predizione di Loop la tua glicemia sarà di %1 nei prossimi %2'
, nl: 'Volgens de Loop voorspelling is je waarde %1 over de volgnede %2'
,zh_cn: '根据loop的预测,在接下来的%2你的血糖将会是%1'
, sv: 'Enligt Loops förutsägelse förväntas du bli %1 inom %2'
Expand All @@ -12290,6 +12346,7 @@ function init() {
, en: 'Unable to forecast with the data that is available'
, de: 'Mit den verfügbaren Daten ist eine Loop Vorhersage nicht möglich'
, dk: 'Det er ikke muligt at forudsige md de tilgængelige data'
, it: 'Non è possibile avere una predizione con i dati disponibili'
, nl: 'Niet mogelijk om een voorspelling te doen met de data die beschikbaar is'
,zh_cn: '血糖数据不可用,无法预测未来走势'
, sv: 'Förutsägelse ej möjlig med tillgänlig data'
Expand All @@ -12298,11 +12355,27 @@ function init() {
, pl: 'Prognoza pętli nie jest możliwa, z dostępnymi danymi.'
, ru: 'прогноз при таких данных невозможен'
},
'alexaLoop': {
bg: 'According to the loop forecast you are expected to be %1 over the next %2'
, cs: 'According to the loop forecast you are expected to be %1 over the next %2'
, en: 'According to the loop forecast you are expected to be %1 over the next %2'
, de: 'Laut Loop Vorhersage liegst du in %2 bei %1'
, dk: 'According to the loop forecast you are expected to be %1 over the next %2'
, it: 'In base alla previsione di Loop la glicemia sarà %1 %2'
, nl: 'According to the loop forecast you are expected to be %1 over the next %2'
,zh_cn: 'According to the loop forecast you are expected to be %1 over the next %2'
, sv: 'According to the loop forecast you are expected to be %1 over the next %2'
, fi: 'According to the loop forecast you are expected to be %1 over the next %2'
, ro: 'According to the loop forecast you are expected to be %1 over the next %2'
, pl: 'According to the loop forecast you are expected to be %1 over the next %2'
, ru: 'According to the loop forecast you are expected to be %1 over the next %2'
},
'alexaRawBG': {
en: 'Your raw bg is %1'
, cs: 'Raw glykémie je %1'
, de: 'Dein Rohblutzucker ist %1'
, dk: 'Dit raw blodsukker er %1'
, it: 'Il dato grezzo della glicemia è %1'
, nl: 'Je raw bloedwaarde is %1'
,zh_cn: '你的血糖是 %1'
, sv: 'Ditt raw blodsocker är %1'
Expand All @@ -12312,11 +12385,20 @@ function init() {
, pl: 'Glikemia RAW wynosi %1'
, ru: 'ваши необработанные данные RAW $1'
},
'alexaAr2NoHandler': {
en: 'AR2 plugin does not seem to be enabled',
de: 'AR2 Plugin ist nicht aktiviert'
},
'alexaAr2Handler': {
en: 'You are expected to be between %1 and %2 over the %3',
de: 'Der %3 erwartete Blutzucker liegt zwischen %1 und %2'
},
'alexaOpenAPSForecast': {
en: 'The OpenAPS Eventual BG is %1'
, cs: 'OpenAPS Eventual BG je %1'
, de: 'Der von OpenAPS vorhergesagte Blutzucker ist %1'
, dk: 'OpenAPS forventet blodsukker er %1'
, it: 'La glicemia predetta da OpenAPS è %1'
, nl: 'OpenAPS uiteindelijke bloedglucose van %1'
,zh_cn: 'OpenAPS 预测最终血糖是 %1'
, sv: 'OpenAPS slutgiltigt blodsocker är %1'
Expand All @@ -12331,6 +12413,21 @@ function init() {
, cs: '%1 %2 aktivních sachridů'
, de: '%1 %2 Gramm Kohlenhydrate wirkend.'
, dk: '%1 %2 gram aktive kulhydrater'
, it: '%1 %2 grammi di carboidrati da digerire'
, nl: '%1 %2 actieve koolhydraten'
,zh_cn: '%1 %2 活性碳水化合物'
, sv: '%1 %2 gram aktiva kolhydrater'
, fi: '%1 %2 aktiivista hiilihydraattia'
, ro: '%1 %2 carbohidrați activi în corp'
,bg: '%1 %2 carbohydrates on board'
, pl: '%1 %2 aktywnych węglowodanów'
, ru: '%1 $2 активных углеводов'
},
'alexaCOB3erson': {
en: '%1 has %2 carbohydrates on board'
, cs: '%1 %2 aktivních sachridů'
, de: '%1 hat %2 Gramm Kohlenhydrate wirkend.'
, dk: '%1 %2 gram aktive kulhydrater'
, nl: '%1 %2 actieve koolhydraten'
,zh_cn: '%1 %2 活性碳水化合物'
, sv: '%1 %2 gram aktiva kolhydrater'
Expand All @@ -12345,6 +12442,7 @@ function init() {
,de: 'Fett [g]'
,dk: 'Fet [g]'
,es: 'Grasas [g]'
,it: 'Grassi [g]'
,fi: 'Rasva [g]'
,fr: 'Graisses [g]'
,nl: 'Vet [g]'
Expand Down
37 changes: 32 additions & 5 deletions lib/plugins/alexa-plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,19 @@ To get up and running with a basic interaction model, which will allow you to as
"values": [
{
"name": {
"value": "bg"
"value": "bg",
"synonyms": [
"BZ",
"Blutzucker" //these could be some synonyms to the above value in YOUR language!
]
}
},
{
"name": {
"value": "blood glucose"
"value": "blood glucose",
"synonyms": [
//here could be some synonyms to the above value in YOUR language!
]
}
},
{
Expand All @@ -128,7 +135,14 @@ To get up and running with a basic interaction model, which will allow you to as
},
{
"name": {
"value": "iob"
"value": "iob",
"synonyms": [
"Insulin an Board",
"Restwirkung",
"Wirkinsulin"
//here could be some synonyms to the above value in YOUR language!
]

}
},
{
Expand All @@ -143,12 +157,19 @@ To get up and running with a basic interaction model, which will allow you to as
},
{
"name": {
"value": "basal"
"value": "basal",
"synonyms": [
"Basalrate" //synonyms in your language
]
}
},
{
"name": {
"value": "cob"
"value": "cob",
"synonyms": [
"Kohlenhydraten",
"Kohlenhydrate" //synonyms in your language
]
}
},
{
Expand Down Expand Up @@ -236,6 +257,12 @@ After you enable testing, you can also use the Alexa Simulator in the left colum

*Metrics:*

Note: You can add synonyms to the available metric terms:

- Go to Slot Types -> LIST_OF_METRICS and add your terms in the "synonyms" column.

Examples:

- "Alexa, ask Nightscout what my bg is"
- "Alexa, ask Nightscout what my blood glucose is"
- "Alexa, ask Nightscout what my number is"
Expand Down
37 changes: 28 additions & 9 deletions lib/plugins/alexa.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ function init(env, ctx) {
// There is no protection for a previously configured handler - one plugin can overwrite the handler of another
// plugin.
alexa.configureIntentHandler = function configureIntentHandler(intent, handler, routableSlot, slotValues) {
if (! intentHandlers[intent]) {
if (!intentHandlers[intent]) {
intentHandlers[intent] = {};
}
if (routableSlot && slotValues) {
for (var i = 0, len = slotValues.length; i < len; i++) {
if (! intentHandlers[intent][routableSlot]) {
if (!intentHandlers[intent][routableSlot]) {
intentHandlers[intent][routableSlot] = {};
}
if (!intentHandlers[intent][routableSlot][slotValues[i]]) {
Expand All @@ -32,18 +32,37 @@ function init(env, ctx) {
intentHandlers[intent].handler = handler;
}
};
var retrieveMetricSynonym = function (slot) {
//try to get synonym metric names, as those could be translatable:
if (slot['resolutions']) {
var synonyms = slot['resolutions']['resolutionsPerAuthority'];
if (synonyms && synonyms.length > 0 && synonyms[0] //element exists
&& synonyms[0].status && synonyms[0].status.code === 'ER_SUCCESS_MATCH') //valid matching
{
var syn = synonyms[0].values[0];
if (syn && syn.value && syn.value.name)
return syn.value.name;
}
}
return undefined;
};

// This function retrieves a handler based on the intent name and slots requested.
alexa.getIntentHandler = function getIntentHandler(intentName, slots) {
if (intentName && intentHandlers[intentName]) {
if (slots) {
var slotKeys = Object.keys(slots);
for (var i = 0, len = slotKeys.length; i < len; i++) {
if (intentHandlers[intentName][slotKeys[i]] && slots[slotKeys[i]].value &&
intentHandlers[intentName][slotKeys[i]][slots[slotKeys[i]].value] &&
intentHandlers[intentName][slotKeys[i]][slots[slotKeys[i]].value].handler) {
var key = slotKeys[i];
var slot = slots[key];
var syn = retrieveMetricSynonym(slot);
var metricName = syn ? syn : slot.value;

if (intentHandlers[intentName][key] && metricName &&
intentHandlers[intentName][key][metricName] &&
intentHandlers[intentName][key][metricName].handler) {

return intentHandlers[intentName][slotKeys[i]][slots[slotKeys[i]].value].handler;
return intentHandlers[intentName][key][metricName].handler;
}
}
}
Expand All @@ -57,7 +76,7 @@ function init(env, ctx) {

};

alexa.addToRollup = function(rollupGroup, handler, rollupName) {
alexa.addToRollup = function (rollupGroup, handler, rollupName) {
if (!rollup[rollupGroup]) {
console.log('Creating the rollup group: ', rollupGroup);
rollup[rollupGroup] = [];
Expand All @@ -66,15 +85,15 @@ function init(env, ctx) {
// status = _.orderBy(status, ['priority'], ['asc'])
};

alexa.getRollup = function(rollupGroup, sbx, slots, locale, callback) {
alexa.getRollup = function (rollupGroup, sbx, slots, locale, callback) {
var handlers = _.map(rollup[rollupGroup], 'handler');
console.log('Rollup array for ', rollupGroup);
console.log(rollup[rollupGroup]);
var nHandlers = [];
_.each(handlers, function (handler) {
nHandlers.push(handler.bind(null, slots, sbx));
});
async.parallelLimit(nHandlers, 10, function(err, results) {
async.parallelLimit(nHandlers, 10, function (err, results) {
if (err) {
console.error('Error: ', err);
}
Expand Down
Loading