33 lines
1.2 KiB
JavaScript
Raw Normal View History

2020-05-07 22:05:20 +01:00
const post = require('../lib/post')
2020-05-07 22:47:43 +01:00
const common = require('../lib/common')
2020-05-07 22:05:20 +01:00
2020-05-07 22:12:45 +01:00
module.exports = function (app) {
2020-05-07 22:05:20 +01:00
app.get("/heating", async function (req, res, next) {
const response = await post.postRequest()
const heating = response.updateData.zones[0]
res.json(heating)
});
2020-05-07 22:12:45 +01:00
app.get("/heating/status", async function (req, res, next) {
const response = await post.postRequest()
const heating = response.updateData.zones[0].status
2020-05-07 22:47:43 +01:00
const mrt = await common.updateTemp(heating)
const on = await common.heatingOn(heating)
2020-05-07 22:41:48 +01:00
let heatingStatus = {
2020-05-08 09:43:01 +01:00
"heatingOn": JSON.stringify(on),
2020-05-07 22:41:48 +01:00
"measuredRoomTemp": mrt,
2020-05-08 09:43:01 +01:00
"currentSetpoint": JSON.stringify(heating.currentSetpoint),
"lastTimerSetPoint": JSON.stringify(heating.lastTimerSetPoint),
"lastTimerDurationMinutes": JSON.stringify(heating.lastTimerDurationMinutes)
2020-05-07 22:41:48 +01:00
}
res.json(heatingStatus)
2020-05-07 22:12:45 +01:00
});
app.get("/heating/config", async function (req, res, next) {
const response = await post.postRequest()
const heating = response.updateData.zones[0].config
res.json(heating)
});
2020-05-07 22:05:20 +01:00
}