homebridge-fenix-tft-wifi
Version:
Homebridge plugin which adds a Fenix TFT WiFi thermostat as HomeKit device.
65 lines • 2.57 kB
JavaScript
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const axios_1 = __importDefault(require("axios"));
const ThermostatData_1 = __importDefault(require("../DTO/ThermostatData"));
class ThermostatApi {
constructor(uuid, tokenManager) {
this.uuid = uuid;
this.tokenManager = tokenManager;
this.ThermostatApiUrl = 'https://vs2-fe-apim-prod.azure-api.net';
this.axiosClient = axios_1.default.create({
headers: {
'Content-type': 'application/json',
},
});
}
getInformation() {
return new Promise((resolve, reject) => {
this.axiosClient.get(this.ThermostatApiUrl + '/iotmanagement/v1/configuration/' + this.uuid + '/' + this.uuid + '/v1.0/content', {
headers: { Authorization: 'Bearer ' + this.tokenManager.accessToken }
}).then((response) => resolve(new ThermostatData_1.default(response.data))).catch((reject));
});
}
async changeMode(mode) {
return await this.axiosClient.put(this.ThermostatApiUrl + '/iotmanagement/v1/devices/twin/properties/config/replace', {
'Id_deviceId': this.uuid,
'S1': this.uuid,
'configurationVersion': 'v1.0',
'data': [
{
'timestamp': null,
'wattsType': 'Dm',
'wattsTypeValue': mode,
}
],
}, {
headers: { Authorization: 'Bearer ' + this.tokenManager.accessToken },
});
}
async setTemperature(thermostat) {
return await this.axiosClient.put(this.ThermostatApiUrl + '/iotmanagement/v1/devices/twin/properties/config/replace', {
'Id_deviceId': this.uuid,
'S1': this.uuid,
'configurationVersion': 'v1.0',
'data': [
{
'timestamp': null,
'wattsType': 'Dm',
'wattsTypeValue': thermostat.mode,
},
{
'timestamp': null,
'wattsType': 'Ma',
'wattsTypeValue': thermostat.realRequiredTemperature,
},
],
}, {
headers: { Authorization: 'Bearer ' + this.tokenManager.accessToken },
});
}
}
exports.default = ThermostatApi;
//# sourceMappingURL=ThermostatApi.js.map