Drayton_MiGenie_HASS/routes/heating_get.js
2020-05-09 21:44:21 +01:00

36 lines
1.3 KiB
JavaScript

const post = require('../lib/post')
const common = require('../lib/common')
module.exports = function (app) {
app.get("/heating", async function (req, res, next) {
const response = await post.postRequest('{}', 'poll')
const heating = response.updateData.zones[0]
res.json(heating)
});
app.get("/heating/status", async function (req, res, next) {
const response = await post.postRequest('{}', 'poll')
// console.log(response.updateData)
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": csp,
"lastTimerSetPoint": lsp,
"lastTimerDurationMinutes": JSON.stringify(heating.lastTimerDurationMinutes)
}
res.json(heatingStatus)
});
app.get("/heating/config", async function (req, res, next) {
const response = await post.postRequest('{}', 'poll')
const heating = response.updateData.zones[0].config
res.json(heating)
});
}