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) {
|
2020-05-08 21:16:25 +01:00
|
|
|
const response = await post.postRequest('{}', 'poll')
|
2020-05-07 22:05:20 +01:00
|
|
|
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) {
|
2020-05-08 21:16:25 +01:00
|
|
|
const response = await post.postRequest('{}', 'poll')
|
2020-05-09 21:44:21 +01:00
|
|
|
// console.log(response.updateData)
|
2020-05-07 22:12:45 +01:00
|
|
|
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-08 18:47:53 +01:00
|
|
|
const csp = await common.heatMap(heating.currentSetpoint)
|
|
|
|
|
const lsp = await common.heatMap(heating.lastTimerSetPoint)
|
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 18:47:53 +01:00
|
|
|
"currentSetpoint": csp,
|
|
|
|
|
"lastTimerSetPoint": lsp,
|
2020-05-08 09:43:01 +01:00
|
|
|
"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) {
|
2020-05-08 21:16:25 +01:00
|
|
|
const response = await post.postRequest('{}', 'poll')
|
2020-05-07 22:12:45 +01:00
|
|
|
const heating = response.updateData.zones[0].config
|
|
|
|
|
res.json(heating)
|
|
|
|
|
});
|
|
|
|
|
|
2020-05-07 22:05:20 +01:00
|
|
|
}
|