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