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)