* fix start issue

This commit is contained in:
Ingo Fischer
2021-08-23 00:34:45 +02:00
parent d7adbddcc0
commit 5795c78ea4
5 changed files with 28 additions and 7 deletions
+3 -3
View File
@@ -3,9 +3,9 @@ os:
- osx - osx
language: node_js language: node_js
node_js: node_js:
- '4' - '12'
- '6' - '14'
- '8' - '16'
services: services:
- mysql - mysql
- postgresql - postgresql
+4
View File
@@ -23,6 +23,10 @@ Please check it https://www.smarthomejetzt.de/mit-iobroker-auf-eine-home-assista
--> -->
## Changelog ## Changelog
### __WORK IN PROGRESS__
* (Apollon77) Fix start issue
### 1.0.0 (2020-12-13) ### 1.0.0 (2020-12-13)
* (bluefox) added the support of compact mode * (bluefox) added the support of compact mode
+3 -3
View File
@@ -2,9 +2,9 @@ version: 'test-{build}'
os: Visual Studio 2013 os: Visual Studio 2013
environment: environment:
matrix: matrix:
- nodejs_version: '4' - nodejs_version: '12'
- nodejs_version: '6' - nodejs_version: '14'
- nodejs_version: '8' - nodejs_version: '16'
platform: platform:
- x86 - x86
- x64 - x64
+13 -1
View File
@@ -23,6 +23,7 @@ function HASS(options, log) {
const requests = {}; const requests = {};
let connected; let connected;
let connectTimeout = null; let connectTimeout = null;
let closed = false;
function subscribeEvents(socket, callback) { function subscribeEvents(socket, callback) {
if (socket && typeof socket.send === 'function') { if (socket && typeof socket.send === 'function') {
@@ -184,7 +185,7 @@ function HASS(options, log) {
that.emit('disconnected'); that.emit('disconnected');
} }
if (!connectTimeout) { if (!connectTimeout && !closed) {
setTimeout(() => { setTimeout(() => {
connectTimeout = null; connectTimeout = null;
that.connect(); that.connect();
@@ -248,6 +249,17 @@ function HASS(options, log) {
initSocket(this.socket); initSocket(this.socket);
}; };
this.close = function () {
if (connectTimeout) {
clearTimeout(connectTimeout);
connectTimeout = null;
}
closed = true;
if (this.socket) {
this.socket.close();
}
}
return this; return this;
} }
+5
View File
@@ -62,6 +62,11 @@ function startAdapter(options) {
return adapter; return adapter;
} }
function stop(callback) {
hass && hass.close();
callback && callback();
}
function getUnit(name) { function getUnit(name) {
name = name.toLowerCase(); name = name.toLowerCase();
if (name.indexOf('temperature') !== -1) { if (name.indexOf('temperature') !== -1) {