Skip to content

Commit

Permalink
fix: channel creation only one time on init
Browse files Browse the repository at this point in the history
  • Loading branch information
sg-app committed Aug 2, 2024
1 parent 141fb62 commit db08834
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ States are generated automatically whenn the adapter starts. If additional state
Placeholder for the next version (at the beginning of the line):
### **WORK IN PROGRESS**
-->

### **WORK IN PROGRESS**

- (SG-App) fix channel creation only one time on init

### 0.4.1 (2024-08-02)

- (SG-App) refactor for latest repo
Expand Down
26 changes: 16 additions & 10 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const utils = require("@iobroker/adapter-core");
const axios = require("axios");

let isInit;
let createdChannel;

class Fenecon extends utils.Adapter {
/**
Expand Down Expand Up @@ -52,6 +53,7 @@ class Fenecon extends utils.Adapter {
}

isInit = true;
createdChannel = [];

// http://x:user@<ipAddress>/rest/channel/
this.log.debug("Adapter successful started.");
Expand Down Expand Up @@ -144,16 +146,20 @@ class Fenecon extends utils.Adapter {
const id = address.join(".");
const allowedId = this.name2id(id);

this.log.debug(`[createUpdateState] Channel ${channelName} not exists. Extend Object.`);
await this.extendObject(channelName,
{
_id: channelName,
type: "channel",
common: {
name: channelName
},
native: {}
});

if (createdChannel.indexOf(channelName) == -1) {
this.log.debug(`[createUpdateState] Channel ${channelName} not exists. Extend Object.`);
await this.extendObject(channelName,
{
_id: channelName,
type: "channel",
common: {
name: channelName
},
native: {}
});
createdChannel.push(channelName);
}

this.log.debug(`[createUpdateState] StateId ${allowedId} not exists. Extend state.`);
await this.extendObject(allowedId,
Expand Down

0 comments on commit db08834

Please sign in to comment.