homebridge-jci-hitachi-platform
Version:
Homebridge platform plugin providing HomeKit support for Jci Hitachi air conditioners.
147 lines • 5.5 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AWSThings = exports.AWSThingDictionary = exports.AWSCredentials = exports.AWSIdentity = exports.AWSTokens = void 0;
class AWSTokens {
constructor(access_token = '', id_token = '', refresh_token = '', expiration = 0) {
this.access_token = access_token;
this.id_token = id_token;
this.refresh_token = refresh_token;
this.expiration = expiration;
}
}
exports.AWSTokens = AWSTokens;
class AWSIdentity {
constructor(identity_id, user_name, user_attributes) {
this.identity_id = identity_id;
this.host_identity_id = user_attributes['custom:host_identity_id'];
this.user_name = user_name;
this.user_attributes = user_attributes;
}
}
exports.AWSIdentity = AWSIdentity;
class AWSCredentials {
constructor(awscredentialsContent) {
this.access_key_id = '';
this.secret_access_key = '';
this.session_token = '';
this.expiration = 0;
const awscredentialsJson = JSON.parse(awscredentialsContent);
this.access_key_id = awscredentialsJson['AccessKeyId'];
this.secret_access_key = awscredentialsJson['SecretKey'];
this.session_token = awscredentialsJson['SessionToken'];
this.expiration = awscredentialsJson['Expiration'];
}
}
exports.AWSCredentials = AWSCredentials;
class AWSThingDictionary {
constructor(awsallthingsContent, log = undefined) {
var _a;
this.things = {};
this.log = log;
const awsallthingsJson = JSON.parse(awsallthingsContent);
const things = awsallthingsJson['results']['Things'];
for (let i = 0; i < things.length; i++) {
const thing = new AWSThings(JSON.stringify(things[i]));
this.things[thing.ThingName] = thing;
}
(_a = this.log) === null || _a === void 0 ? void 0 : _a.info(`You have ${Object.keys(this.things).length} devices.`);
}
getAllThings() {
return this.things;
}
hasThingName(thingName) {
return this.things[thingName] !== undefined;
}
getDevice(thingName) {
return this.things[thingName];
}
updateDeviceStatusPayload(thingName, payload) {
if (this.hasThingName(thingName) === false) {
return;
}
this.things[thingName].updateStatusPayload(payload);
}
updateDeviceRegistrationPayload(thingName, payload) {
if (this.hasThingName(thingName) === false) {
return;
}
this.things[thingName].updateRegistrationPayload(payload);
}
}
exports.AWSThingDictionary = AWSThingDictionary;
class AWSThings {
constructor(awsthingsContent) {
this.statusPayload = undefined;
this.registrationPayload = undefined;
this.thingObject = JSON.parse(awsthingsContent);
}
get ThingName() {
return this.thingObject.ThingName;
}
get CustomDeviceName() {
return this.thingObject.CustomDeviceName;
}
get DeviceType() {
return this.thingObject.DeviceType;
}
get SwitchOn() {
var _a, _b;
return (_b = (_a = this.statusPayload) === null || _a === void 0 ? void 0 : _a.Switch) !== null && _b !== void 0 ? _b : 0;
}
get TemperatureSetting() {
var _a;
return (_a = this.statusPayload) === null || _a === void 0 ? void 0 : _a.TemperatureSetting;
}
get TemperatureSettingMin() {
var _a;
return this.registrationPayload ? (((_a = this.registrationPayload.TemperatureSetting) !== null && _a !== void 0 ? _a : 0) >> 8 & 255) : 16;
}
get TemperatureSettingMax() {
var _a;
return this.registrationPayload ? (((_a = this.registrationPayload.TemperatureSetting) !== null && _a !== void 0 ? _a : 0) & 255) : 32;
}
get IndoorTemperature() {
var _a;
return (_a = this.statusPayload) === null || _a === void 0 ? void 0 : _a.IndoorTemperature;
}
get IndoorHumidity() {
var _a;
return (_a = this.statusPayload) === null || _a === void 0 ? void 0 : _a.IndoorHumidity;
}
get PM25() {
var _a;
return (_a = this.statusPayload) === null || _a === void 0 ? void 0 : _a.PM25;
}
get FanSpeed() {
var _a;
return (_a = this.statusPayload) === null || _a === void 0 ? void 0 : _a.FanSpeed;
}
get QuickMode() {
var _a, _b;
return (_b = (_a = this.statusPayload) === null || _a === void 0 ? void 0 : _a.QuickMode) !== null && _b !== void 0 ? _b : 0;
}
get CleanNotification() {
var _a, _b;
return (_b = (_a = this.statusPayload) === null || _a === void 0 ? void 0 : _a.CleanNotification) !== null && _b !== void 0 ? _b : 0;
}
get CleanSwitch() {
var _a, _b;
return (_b = (_a = this.statusPayload) === null || _a === void 0 ? void 0 : _a.CleanSwitch) !== null && _b !== void 0 ? _b : 0;
}
get FirmwareVersion() {
var _a;
return (_a = this.registrationPayload) === null || _a === void 0 ? void 0 : _a.FirmwareVersion;
}
get Model() {
var _a;
return (_a = this.registrationPayload) === null || _a === void 0 ? void 0 : _a.Model;
}
updateStatusPayload(payload) {
this.statusPayload = payload;
}
updateRegistrationPayload(payload) {
this.registrationPayload = payload;
}
}
exports.AWSThings = AWSThings;
//# sourceMappingURL=jci-hitachi-models.js.map