diff --git a/lib/common.js b/lib/common.js index c63678f..f91b052 100644 --- a/lib/common.js +++ b/lib/common.js @@ -3,8 +3,8 @@ module.exports = { updateTemp: async (heating) => { try { let mrt = String(heating.measuredRoomTemp) - mrt = mrt.split(/(?=(?:..)*$)/) - mrt = parseFloat(mrt[1] + "." + mrt[0]) + mrt = mrt.match(new RegExp('.{1,' + 2 + '}', 'g')); + mrt = mrt[0] + "." + mrt[1] return mrt } catch (error) { console.log('Error') diff --git a/package-lock.json b/package-lock.json index 8a86b90..1e8bc17 100644 --- a/package-lock.json +++ b/package-lock.json @@ -419,6 +419,11 @@ "resolved": "https://registry.npmjs.org/normalize-url/-/normalize-url-4.5.0.tgz", "integrity": "sha512-2s47yzUxdexf1OhyRi4Em83iQk0aPvwTddtFz4hnSSw9dCEsLEGf6SwIO8ss/19S9iBb5sJaOuTvTGDeZI00BQ==" }, + "numeral": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/numeral/-/numeral-2.0.6.tgz", + "integrity": "sha1-StCAk21EPCVhrtnyGX7//iX05QY=" + }, "on-finished": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", diff --git a/package.json b/package.json index d0117eb..c0eb5d6 100644 --- a/package.json +++ b/package.json @@ -17,5 +17,5 @@ "express": "^4.17.1", "fs": "0.0.1-security", "got": "^11.1.1" - } + } } diff --git a/routes/heating.js b/routes/heating.js index c6c920b..e940acb 100644 --- a/routes/heating.js +++ b/routes/heating.js @@ -15,13 +15,12 @@ module.exports = function (app) { const on = await common.heatingOn(heating) let heatingStatus = { - "heatingOn": on, + "heatingOn": JSON.stringify(on), "measuredRoomTemp": mrt, - "currentSetpoint": heating.currentSetpoint, - "lastTimerSetPoint": heating.lastTimerSetPoint, - "lastTimerDurationMinutes": heating.lastTimerDurationMinutes + "currentSetpoint": JSON.stringify(heating.currentSetpoint), + "lastTimerSetPoint": JSON.stringify(heating.lastTimerSetPoint), + "lastTimerDurationMinutes": JSON.stringify(heating.lastTimerDurationMinutes) } - res.json(heatingStatus) });