Skip to content

Commit

Permalink
Added more presets for topics
Browse files Browse the repository at this point in the history
  • Loading branch information
sestriel committed Oct 5, 2023
1 parent 1430cbc commit 96cca9d
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 4 deletions.
84 changes: 80 additions & 4 deletions admin/jsonConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
"defaultTopic": {
"type": "text",
"label": "defaultTopic",
"newLine": true
"newLine": true,
"sm": 12,
"md": 6,
"lg": 3
},
"defaultTopicAuth": {
"type": "select",
Expand All @@ -42,19 +45,92 @@
"defaultUsername": {
"type": "text",
"label": "defaultUsername",
"newLine": true
"newLine": true,
"sm": 12,
"md": 6,
"lg": 3
},
"defaultPassword": {
"type": "password",
"label": "defaultPassword",
"visible": true,
"newLine": false
"newLine": false,
"sm": 12,
"md": 6,
"lg": 3
},
"defaultAccessToken": {
"type": "text",
"label": "defaultAccessToken",
"help": "helpDefaultAccessToken",
"newLine": true
"newLine": false,
"sm": 12,
"md": 6,
"lg": 3
},
"presetTopicsDivider": {
"type": "divider"
},
"presetTopics": {
"type": "table",
"sm": 12,
"items": [
{
"type": "text",
"width": "20%",
"attr": "presetTopicName",
"title": "TopicName"
},
{
"type": "select",
"width": "20%",
"attr": "presetTopicAuth",
"title": "TopicAuth",
"options": [
{
"label": "defaultTopicAuthNone",
"value": 0
},
{
"label": "defaultTopicAuthUser",
"value": 1
},
{
"label": "defaultTopicAuthToken",
"value": 2
}
]
},
{
"type": "text",
"width": "20%",
"attr": "presetTopicUsername",
"title": "TopicUsername"
},
{
"type": "password",
"width": "20%",
"attr": "presetTopicPassword",
"title": "TopicPassword",
"visible": true
},
{
"type": "password",
"width": "20%",
"attr": "presetTopicAccessToken",
"title": "TopicAccessToken",
"visible": true
}
]
},
"actionsDivider": {
"type": "divider"
},
"testBtn": {
"type": "sendTo",
"command": "testBtn",
"variant": "contained",
"label": "Test"
}
}
}
14 changes: 14 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

const utils = require('@iobroker/adapter-core');
const axios = require('axios');
const {type} = require('os');

class ntfy extends utils.Adapter {

Expand Down Expand Up @@ -75,6 +76,19 @@ class ntfy extends utils.Adapter {
}
}
}
if (typeof obj === 'object' && obj.command) {
if (obj.command === 'testBtn') {
this.log.error(`test: ${JSON.stringify(this.config.presetTopics)} and type ${typeof this.config.presetTopics}`);
let testMsg;
if (typeof this.config.presetTopics !== 'object' || this.config.presetTopics.length <= 0) {
testMsg = 'Presets: None';
} else {
testMsg = `Presets: ${JSON.stringify(this.config.presetTopics)}`;
}

this.sendTo(obj.from, obj.command, [{label: testMsg, value: ''}], obj.callback);
}
}
}

sendMessage(obj) {
Expand Down

0 comments on commit 96cca9d

Please sign in to comment.