Skip to content

Commit

Permalink
Removed trigger state (subscribe is deprecated in js-controller 6.x) …
Browse files Browse the repository at this point in the history
…- see #662
  • Loading branch information
klein0r committed May 3, 2024
1 parent 1a2182f commit ce1594f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 64 deletions.
4 changes: 3 additions & 1 deletion README.md
Expand Up @@ -23,7 +23,6 @@ Sentry reporting, starting with js-controller 3.0, means that this adapter can u

<!--
## Todo
* `data.trigger` doesn't support `check` option
* fix timezone stuff in tests
-->

Expand All @@ -32,6 +31,9 @@ Sentry reporting, starting with js-controller 3.0, means that this adapter can u
Placeholder for the next version (at the beginning of the line):
### **WORK IN PROGRESS**
-->
### **WORK IN PROGRESS**
* (klein0r) Breaking change: Removed trigger state (subscribe is deprecated in js-controller 6.x)

### 1.15.0 (2024-04-30)
* (mcm1957) Adapter requires node.js >= 18 and js-controller >= 5 now
* (mcm1957) Dependencies have been updated
Expand Down
26 changes: 0 additions & 26 deletions io-package.json
Expand Up @@ -152,7 +152,6 @@
"config": "json"
},
"allowInit": true,
"subscribe": "ical.<INSTANCE>.trigger",
"extIcon": "https://raw.githubusercontent.com/iobroker-community-adapters/ioBroker.ical/master/admin/ical.png",
"type": "date-and-time",
"connectionType": "local",
Expand Down Expand Up @@ -337,31 +336,6 @@
},
"native": {}
},
{
"_id": "trigger",
"type": "state",
"common": {
"name": {
"en": "Command",
"de": "Befehl",
"ru": "Команда",
"pt": "Comando",
"nl": "Commando",
"fr": "Commandant",
"it": "Comando",
"es": "Comando",
"pl": "Dowództwo",
"uk": "Про компанію",
"zh-cn": "指挥"
},
"desc": "Commands: read [url], check [reason]",
"type": "string",
"read": true,
"write": true,
"role": "value"
},
"native": {}
},
{
"_id": "data.count",
"type": "state",
Expand Down
39 changes: 2 additions & 37 deletions main.js
Expand Up @@ -22,43 +22,6 @@ function startAdapter(options) {

Object.assign(options,{
name: adapterName,
stateChange: async function (id, state) {
if (!id || !state || state.ack || !state.val) {
return;
}

if (id === `${adapter.namespace}.trigger`) {
const content = state.val.split(' ');
// One time read all calendars
switch (content[0]) {
case 'read':
if (content[1]) {
adapter.log.info(`reading iCal from URL: "${content[1]}"`);
readOne(content[1]);
} else {
adapter.log.info('reading one time from all calendars');
readAll();
}
break;

// FIXME: checkForEvents not supporting call with only 1 parameter
case 'check':
if (content[1]) {
adapter.log.info(`checking "${content[1]}"`);
await checkForEvents(content[1]);
} else {
adapter.log.warn('check all events');
for (let i = 0; i < adapter.config.events.length; i++) {
await checkForEvents(adapter.config.events[i].name);
}
}
break;

default:
adapter.log.warn(`Unknown command in trigger: "${state.val}"`);
}
}
},
unload: function (callback) {
stopped = true;
callback();
Expand Down Expand Up @@ -1600,6 +1563,8 @@ function main() {
}
});

adapter.delObjectAsync('trigger'); // removed deprecated subscribe state (created in previous versions)

syncUserEvents(readAll);
}

Expand Down

0 comments on commit ce1594f

Please sign in to comment.