Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixing creation and updates of objects in latest versions of iobroker #293

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fixing creation and updates of objects in latest versions of iobroker
lfischer85 authored Jan 12, 2025
commit 45061d1621ebaf69f29997edb952f886d1d72af0
23 changes: 14 additions & 9 deletions myAdapter.js
Original file line number Diff line number Diff line change
@@ -60,12 +60,15 @@

static initAdapter() {
states = {};
this.D(`Adapter ${this.ains} starting.`);
this.getObjectList = this.c2p(adapter.getObjectList);
this.getForeignState = this.c2p(adapter.getForeignState);
this.setForeignState = this.c2p(adapter.setForeignState);
this.getState = this.c2p(adapter.getState);
this.setState = this.c2p(adapter.setState);
this.getObjectList = adapter.getObjectListAsync ?
adapter.getObjectListAsync.bind(adapter) :
this.c2p(adapter.objects.getObjectList).bind(adapter.objects);
this.getForeignState = adapter.getForeignStateAsync.bind(adapter);
this.setForeignState = adapter.setForeignStateAsync.bind(adapter);
this.getState = adapter.getStateAsync.bind(adapter);
this.setState = adapter.setStateAsync.bind(adapter);
this.getStates = adapter.getStatesAsync.bind(adapter);


return (
!adapter.config.forceinit
@@ -145,11 +148,13 @@
this.c1pe(adapter.delState)(id, opt).catch((res) =>
res === 'Not exists' ? this.resolve() : this.reject(res),
);
this.removeState = (id, opt) =>
this.delState(id, opt).then(() => this.delObject((delete this.states[id], id), opt));
this.removeState = async (id, opt) => {

Check failure on line 151 in myAdapter.js

GitHub Actions / check-and-lint

Expected indentation of 8 spaces but found 9
await adapter.delStateAsync(id, opt).catch(this.nop);

Check failure on line 152 in myAdapter.js

GitHub Actions / check-and-lint

Expected indentation of 12 spaces but found 16
await adapter.delObjectAsync((delete states[id], id), opt).catch(this.nop);

Check failure on line 153 in myAdapter.js

GitHub Actions / check-and-lint

Expected indentation of 12 spaces but found 16
};

Check failure on line 154 in myAdapter.js

GitHub Actions / check-and-lint

Expected indentation of 8 spaces but found 12

Check failure on line 154 in myAdapter.js

GitHub Actions / check-and-lint

Trailing spaces not allowed
this.setObject = this.c2p(adapter.setObject);
this.createState = this.c2p(adapter.createState);
this.extendObject = this.c2p(adapter.extendObject);
this.extendObject = adapter.extendObjectAsync.bind(adapter);

adapter
.on('message', (obj) => (obj ? this.processMessage(this.D(`received Message ${this.O(obj)}`, obj)) : true))