Skip to content

Commit

Permalink
- Fixed app devices not beeing identified correctly.
Browse files Browse the repository at this point in the history
- Fixed compatibility with 'old' plan devices that don't support on/off capability.
- Fixed incompatibility in Athom API not providing correct values through websocket#
- Fixed incompatibility with console.re websocket.io-client
  • Loading branch information
Markus Kling committed May 14, 2023
1 parent ba7d72e commit cdee03d
Show file tree
Hide file tree
Showing 9 changed files with 16,320 additions and 11,094 deletions.
9 changes: 9 additions & 0 deletions docs/releasenotes/v02-00-07.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
layout: page
title: Release Notes v2.0.7
---

- Fixed app devices not beeing identified correctly.
- Fixed compatibility with 'old' plan devices that don't support on/off capability.
- Fixed incompatibility in Athom API not providing correct values through websocket#
- Fixed incompatibility with console.re websocket.io-client
27,353 changes: 16,273 additions & 11,080 deletions package-lock.json

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,20 @@
"date-fns": "^2.0.0-alpha.21",
"encoding": "^0.1.13",
"graceful-fs": "^4.2.3",
"homey-api": "^3.0.0-rc.19",
"homey-api": "^3.0.2",
"install": "^0.13.0",
"lodash": "^4.17.11",
"material-ui-pickers": "^2.2.4",
"natives": "^1.1.6",
"notistack": "^1.0.10",
"npm": "^9.6.6",
"react": "^16.14.0",
"react-dom": "^16.14.0",
"react-material-ui": "0.0.1",
"react-router-dom": "^5.0.0",
"react-scroll-locky": "^1.5.0",
"reflect-metadata": "^0.1.13",
"socket.io-client-v3": "npm:socket.io-client@^3.0.0",
"strongly-typed-events": "^1.4.10",
"tslint-react": "^4.0.0",
"tsyringe": "^4.0.1",
Expand All @@ -46,7 +49,7 @@
"@types/react-dom": "^16.8.4",
"@types/react-router": "^5.1.3",
"@types/react-router-dom": "^5.1.3",
"@types/socket.io-client": "^1.4.32",
"@types/socket.io-client": "^1.4.36",
"@vitalets/google-translate-api": "^3.0.0",
"awesome-typescript-loader": "^5.2.1",
"babel-loader": "^8.0.5",
Expand Down
6 changes: 6 additions & 0 deletions src/app/services/bootstrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import { Mutex } from "@app/helper";
import { App as HomeyApp } from "homey";
import process = require("process");
import { container } from "tsyringe";
import { DeviceManagerService } from "../services/device-manager";
import { HeatingPlanRepositoryService } from "./heating-plan-repository";
Expand All @@ -28,6 +29,11 @@ export async function BootStrapper(app: HomeyApp, silent = false) {
// global hack
process.env.TZ = app.homey.clock.getTimezone();

// // enables some websocket debug messages
// if (!__PRODUCTION__) {
// process.env.DEBUG = "*";
// }

// depends on logger -> settings -> ...
const settingsManager: SettingsManagerService = container.resolve(SettingsManagerService);
await settingsManager.init(app.homey.settings);
Expand Down
2 changes: 1 addition & 1 deletion src/app/services/device-manager/DeviceManagerService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export type AuditedDevice = {
} & IDevice;

export function VirtualDevice(device: IDevice): boolean {
return device.driverUri != null && device.driverUri.match(/app\.mskg\.homey\-heating/ig) != null;
return device.driverId != null && device.driverId.match(/app\.mskg\.homey\-heating/ig) != null;
}

export function CanSetTargetTemperature(device: IDevice): boolean {
Expand Down
13 changes: 9 additions & 4 deletions src/app/services/log/ConsoleReLogger.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
import { PromiseBuffer } from "@sentry/utils";
import { connect } from "socket.io-client";
// needs socket.io-client v3
import { io } from "socket.io-client-v3";
import { LogService } from "./LogService";
import { ILogger, INeedsCleanup } from "./types";

export class ConsoleReLogger implements ILogger, INeedsCleanup {
private cleanup = false;
private socket: SocketIOClient.Socket;
private socket;
private buffer = new PromiseBuffer<void>(30);

constructor(private channel: string) {
this.socket = connect("https://console.re:443", {
this.socket = io("https://console.re", {
transports: ["websocket"],
// @ts-ignore
extraHeaders: {
'x-consolere': 'true'
}
});

this.socket.on("connect", () => {
Expand Down Expand Up @@ -94,7 +99,7 @@ export class ConsoleReLogger implements ILogger, INeedsCleanup {

resolve();
}),
// @ts-ignore
// @ts-ignore
).catch((e) => {
LogService.transportLog.error(e, "ConsoleRe could not send log: ", ...args, e);
});
Expand Down
5 changes: 4 additions & 1 deletion src/app/services/settings-manager/SettingsManagerService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ export class SettingsManagerService {
value: any,
}>();

private devSettings: { [key: string]: any } = {};
private devSettings: { [key: string]: any } = {
logenabled: true,
consolere: "mskgtest",
};

constructor(private factory: LoggerFactory) {
}
Expand Down
15 changes: 11 additions & 4 deletions src/drivers/virtual-thermostat/device.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ class VirtualThermostat extends Device implements IVirtualThermostat {
private capabilitiesChanged!: IEventHandler<DeviceManagerService, CapabilityChangedEventArgs>;
private plansApplied!: IEventHandler<HeatingManagerService, PlansAppliedEventArgs>;

private hasOnOff = false;

@trycatchlog(true)
public async onInit() {
await BootStrapper(this.homey.app);
Expand All @@ -59,7 +61,8 @@ class VirtualThermostat extends Device implements IVirtualThermostat {
this.tryRegisterCapability(CapabilityType.ThermostatOverride,
AsyncDebounce(this.onThermostatModeChanged.bind(this), settings.get<number>(InternalSettings.DriverDebounce, 5 * 1000)));

this.tryRegisterCapability(CapabilityType.OnOff,
// has been added afterwards, need to be aware of not existing
this.hasOnOff = await this.tryRegisterCapability(CapabilityType.OnOff,
AsyncDebounce(this.onOnOff.bind(this), settings.get<number>(InternalSettings.DriverDebounce, 5 * 1000)));

this.repositoryChanged = this.plansChanged.bind(this);
Expand All @@ -73,6 +76,7 @@ class VirtualThermostat extends Device implements IVirtualThermostat {

// Update values
this.plan = await this.repository.find(this.id);

await this.updateCapabilitiesFromPlan();
await this.updateTemperature();
await this.updateOnOffStatus();
Expand Down Expand Up @@ -171,16 +175,19 @@ class VirtualThermostat extends Device implements IVirtualThermostat {
* @param capability The one
* @param callback The for the capability
*/
@trycatchlog(true)
private async tryRegisterCapability(capability: CapabilityType, callback: (val: any, opts: CallableFunction) => Promise<void>) {
@trycatchlog(true, false)
private async tryRegisterCapability(capability: CapabilityType, callback: (val: any, opts: CallableFunction) => Promise<void>): Promise<boolean> {
if (!find(this.getCapabilities(), (c) => c === capability)) {
this.logger.information(`does not have ${capability} - cannot register listener`);
return false;
} else {
this.logger.information(`attached listener for ${capability}`);

// this.capabilityListeners[capability] = callback;
await this.registerCapabilityListener(capability, callback);
}

return true;
}

/**
Expand Down Expand Up @@ -362,7 +369,7 @@ class VirtualThermostat extends Device implements IVirtualThermostat {
* Update this device's state
*/
private async updateOnOffStatus() {
if (this.plan == null) { return; }
if (this.plan == null || !this.hasOnOff) { return; }

this.logger.debug(`Updating ${CapabilityType.OnOff} ${this.plan.enabled}`);
await this.doSetCapabilityValue(CapabilityType.OnOff, this.plan.enabled);
Expand Down
4 changes: 2 additions & 2 deletions webpack.app.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ var appConfig = (env, argv) => {
"[email protected]": { licenseName: "MIT" },
"[email protected]": { licenseName: "MIT" },
// this is proprietary but OK here
"[email protected].0-rc.19": { licenseName: "ISC" },
"[email protected].2": { licenseName: "ISC" },
"@types/[email protected]": { licenseName: "ISC" },
}
}));
Expand Down Expand Up @@ -195,7 +195,7 @@ var appConfig = (env, argv) => {
externals: {
"bufferutil": "bufferutil",
"utf-8-validate": "utf-8-validate",
"ws": "ws",
// "ws": "ws",
"homey": "homey",
// "homey-api": "homey-api",
"reflect-metadata": "reflect-metadata",
Expand Down

0 comments on commit cdee03d

Please sign in to comment.