2020-05-07 22:41:48 +01:00

43 lines
1.3 KiB
JavaScript

const post = require('../lib/post')
module.exports = function (app) {
app.get("/heating", async function (req, res, next) {
const response = await post.postRequest()
const heating = response.updateData.zones[0]
res.json(heating)
});
app.get("/heating/status", async function (req, res, next) {
const response = await post.postRequest()
const heating = response.updateData.zones[0].status
let mrt = String( heating.measuredRoomTemp )
mrt = mrt.split( /(?=(?:..)*$)/ )
mrt = parseFloat(mrt[1] + "." + mrt[0])
heating.measuredRoomTemp = mrt
let on
if (heating.currentSetpoint > 0) {
on = true
} else {
on = false
}
let heatingStatus = {
"heatingOn": on,
"measuredRoomTemp": mrt,
"currentSetpoint": heating.currentSetpoint,
"lastTimerSetPoint": heating.lastTimerSetPoint,
"lastTimerDurationMinutes": heating.lastTimerDurationMinutes
}
res.json(heatingStatus)
});
app.get("/heating/config", async function (req, res, next) {
const response = await post.postRequest()
const heating = response.updateData.zones[0].config
res.json(heating)
});
}