Skip to content

Commit

Permalink
improve previous commit
Browse files Browse the repository at this point in the history
  • Loading branch information
DutchmanNL committed Nov 5, 2023
1 parent c93ef9a commit 8989c59
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 23 deletions.
1 change: 1 addition & 0 deletions admin/words.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion io-package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"common": {
"name": "esphome",
"version": "0.4.1-beta.4",
"version": "0.4.1-beta.5",
"news": {
"0.4.0": {
"en": "Added cleanup capability for unused channels & states after initialisation of device, resolves #39\nAdded button to info channel which allows to delete all offline devices from adapter tree. resolves #39\n[Breaking] Backup strategy changed, requires [BackitUp v2.9.1](https://github.com/simatec/ioBroker.backitup) and activate option for ESPHome, fixes #129",
Expand Down
42 changes: 22 additions & 20 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,20 +223,20 @@ class Esphome extends utils.Adapter {
// const host = espDevices[device].ip;
this.log.info(`Try to connect to ${host}`);

// Cancel process if connection try is already in progress
if (this.deviceInfo[host] && this.deviceInfo[host].connecting) return;

// Clear any existing memory information for this device
delete this.deviceInfo[host];

// Cancel process if connection try is already in progress
if (this.deviceInfo[host] && this.deviceInfo[host].connecting)

// Reserve basic memory information for this device
this.deviceInfo[host] = {
connected : false,
connecting : true,
connectionError : false,
initialized: false,
ip : host
};
this.deviceInfo[host] = {
connected : false,
connecting : true,
connectionError : false,
initialized: false,
ip : host
};

if (!deviceEncryptionKey || deviceEncryptionKey === '') {
client[host] = new Client({
Expand Down Expand Up @@ -275,18 +275,20 @@ class Esphome extends utils.Adapter {
// Connection listener
client[host].on('connected', async () => {
try {
this.deviceInfo[host].connected = true;
this.deviceInfo[host].connecting = false;
// Clear any existing memory information for this device
delete this.deviceInfo[host];

// Reserve basic memory information for this device
this.deviceInfo[host] = {
connected : true,
connectionError : false,
initialized: false,
ip : host
};
if (!this.deviceInfo[host]) {
this.deviceInfo[host] = {
connected : false,
connecting : true,
connectionError : false,
initialized: false,
ip : host
};
} else {
this.deviceInfo[host].connected = true;
this.deviceInfo[host].connecting = false;
}
this.log.info(`ESPHome client ${host} connected`);
// Clear possible present warn messages for device from previous connection
delete warnMessages[host];
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "iobroker.esphome",
"version": "0.4.1-beta.4",
"version": "0.4.1-beta.5",
"description": "Control your ESP8266/ESP32 with simple yet powerful configuration files created and managed by ESPHome",
"author": {
"name": "DutchmanNL",
Expand Down

0 comments on commit 8989c59

Please sign in to comment.