Socket
Socket
Sign inDemoInstall

homebridge-mertik-fireplace

Package Overview
Dependencies
0
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.2.8 to 1.3.0

6

dist/controllers/fireplaceController.d.ts

@@ -16,2 +16,3 @@ /// <reference types="node" />

on(event: 'status', listener: (status: FireplaceStatus) => void): this;
on(event: 'reachable', listener: (reachable: boolean) => void): this;
}

@@ -29,2 +30,3 @@ export declare class FireplaceController extends EventEmitter implements IFireplaceController, IFireplaceEvents {

private shuttingDown;
private lostConnection;
private static UNREACHABLE_TIMEOUT;

@@ -38,2 +40,3 @@ private static REFRESH_TIMEOUT;

private igniteFireplace;
private standBy;
private guardFlameOff;

@@ -49,5 +52,6 @@ private setEcoMode;

resetFlameHeight(): void;
setFlameHeight(height: FlameHeight): Promise<void>;
setFlameHeight(temperature: number): Promise<void>;
getFlameHeight(): FlameHeight;
setTemperature(temperature: number): Promise<void>;
private setTemperatureValue;
setMode(request: IRequest): Promise<boolean>;

@@ -54,0 +58,0 @@ setAux(on: boolean): void;

66

dist/controllers/fireplaceController.js

@@ -23,2 +23,3 @@ "use strict";

this.shuttingDown = false;
this.lostConnection = false;
this.delay = ms => new Promise(res => setTimeout(res, ms));

@@ -42,2 +43,11 @@ this.config = this.accessory.context.device;

refreshStatus() {
const isReachable = this.reachable();
this.emit('reachable', isReachable);
if (this.lastStatus) {
// Security mechanisnm to turn off fireplace when we had contcat before.
this.lostConnection = !isReachable;
if (this.lostConnection) {
this.log.error('Lost contact!');
}
}
try {

@@ -57,2 +67,6 @@ this.sendCommand('303303');

this.emit('status', this.lastStatus);
if (this.lostConnection) {
// Make sure to turn it off, as we are not sure which state we are in.
this.guardFlameOff();
}
}

@@ -69,2 +83,7 @@ async igniteFireplace() {

}
async standBy() {
await this.setTemperatureValue(0);
const msg = '3136303003';
return this.sendCommand(msg);
}
async guardFlameOff() {

@@ -120,5 +139,2 @@ if (this.shuttingDown) {

reachable() {
if (!this.lastContact) {
return false;
}
const now = new Date().getTime();

@@ -135,3 +151,6 @@ const last = this.lastContact.getTime();

}
async setFlameHeight(height) {
async setFlameHeight(temperature) {
const percentage = ((temperature) - 5) / 31;
this.log.debug(`Set flame height to percentage: ${percentage}`);
const height = flameHeight_1.FlameHeightUtils.ofPercentage(percentage);
this.log.info(`Set flame height to ${height.toString()}`);

@@ -156,2 +175,5 @@ this.height = height;

await this.delay(1000);
await this.setTemperatureValue(temperature);
}
async setTemperatureValue(temperature) {
const value = temperatureRange_1.TemperatureRangeUtils.toBits(temperature);

@@ -163,3 +185,3 @@ const msg = '42324644303' + value + '03';

async setMode(request) {
var _a, _b, _c, _d, _e;
var _a, _b, _c, _d;
const mode = request.mode;

@@ -181,13 +203,14 @@ const currentMode = ((_a = this.lastStatus) === null || _a === void 0 ? void 0 : _a.mode) || operationMode_1.OperationMode.Off;

this.log.info(`Set mode to: ${operationMode_1.OperationMode[mode]}`);
const targetTemperature = (_d = (_c = this.lastStatus) === null || _c === void 0 ? void 0 : _c.targetTemperature) !== null && _d !== void 0 ? _d : 20;
switch (mode) {
case operationMode_1.OperationMode.Manual:
this.setManualMode();
this.setFlameHeight(flameHeight_1.FlameHeight.Step11);
this.setFlameHeight(targetTemperature);
break;
case operationMode_1.OperationMode.Eco:
this.setFlameHeight(flameHeight_1.FlameHeight.Step11);
this.setFlameHeight(targetTemperature);
this.setEcoMode();
break;
case operationMode_1.OperationMode.Temperature:
this.setTemperature((_e = (_c = request.temperature) !== null && _c !== void 0 ? _c : (_d = this.lastStatus) === null || _d === void 0 ? void 0 : _d.targetTemperature) !== null && _e !== void 0 ? _e : 20);
this.setTemperature(targetTemperature);
break;

@@ -214,17 +237,20 @@ case operationMode_1.OperationMode.Off:

else if (request.temperature !== undefined
&& request.mode === operationMode_1.OperationMode.Temperature) {
await this.setTemperature(request.temperature);
&& (request.mode === operationMode_1.OperationMode.Temperature || ((_b = this.lastStatus) === null || _b === void 0 ? void 0 : _b.mode) === operationMode_1.OperationMode.Temperature)) {
if (request.temperature <= 0.0) {
await this.standBy();
}
else {
await this.setTemperature(request.temperature);
}
}
else if (request.height !== undefined
&& (request.mode === operationMode_1.OperationMode.Manual || request.mode === operationMode_1.OperationMode.Eco)) {
await this.setFlameHeight(request.height);
}
else if (request.temperature !== undefined
&& ((_b = this.lastStatus) === null || _b === void 0 ? void 0 : _b.mode) === operationMode_1.OperationMode.Temperature) {
await this.setTemperature(request.temperature);
&& (request.mode === operationMode_1.OperationMode.Manual || request.mode === operationMode_1.OperationMode.Eco
|| ((_c = this.lastStatus) === null || _c === void 0 ? void 0 : _c.mode) === operationMode_1.OperationMode.Manual || ((_d = this.lastStatus) === null || _d === void 0 ? void 0 : _d.mode) === operationMode_1.OperationMode.Eco)) {
if (request.temperature <= 0.0) {
await this.standBy();
}
else {
await this.setFlameHeight(request.temperature);
}
}
else if (request.height !== undefined
&& (((_c = this.lastStatus) === null || _c === void 0 ? void 0 : _c.mode) === operationMode_1.OperationMode.Manual || ((_d = this.lastStatus) === null || _d === void 0 ? void 0 : _d.mode) === operationMode_1.OperationMode.Eco)) {
await this.setFlameHeight(request.height);
}
await this.delay(5000);

@@ -231,0 +257,0 @@ if (request.auxOn !== undefined) {

import { Logger } from 'homebridge';
import { FlameHeight } from '../models/flameHeight';
import { OperationMode } from '../models/operationMode';

@@ -10,3 +9,2 @@ import { IRequest } from '../models/request';

lock(): void;
setFlameHeight(height: FlameHeight): void;
setAux(on: boolean): void;

@@ -32,3 +30,2 @@ setMode(mode: OperationMode): void;

unlock(): void;
setFlameHeight(height: FlameHeight): void;
setAux(on: boolean): void;

@@ -35,0 +32,0 @@ setMode(mode: OperationMode): void;

@@ -37,5 +37,2 @@ "use strict";

}
setFlameHeight(height) {
this.scheduleRequest({ height });
}
setAux(on) {

@@ -60,3 +57,3 @@ this.scheduleRequest({ auxOn: on });

this.scheduledRequest = mergedRequest;
this.sendTask = setTimeout(() => this.sendRequest(mergedRequest), 5000);
this.sendTask = setTimeout(() => this.sendRequest(mergedRequest), 10000);
}

@@ -69,3 +66,3 @@ async sendRequest(request, retry = false) {

if (!retry) {
setTimeout(() => this.sendRequest(request, true), 5000);
setTimeout(() => this.sendRequest(request, true), 10000);
return;

@@ -72,0 +69,0 @@ }

import { Characteristic, Logger, PlatformAccessory } from 'homebridge';
import { MertikPlatform } from '../platform';
export interface IServiceController {
reachableCharacteristic(): Characteristic;
activeCharacteristic(): Characteristic;

@@ -18,4 +19,6 @@ currentHeaterCoolerStateCharacteristic(): Characteristic;

private readonly service;
private readonly reachableService;
constructor(log: Logger, accessory: PlatformAccessory, platform: MertikPlatform);
initCharacteristics(): void;
reachableCharacteristic: () => Characteristic;
activeCharacteristic: () => Characteristic;

@@ -22,0 +25,0 @@ currentHeaterCoolerStateCharacteristic: () => Characteristic;

@@ -9,2 +9,3 @@ "use strict";

this.platform = platform;
this.reachableCharacteristic = () => this.reachableService.getCharacteristic(this.platform.Characteristic.ContactSensorState);
this.activeCharacteristic = () => this.service.getCharacteristic(this.platform.Characteristic.Active);

@@ -20,2 +21,4 @@ this.currentHeaterCoolerStateCharacteristic = () => this.service.getCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState);

|| this.accessory.addService(this.platform.Service.HeaterCooler);
this.reachableService = this.accessory.getService(this.platform.Service.ContactSensor)
|| this.accessory.addService(this.platform.Service.ContactSensor);
this.initCharacteristics();

@@ -35,5 +38,6 @@ }

.setCharacteristic(this.platform.Characteristic.Name, (_a = this.config.name) !== null && _a !== void 0 ? _a : 'Fireplace');
this.reachableService.setCharacteristic(this.platform.Characteristic.Name, 'Connected');
this.heatingThresholdTemperatureCharacteristic()
.setProps({
minValue: 5.0,
minValue: 0.0,
maxValue: 36,

@@ -40,0 +44,0 @@ minStep: 0.5,

@@ -18,2 +18,3 @@ import { PlatformAccessory } from 'homebridge';

private getStatus;
private updateReachable;
private updateActive;

@@ -25,2 +26,3 @@ private updateCurrentHeatingCoolerState;

private updateHeatingThresholdTemperature;
private reachableValue;
private activeValue;

@@ -27,0 +29,0 @@ private swingModeValue;

@@ -40,2 +40,5 @@ "use strict";

});
this.fireplace.on('reachable', (reachable) => {
this.updateReachable(reachable);
});
}

@@ -71,7 +74,6 @@ subscribeService() {

.onSet((value) => {
const percentage = (value - 5) / 31;
this.platform.log.debug(`Set flame height to percentage: ${percentage}`);
this.request.setFlameHeight(flameHeight_1.FlameHeightUtils.ofPercentage(percentage));
this.request.setTemperature(value);
});
this.service.reachableCharacteristic()
.onGet(() => this.reachableValue(this.fireplace.reachable()));
}

@@ -90,2 +92,5 @@ getStatus() {

// Update handlers
updateReachable(reachable) {
this.service.reachableCharacteristic().updateValue(this.reachableValue(reachable));
}
updateActive(status) {

@@ -101,3 +106,3 @@ this.service.activeCharacteristic().updateValue(this.activeValue(status));

updateCurrentTemperature(status) {
this.service.currentTemperatureCharacteristic().updateValue(status.currentTemperature);
this.service.currentTemperatureCharacteristic().updateValue(status.currentTemperature > 100 ? 20 : status.currentTemperature);
}

@@ -111,2 +116,6 @@ updateSwingMode(status) {

// CharacteristicValues
reachableValue(reachable) {
return reachable ? this.platform.Characteristic.ContactSensorState.CONTACT_DETECTED
: this.platform.Characteristic.ContactSensorState.CONTACT_NOT_DETECTED;
}
activeValue(status) {

@@ -113,0 +122,0 @@ const currentRequest = this.request.currentRequest();

{
"displayName": "Mertik Fireplace",
"name": "homebridge-mertik-fireplace",
"version": "1.2.8",
"version": "1.3.0",
"description": "Controls Mertik Fireplace Wifi controllers, connecting real fire with Homebridge.",

@@ -6,0 +6,0 @@ "license": "Apache-2.0",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc