45 lines
1.8 KiB
JavaScript
45 lines
1.8 KiB
JavaScript
const post = require('../lib/post')
|
|
const common = require('../lib/common')
|
|
let logger = require('perfect-logger')
|
|
|
|
module.exports = function (app) {
|
|
app.get("/heating", async function (req, res, next) {
|
|
logger.debug('GET - /heating - START')
|
|
const response = await post.postRequest('{}', 'poll')
|
|
const heating = response.updateData.zones[0]
|
|
logger.debug('GET - /heating - END')
|
|
res.json(heating)
|
|
});
|
|
|
|
app.get("/heating/status", async function (req, res, next) {
|
|
logger.debug('GET - /heating/status - START')
|
|
const response = await post.postRequest('{}', 'poll')
|
|
// logger.debug(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)
|
|
const time = await common.convertTime(heating.nextScheduleEventUtcTime)
|
|
|
|
let heatingStatus = {
|
|
"heatingOn": JSON.stringify(on),
|
|
"measuredRoomTemp": mrt,
|
|
"currentSetpoint": csp,
|
|
"lastTimerSetPoint": lsp,
|
|
"lastTimerDurationMinutes": JSON.stringify(heating.lastTimerDurationMinutes),
|
|
"nextScheduleEventUtcTime": time
|
|
}
|
|
logger.debug('GET - /heating/status - END')
|
|
res.json(heatingStatus)
|
|
});
|
|
|
|
app.get("/heating/config", async function (req, res, next) {
|
|
logger.debug('GET - /heating/config - START')
|
|
const response = await post.postRequest('{}', 'poll')
|
|
const heating = response.updateData.zones[0].config
|
|
logger.debug('GET - /heating/config - END')
|
|
res.json(heating)
|
|
});
|
|
|
|
} |