From ddf2aad2db71ffc9eb60d0ceb0b38e173be07b26 Mon Sep 17 00:00:00 2001 From: Karl Date: Fri, 8 May 2020 18:47:53 +0100 Subject: [PATCH] convert migenie temps --- lib/common.js | 22 ++++++++++++++++++++++ routes/heating.js | 6 ++++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/lib/common.js b/lib/common.js index f91b052..70cac8d 100644 --- a/lib/common.js +++ b/lib/common.js @@ -24,5 +24,27 @@ module.exports = { console.log('Error') } + }, + heatMap: async (value) => { + value + + let heatMap = [ + { + "miGenie": 84, + "realTemp": 22 + }, + { + "miGenie": 88, + "realTemp": 23 + } + ] + + for (let index = 0; index < heatMap.length; index++) { + const element = heatMap[index]; + if (value === element.miGenie){ + value = element.realTemp + return value + } + } } } \ No newline at end of file diff --git a/routes/heating.js b/routes/heating.js index e940acb..2bb8ef5 100644 --- a/routes/heating.js +++ b/routes/heating.js @@ -13,12 +13,14 @@ module.exports = function (app) { const heating = response.updateData.zones[0].status const mrt = await common.updateTemp(heating) const on = await common.heatingOn(heating) + const csp = await common.heatMap(heating.currentSetpoint) + const lsp = await common.heatMap(heating.lastTimerSetPoint) let heatingStatus = { "heatingOn": JSON.stringify(on), "measuredRoomTemp": mrt, - "currentSetpoint": JSON.stringify(heating.currentSetpoint), - "lastTimerSetPoint": JSON.stringify(heating.lastTimerSetPoint), + "currentSetpoint": csp, + "lastTimerSetPoint": lsp, "lastTimerDurationMinutes": JSON.stringify(heating.lastTimerDurationMinutes) } res.json(heatingStatus)