iobroker.drag-indicator 1.13.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +125 -0
- package/admin/custom_m.html +44 -0
- package/admin/drag-indicator.png +0 -0
- package/admin/index_m.html +95 -0
- package/admin/jsonCustom.json +34 -0
- package/admin/style.css +32 -0
- package/admin/words.js +41 -0
- package/io-package.json +101 -0
- package/lib/adapter-config.d.ts +19 -0
- package/main.js +413 -0
- package/package.json +70 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 BenAhrdt <bsahrdt@gmail.com>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+

|
|
2
|
+
# ioBroker.drag-indicator
|
|
3
|
+
|
|
4
|
+
[](https://www.npmjs.com/package/iobroker.drag-indicator)
|
|
5
|
+
[](https://www.npmjs.com/package/iobroker.drag-indicator)
|
|
6
|
+

|
|
7
|
+

|
|
8
|
+
[](https://david-dm.org/BenAhrdt/iobroker.drag-indicator)
|
|
9
|
+
|
|
10
|
+
[](https://nodei.co/npm/iobroker.drag-indicator/)
|
|
11
|
+
|
|
12
|
+
**Tests:** 
|
|
13
|
+
|
|
14
|
+
## drag-indicator adapter for ioBroker
|
|
15
|
+
|
|
16
|
+
Shows the min and max of a selected value
|
|
17
|
+
|
|
18
|
+
## Developer manual
|
|
19
|
+
This section is intended for the developer. It can be deleted later
|
|
20
|
+
|
|
21
|
+
### Getting started
|
|
22
|
+
|
|
23
|
+
You are almost done, only a few steps left:
|
|
24
|
+
1. Create a new repository on GitHub with the name `ioBroker.drag-indicator`
|
|
25
|
+
|
|
26
|
+
1. Push all files to the GitHub repo. The creator has already set up the local repository for you:
|
|
27
|
+
```bash
|
|
28
|
+
git push origin main
|
|
29
|
+
```
|
|
30
|
+
1. Add a new secret under https://github.com/BenAhrdt/ioBroker.drag-indicator/settings/secrets. It must be named `AUTO_MERGE_TOKEN` and contain a personal access token with push access to the repository, e.g. yours. You can create a new token under https://github.com/settings/tokens.
|
|
31
|
+
|
|
32
|
+
1. Head over to [main.js](main.js) and start programming!
|
|
33
|
+
|
|
34
|
+
### Best Practices
|
|
35
|
+
We've collected some [best practices](https://github.com/ioBroker/ioBroker.repositories#development-and-coding-best-practices) regarding ioBroker development and coding in general. If you're new to ioBroker or Node.js, you should
|
|
36
|
+
check them out. If you're already experienced, you should also take a look at them - you might learn something new :)
|
|
37
|
+
|
|
38
|
+
### Scripts in `package.json`
|
|
39
|
+
Several npm scripts are predefined for your convenience. You can run them using `npm run <scriptname>`
|
|
40
|
+
| Script name | Description |
|
|
41
|
+
|-------------|-------------|
|
|
42
|
+
| `test:js` | Executes the tests you defined in `*.test.js` files. |
|
|
43
|
+
| `test:package` | Ensures your `package.json` and `io-package.json` are valid. |
|
|
44
|
+
| `test:unit` | Tests the adapter startup with unit tests (fast, but might require module mocks to work). |
|
|
45
|
+
| `test:integration` | Tests the adapter startup with an actual instance of ioBroker. |
|
|
46
|
+
| `test` | Performs a minimal test run on package files and your tests. |
|
|
47
|
+
| `check` | Performs a type-check on your code (without compiling anything). |
|
|
48
|
+
| `lint` | Runs `ESLint` to check your code for formatting errors and potential bugs. |
|
|
49
|
+
| `translate` | Translates texts in your adapter to all required languages, see [`@iobroker/adapter-dev`](https://github.com/ioBroker/adapter-dev#manage-translations) for more details. |
|
|
50
|
+
| `release` | Creates a new release, see [`@alcalzone/release-script`](https://github.com/AlCalzone/release-script#usage) for more details. |
|
|
51
|
+
|
|
52
|
+
### Writing tests
|
|
53
|
+
When done right, testing code is invaluable, because it gives you the
|
|
54
|
+
confidence to change your code while knowing exactly if and when
|
|
55
|
+
something breaks. A good read on the topic of test-driven development
|
|
56
|
+
is https://hackernoon.com/introduction-to-test-driven-development-tdd-61a13bc92d92.
|
|
57
|
+
Although writing tests before the code might seem strange at first, but it has very
|
|
58
|
+
clear upsides.
|
|
59
|
+
|
|
60
|
+
The template provides you with basic tests for the adapter startup and package files.
|
|
61
|
+
It is recommended that you add your own tests into the mix.
|
|
62
|
+
|
|
63
|
+
### Publishing the adapter
|
|
64
|
+
Using GitHub Actions, you can enable automatic releases on npm whenever you push a new git tag that matches the form
|
|
65
|
+
`v<major>.<minor>.<patch>`. We **strongly recommend** that you do. The necessary steps are described in `.github/workflows/test-and-release.yml`.
|
|
66
|
+
|
|
67
|
+
Since you installed the release script, you can create a new
|
|
68
|
+
release simply by calling:
|
|
69
|
+
```bash
|
|
70
|
+
npm run release
|
|
71
|
+
```
|
|
72
|
+
Additional command line options for the release script are explained in the
|
|
73
|
+
[release-script documentation](https://github.com/AlCalzone/release-script#command-line).
|
|
74
|
+
|
|
75
|
+
To get your adapter released in ioBroker, please refer to the documentation
|
|
76
|
+
of [ioBroker.repositories](https://github.com/ioBroker/ioBroker.repositories#requirements-for-adapter-to-get-added-to-the-latest-repository).
|
|
77
|
+
|
|
78
|
+
### Test the adapter manually on a local ioBroker installation
|
|
79
|
+
In order to install the adapter locally without publishing, the following steps are recommended:
|
|
80
|
+
1. Create a tarball from your dev directory:
|
|
81
|
+
```bash
|
|
82
|
+
npm pack
|
|
83
|
+
```
|
|
84
|
+
1. Upload the resulting file to your ioBroker host
|
|
85
|
+
1. Install it locally (The paths are different on Windows):
|
|
86
|
+
```bash
|
|
87
|
+
cd /opt/iobroker
|
|
88
|
+
npm i /path/to/tarball.tgz
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
For later updates, the above procedure is not necessary. Just do the following:
|
|
92
|
+
1. Overwrite the changed files in the adapter directory (`/opt/iobroker/node_modules/iobroker.drag-indicator`)
|
|
93
|
+
1. Execute `iobroker upload drag-indicator` on the ioBroker host
|
|
94
|
+
|
|
95
|
+
## Changelog
|
|
96
|
+
<!--
|
|
97
|
+
Placeholder for the next version (at the beginning of the line):
|
|
98
|
+
### **WORK IN PROGRESS**
|
|
99
|
+
-->
|
|
100
|
+
|
|
101
|
+
### **WORK IN PROGRESS**
|
|
102
|
+
* (BenAhrdt) initial release
|
|
103
|
+
|
|
104
|
+
## License
|
|
105
|
+
MIT License
|
|
106
|
+
|
|
107
|
+
Copyright (c) 2022 BenAhrdt <bsahrdt@gmail.com>
|
|
108
|
+
|
|
109
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
110
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
111
|
+
in the Software without restriction, including without limitation the rights
|
|
112
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
113
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
114
|
+
furnished to do so, subject to the following conditions:
|
|
115
|
+
|
|
116
|
+
The above copyright notice and this permission notice shall be included in all
|
|
117
|
+
copies or substantial portions of the Software.
|
|
118
|
+
|
|
119
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
120
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
121
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
122
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
123
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
124
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
125
|
+
SOFTWARE.
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
<script type="text/x-iobroker" data-template-name="drag-indicator">
|
|
2
|
+
<div class="row">
|
|
3
|
+
<div class="col s2">
|
|
4
|
+
<input type="checkbox" data-field="enabled" data-default="false"/>
|
|
5
|
+
<!-- this field is mandatory, just to find out if to include this settings or not</span-->
|
|
6
|
+
<span class="translate">enabled</span>
|
|
7
|
+
</div>
|
|
8
|
+
<div class="col s4">
|
|
9
|
+
<input type="text" data-field="interval" size="30">
|
|
10
|
+
<span class="translate">period of time</span>
|
|
11
|
+
</div>
|
|
12
|
+
<div class="col s4">
|
|
13
|
+
<input type="text" data-field="state" size="30">
|
|
14
|
+
<span class="translate">new state</span>
|
|
15
|
+
</div>
|
|
16
|
+
<div class="col s2">
|
|
17
|
+
<input type="checkbox" data-field="setAck" data-default="false">
|
|
18
|
+
<span class="translate">ack</span>
|
|
19
|
+
</div>
|
|
20
|
+
</div>
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
<script type="text/javascript">
|
|
24
|
+
$.get("adapter/drag-indicator/words.js", function(script) {
|
|
25
|
+
let translation = script.substring(script.indexOf('{'), script.length);
|
|
26
|
+
translation = translation.substring(0, translation.lastIndexOf(';'));
|
|
27
|
+
$.extend(systemDictionary, JSON.parse(translation));
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
// There are two ways how to predefine default settings:
|
|
31
|
+
// - with attribute "data-default" (content independent)
|
|
32
|
+
// - with function in global variable "defaults". Function name is equal with adapter name.
|
|
33
|
+
// as input function receives object with all information concerning it
|
|
34
|
+
if (typeof defaults !== 'undefined') {
|
|
35
|
+
defaults["drag-indicator"] = function (obj, instanceObj) {
|
|
36
|
+
return {
|
|
37
|
+
enabled: false,
|
|
38
|
+
interval: '5m',
|
|
39
|
+
state: false,
|
|
40
|
+
setAck: false
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
</script>
|
|
Binary file
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
<html>
|
|
2
|
+
|
|
3
|
+
<head>
|
|
4
|
+
|
|
5
|
+
<!-- Load ioBroker scripts and styles-->
|
|
6
|
+
<link rel="stylesheet" type="text/css" href="../../css/adapter.css" />
|
|
7
|
+
<link rel="stylesheet" type="text/css" href="../../lib/css/materialize.css">
|
|
8
|
+
|
|
9
|
+
<script type="text/javascript" src="../../lib/js/jquery-3.2.1.min.js"></script>
|
|
10
|
+
<script type="text/javascript" src="../../socket.io/socket.io.js"></script>
|
|
11
|
+
|
|
12
|
+
<script type="text/javascript" src="../../js/translate.js"></script>
|
|
13
|
+
<script type="text/javascript" src="../../lib/js/materialize.js"></script>
|
|
14
|
+
<script type="text/javascript" src="../../js/adapter-settings.js"></script>
|
|
15
|
+
|
|
16
|
+
<!-- Load our own files -->
|
|
17
|
+
<link rel="stylesheet" type="text/css" href="style.css" />
|
|
18
|
+
<script type="text/javascript" src="words.js"></script>
|
|
19
|
+
|
|
20
|
+
<script type="text/javascript">
|
|
21
|
+
// This will be called by the admin adapter when the settings page loads
|
|
22
|
+
function load(settings, onChange) {
|
|
23
|
+
// example: select elements with id=key and class=value and insert value
|
|
24
|
+
if (!settings) return;
|
|
25
|
+
$('.value').each(function () {
|
|
26
|
+
var $key = $(this);
|
|
27
|
+
var id = $key.attr('id');
|
|
28
|
+
if ($key.attr('type') === 'checkbox') {
|
|
29
|
+
// do not call onChange direct, because onChange could expect some arguments
|
|
30
|
+
$key.prop('checked', settings[id])
|
|
31
|
+
.on('change', () => onChange())
|
|
32
|
+
;
|
|
33
|
+
} else {
|
|
34
|
+
// do not call onChange direct, because onChange could expect some arguments
|
|
35
|
+
$key.val(settings[id])
|
|
36
|
+
.on('change', () => onChange())
|
|
37
|
+
.on('keyup', () => onChange())
|
|
38
|
+
;
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
onChange(false);
|
|
42
|
+
// reinitialize all the Materialize labels on the page if you are dynamically adding inputs:
|
|
43
|
+
if (M) M.updateTextFields();
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// This will be called by the admin adapter when the user presses the save button
|
|
47
|
+
function save(callback) {
|
|
48
|
+
// example: select elements with class=value and build settings object
|
|
49
|
+
var obj = {};
|
|
50
|
+
$('.value').each(function () {
|
|
51
|
+
var $this = $(this);
|
|
52
|
+
if ($this.attr('type') === 'checkbox') {
|
|
53
|
+
obj[$this.attr('id')] = $this.prop('checked');
|
|
54
|
+
} else if ($this.attr('type') === 'number') {
|
|
55
|
+
obj[$this.attr('id')] = parseFloat($this.val());
|
|
56
|
+
} else {
|
|
57
|
+
obj[$this.attr('id')] = $this.val();
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
callback(obj);
|
|
61
|
+
}
|
|
62
|
+
</script>
|
|
63
|
+
|
|
64
|
+
</head>
|
|
65
|
+
|
|
66
|
+
<body>
|
|
67
|
+
|
|
68
|
+
<div class="m adapter-container">
|
|
69
|
+
|
|
70
|
+
<div class="row">
|
|
71
|
+
<div class="col s12 m4 l2">
|
|
72
|
+
<img src="drag-indicator.png" class="logo">
|
|
73
|
+
</div>
|
|
74
|
+
</div>
|
|
75
|
+
|
|
76
|
+
<!-- Put your content here -->
|
|
77
|
+
|
|
78
|
+
<!-- For example columns with settings: -->
|
|
79
|
+
<div class="row">
|
|
80
|
+
<div class="col s6 input-field">
|
|
81
|
+
<input type="checkbox" class="value" id="deleteStatesWithDisable" />
|
|
82
|
+
<label for="deleteStatesWithDisable" class="translate">State mit deaktivieren Löschen</label>
|
|
83
|
+
</div>
|
|
84
|
+
</div>
|
|
85
|
+
|
|
86
|
+
<div class="row">
|
|
87
|
+
<p style="text-align:center ; font-weight: bold ; color: red"> Die State spezifischen Einstellungen, nehmen Sie bitte direkt in der Benutzerdefinierten
|
|
88
|
+
Einstellung des jeweilen Sates vor.</p>
|
|
89
|
+
</div>
|
|
90
|
+
|
|
91
|
+
</div>
|
|
92
|
+
|
|
93
|
+
</body>
|
|
94
|
+
|
|
95
|
+
</html>
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"i18n": true,
|
|
3
|
+
"items": {
|
|
4
|
+
"_basicSettings": {
|
|
5
|
+
"newLine": true,
|
|
6
|
+
"type": "header",
|
|
7
|
+
"text": "Schleppzeigereinstellungen",
|
|
8
|
+
"sm": 20
|
|
9
|
+
},
|
|
10
|
+
"warningText": {
|
|
11
|
+
"newLine": true,
|
|
12
|
+
"type": "staticText",
|
|
13
|
+
"text": "!!! Achtung, es können nur Datenpunkte vom Typ number ausgewählt werden",
|
|
14
|
+
"hidden": "customObj.common.type === 'number'",
|
|
15
|
+
"sm": 12
|
|
16
|
+
},
|
|
17
|
+
"channelName": {
|
|
18
|
+
"type": "text",
|
|
19
|
+
"label": "Name",
|
|
20
|
+
"tooltip": "Tragen Sie hier den Name des Datenpunkts ein, welcher später in dem übergeordnerten Verzeichnnis angezeigt werden soll.",
|
|
21
|
+
"hidden": "customObj.common.type !== 'number'",
|
|
22
|
+
"sm":3
|
|
23
|
+
},
|
|
24
|
+
"resetCronJob": {
|
|
25
|
+
"newLine": true,
|
|
26
|
+
"simple": true,
|
|
27
|
+
"type": "cron",
|
|
28
|
+
"label": "Automatischer Reset",
|
|
29
|
+
"tooltip": "Tragen Sie hier den entsprechenden cronJob ein, bei welchem ein automatischer Reset erfolgen soll.",
|
|
30
|
+
"hidden": "customObj.common.type !== 'number'",
|
|
31
|
+
"sm":6
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
package/admin/style.css
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/* You can delete those if you want. I just found them very helpful */
|
|
2
|
+
* {
|
|
3
|
+
box-sizing: border-box
|
|
4
|
+
}
|
|
5
|
+
.m {
|
|
6
|
+
/* Don't cut off dropdowns! */
|
|
7
|
+
overflow: initial;
|
|
8
|
+
}
|
|
9
|
+
.m.adapter-container,
|
|
10
|
+
.m.adapter-container > div.App {
|
|
11
|
+
/* Fix layout/scrolling issues with tabs */
|
|
12
|
+
height: 100%;
|
|
13
|
+
width: 100%;
|
|
14
|
+
position: relative;
|
|
15
|
+
}
|
|
16
|
+
.m .select-wrapper + label {
|
|
17
|
+
/* The positioning for dropdown labels is messed up */
|
|
18
|
+
transform: none !important;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
label > i[title] {
|
|
22
|
+
/* Display the help cursor for the tooltip icons and fix their positioning */
|
|
23
|
+
cursor: help;
|
|
24
|
+
margin-left: 0.25em;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.dropdown-content {
|
|
28
|
+
/* Don't wrap text in dropdowns */
|
|
29
|
+
white-space: nowrap;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/* Add your styles here */
|
package/admin/words.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/*global systemDictionary:true */
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
systemDictionary = {
|
|
5
|
+
"drag-indicator adapter settings": {
|
|
6
|
+
"en": "Adapter settings for drag-indicator",
|
|
7
|
+
"de": "Adaptereinstellungen für drag-indicator",
|
|
8
|
+
"ru": "Настройки адаптера для drag-indicator",
|
|
9
|
+
"pt": "Configurações do adaptador para drag-indicator",
|
|
10
|
+
"nl": "Adapterinstellingen voor drag-indicator",
|
|
11
|
+
"fr": "Paramètres d'adaptateur pour drag-indicator",
|
|
12
|
+
"it": "Impostazioni dell'adattatore per drag-indicator",
|
|
13
|
+
"es": "Ajustes del adaptador para drag-indicator",
|
|
14
|
+
"pl": "Ustawienia adaptera dla drag-indicator",
|
|
15
|
+
"zh-cn": "drag-indicator的适配器设置"
|
|
16
|
+
},
|
|
17
|
+
"option1": {
|
|
18
|
+
"en": "option1",
|
|
19
|
+
"de": "Option 1",
|
|
20
|
+
"ru": "Опция 1",
|
|
21
|
+
"pt": "Opção 1",
|
|
22
|
+
"nl": "Optie 1",
|
|
23
|
+
"fr": "Option 1",
|
|
24
|
+
"it": "opzione 1",
|
|
25
|
+
"es": "Opción 1",
|
|
26
|
+
"pl": "opcja 1",
|
|
27
|
+
"zh-cn": "选项1"
|
|
28
|
+
},
|
|
29
|
+
"option2": {
|
|
30
|
+
"en": "option2",
|
|
31
|
+
"de": "Option 2",
|
|
32
|
+
"ru": "вариант 2",
|
|
33
|
+
"pt": "opção 2",
|
|
34
|
+
"nl": "Optie 2",
|
|
35
|
+
"fr": "Option 2",
|
|
36
|
+
"it": "opzione 2",
|
|
37
|
+
"es": "opcion 2",
|
|
38
|
+
"pl": "Opcja 2",
|
|
39
|
+
"zh-cn": "选项2"
|
|
40
|
+
}
|
|
41
|
+
};
|
package/io-package.json
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
{
|
|
2
|
+
"common": {
|
|
3
|
+
"name": "drag-indicator",
|
|
4
|
+
"version": "1.13.6",
|
|
5
|
+
"news": {
|
|
6
|
+
"0.0.1": {
|
|
7
|
+
"en": "initial release",
|
|
8
|
+
"de": "Erstveröffentlichung",
|
|
9
|
+
"ru": "Начальная версия",
|
|
10
|
+
"pt": "lançamento inicial",
|
|
11
|
+
"nl": "Eerste uitgave",
|
|
12
|
+
"fr": "Première version",
|
|
13
|
+
"it": "Versione iniziale",
|
|
14
|
+
"es": "Versión inicial",
|
|
15
|
+
"pl": "Pierwsze wydanie",
|
|
16
|
+
"zh-cn": "首次出版"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"title": "Drag-Indicator",
|
|
20
|
+
"titleLang": {
|
|
21
|
+
"en": "Drag-Indicator",
|
|
22
|
+
"de": "Schleppzeiger",
|
|
23
|
+
"ru": "Индикатор перетаскивания",
|
|
24
|
+
"pt": "Indicador de arrastar",
|
|
25
|
+
"nl": "Sleep-indicator",
|
|
26
|
+
"fr": "Indicateur de traînée",
|
|
27
|
+
"it": "Indicatore di trascinamento",
|
|
28
|
+
"es": "Indicador de arrastre",
|
|
29
|
+
"pl": "Wskaźnik przeciągania",
|
|
30
|
+
"zh-cn": "拖动指示器"
|
|
31
|
+
},
|
|
32
|
+
"desc": {
|
|
33
|
+
"en": "Shows the min and max of a selected value",
|
|
34
|
+
"de": "Zeigt das Minimum und Maximum eines ausgewählten Werts an",
|
|
35
|
+
"ru": "Показывает минимум и максимум выбранного значения",
|
|
36
|
+
"pt": "Mostra o mínimo e o máximo de um valor selecionado",
|
|
37
|
+
"nl": "Toont de min en max van een geselecteerde waarde",
|
|
38
|
+
"fr": "Affiche le min et le max d'une valeur sélectionnée",
|
|
39
|
+
"it": "Mostra il minimo e il massimo di un valore selezionato",
|
|
40
|
+
"es": "Muestra el mínimo y el máximo de un valor seleccionado",
|
|
41
|
+
"pl": "Pokazuje minimalną i maksymalną wartość wybranej wartości",
|
|
42
|
+
"zh-cn": "显示所选值的最小值和最大值"
|
|
43
|
+
},
|
|
44
|
+
"authors": [
|
|
45
|
+
"BenAhrdt <bsahrdt@gmail.com>"
|
|
46
|
+
],
|
|
47
|
+
"keywords": [
|
|
48
|
+
"drag-indicator",
|
|
49
|
+
"Schleppzeiger",
|
|
50
|
+
"min",
|
|
51
|
+
"max"
|
|
52
|
+
],
|
|
53
|
+
"license": "MIT",
|
|
54
|
+
"platform": "Javascript/Node.js",
|
|
55
|
+
"main": "main.js",
|
|
56
|
+
"icon": "drag-indicator.png",
|
|
57
|
+
"enabled": true,
|
|
58
|
+
"extIcon": "https://raw.githubusercontent.com/BenAhrdt/ioBroker.drag-indicator/main/admin/drag-indicator.png",
|
|
59
|
+
"readme": "https://github.com/BenAhrdt/ioBroker.drag-indicator/blob/main/README.md",
|
|
60
|
+
"loglevel": "info",
|
|
61
|
+
"mode": "daemon",
|
|
62
|
+
"type": "energy",
|
|
63
|
+
"compact": true,
|
|
64
|
+
"connectionType": "local",
|
|
65
|
+
"dataSource": "poll",
|
|
66
|
+
"materialize": true,
|
|
67
|
+
"supportCustoms": true,
|
|
68
|
+
"dependencies": [
|
|
69
|
+
{
|
|
70
|
+
"js-controller": ">=2.0.0"
|
|
71
|
+
}
|
|
72
|
+
]
|
|
73
|
+
},
|
|
74
|
+
"native": {
|
|
75
|
+
"deleteStatesWithDisable": false
|
|
76
|
+
},
|
|
77
|
+
"objects": [],
|
|
78
|
+
"instanceObjects": [
|
|
79
|
+
{
|
|
80
|
+
"_id": "info",
|
|
81
|
+
"type": "channel",
|
|
82
|
+
"common": {
|
|
83
|
+
"name": "Information"
|
|
84
|
+
},
|
|
85
|
+
"native": {}
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
"_id": "info.connection",
|
|
89
|
+
"type": "state",
|
|
90
|
+
"common": {
|
|
91
|
+
"role": "indicator.connected",
|
|
92
|
+
"name": "Device or service connected",
|
|
93
|
+
"type": "boolean",
|
|
94
|
+
"read": true,
|
|
95
|
+
"write": false,
|
|
96
|
+
"def": false
|
|
97
|
+
},
|
|
98
|
+
"native": {}
|
|
99
|
+
}
|
|
100
|
+
]
|
|
101
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// This file extends the AdapterConfig type from "@types/iobroker"
|
|
2
|
+
// using the actual properties present in io-package.json
|
|
3
|
+
// in order to provide typings for adapter.config properties
|
|
4
|
+
|
|
5
|
+
import { native } from "../io-package.json";
|
|
6
|
+
|
|
7
|
+
type _AdapterConfig = typeof native;
|
|
8
|
+
|
|
9
|
+
// Augment the globally declared type ioBroker.AdapterConfig
|
|
10
|
+
declare global {
|
|
11
|
+
namespace ioBroker {
|
|
12
|
+
interface AdapterConfig extends _AdapterConfig {
|
|
13
|
+
// Do not enter anything here!
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// this is required so the above AdapterConfig is found by TypeScript / type checking
|
|
19
|
+
export {};
|
package/main.js
ADDED
|
@@ -0,0 +1,413 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* Created with @iobroker/create-adapter v2.1.1
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
// The adapter-core module gives you access to the core ioBroker functions
|
|
8
|
+
// you need to create an adapter
|
|
9
|
+
const utils = require("@iobroker/adapter-core");
|
|
10
|
+
const schedule = require("node-schedule");
|
|
11
|
+
const { isDeepStrictEqual } = require("util");
|
|
12
|
+
|
|
13
|
+
// Load your modules here, e.g.:
|
|
14
|
+
// const fs = require("fs");
|
|
15
|
+
|
|
16
|
+
class DragIndicator extends utils.Adapter {
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @param {Partial<utils.AdapterOptions>} [options={}]
|
|
20
|
+
*/
|
|
21
|
+
constructor(options) {
|
|
22
|
+
super({
|
|
23
|
+
...options,
|
|
24
|
+
name: "drag-indicator",
|
|
25
|
+
});
|
|
26
|
+
this.on("ready", this.onReady.bind(this));
|
|
27
|
+
this.on("stateChange", this.onStateChange.bind(this));
|
|
28
|
+
this.on("objectChange", this.onObjectChange.bind(this));
|
|
29
|
+
// this.on("message", this.onMessage.bind(this));
|
|
30
|
+
this.on("unload", this.onUnload.bind(this));
|
|
31
|
+
|
|
32
|
+
this.subscribecounterId = "info.subscribedStatesCount";
|
|
33
|
+
this.subscribecounter = 0;
|
|
34
|
+
|
|
35
|
+
this.additionalIds = {
|
|
36
|
+
max : ".max",
|
|
37
|
+
min : ".min",
|
|
38
|
+
reset : ".reset"
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
this.observedValuesId = "observed_Values.";
|
|
42
|
+
this.cronJobs = {};
|
|
43
|
+
this.jobId = "jobId";
|
|
44
|
+
|
|
45
|
+
// define arrays for selected states and calculation
|
|
46
|
+
this.activeStates = {};
|
|
47
|
+
this.activeStatesLastAdditionalValues = {};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Is called when databases are connected and adapter received configuration.
|
|
52
|
+
*/
|
|
53
|
+
async onReady() {
|
|
54
|
+
// Initialize your adapter here
|
|
55
|
+
// Reset the connection indicator during startup
|
|
56
|
+
this.setState("info.connection", false, true);
|
|
57
|
+
|
|
58
|
+
// Creates the subscribed state count
|
|
59
|
+
await this.setObjectNotExistsAsync(this.subscribecounterId, {
|
|
60
|
+
type: "state",
|
|
61
|
+
common: {
|
|
62
|
+
name: "Count of subscribed states",
|
|
63
|
+
type: "number",
|
|
64
|
+
role: "indicator",
|
|
65
|
+
read: true,
|
|
66
|
+
write: false,
|
|
67
|
+
def:0
|
|
68
|
+
},
|
|
69
|
+
native: {},
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
//Read all states with custom configuration
|
|
73
|
+
const customStateArray = await this.getObjectViewAsync("system","custom",{});
|
|
74
|
+
|
|
75
|
+
// Request if there is an object
|
|
76
|
+
if(customStateArray && customStateArray.rows)
|
|
77
|
+
{
|
|
78
|
+
for(let index = 0 ; index < customStateArray.rows.length ; index++){
|
|
79
|
+
if(customStateArray.rows[index].value !== null){
|
|
80
|
+
// Request if there is an object for this namespace an its enabled
|
|
81
|
+
if (customStateArray.rows[index].value[this.namespace] && customStateArray.rows[index].value[this.namespace].enabled === true) {
|
|
82
|
+
const id = customStateArray.rows[index].id;
|
|
83
|
+
const obj = await this.getForeignObjectAsync(id);
|
|
84
|
+
if(obj){
|
|
85
|
+
const common = obj.common;
|
|
86
|
+
const state = await this.getForeignStateAsync(id);
|
|
87
|
+
if(state){
|
|
88
|
+
await this.addObjectAndCreateState(id,common,customStateArray.rows[index].value[this.namespace],state,true);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
this.subscribeForeignObjects("*");
|
|
97
|
+
this.setState(this.subscribecounterId,this.subscribecounter,true);
|
|
98
|
+
this.setState("info.connection", true, true);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Is called when adapter shuts down - callback has to be called under any circumstances!
|
|
103
|
+
* @param {() => void} callback
|
|
104
|
+
*/
|
|
105
|
+
onUnload(callback) {
|
|
106
|
+
try {
|
|
107
|
+
// clear all schedules
|
|
108
|
+
for(const cronJob in this.cronJobs)
|
|
109
|
+
{
|
|
110
|
+
schedule.cancelJob(this.cronJobs[cronJob][this.jobId]);
|
|
111
|
+
}
|
|
112
|
+
callback();
|
|
113
|
+
} catch (e) {
|
|
114
|
+
callback();
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
async addObjectAndCreateState(id,common,customInfo,state,countUpSubscibecounter)
|
|
119
|
+
{
|
|
120
|
+
// check if custominfo is available
|
|
121
|
+
if(!customInfo){
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
if(common.type != "number")
|
|
125
|
+
{
|
|
126
|
+
this.log.error(`state ${id} is not type number, but ${common.type}`);
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
this.activeStates[id] = {};
|
|
130
|
+
this.activeStates[id].customInfo = customInfo;
|
|
131
|
+
// Create adapter internal object
|
|
132
|
+
const tempId = this.createStatestring(id);
|
|
133
|
+
await this.setObjectAsync(tempId,{
|
|
134
|
+
type:"channel",
|
|
135
|
+
common:{
|
|
136
|
+
name: customInfo.channelName
|
|
137
|
+
},
|
|
138
|
+
native : {},
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
// create adapter internal states
|
|
142
|
+
for(const myId in this.additionalIds){
|
|
143
|
+
const tempId = this.createStatestring(id) + this.additionalIds[myId];
|
|
144
|
+
if(this.additionalIds[myId] == this.additionalIds.reset){
|
|
145
|
+
await this.setObjectNotExistsAsync(tempId,{
|
|
146
|
+
type: "state",
|
|
147
|
+
common: {
|
|
148
|
+
name: myId,
|
|
149
|
+
type: "boolean",
|
|
150
|
+
role: "reset",
|
|
151
|
+
read: true,
|
|
152
|
+
write: true,
|
|
153
|
+
def: false
|
|
154
|
+
},
|
|
155
|
+
native: {},
|
|
156
|
+
});
|
|
157
|
+
this.log.debug(`state ${tempId} added / activated`);
|
|
158
|
+
this.subscribeStates(tempId);
|
|
159
|
+
this.activeStatesLastAdditionalValues[this.namespace + "." + tempId] = id;
|
|
160
|
+
this.setState(tempId,false,true);
|
|
161
|
+
}
|
|
162
|
+
else{
|
|
163
|
+
await this.setObjectNotExistsAsync(tempId,{
|
|
164
|
+
type: "state",
|
|
165
|
+
common: {
|
|
166
|
+
name: common.name,
|
|
167
|
+
type: common.type,
|
|
168
|
+
role: common.role,
|
|
169
|
+
unit: common.unit,
|
|
170
|
+
read: true,
|
|
171
|
+
write: true
|
|
172
|
+
},
|
|
173
|
+
native: {},
|
|
174
|
+
});
|
|
175
|
+
this.log.debug(`state ${tempId} added / activated`);
|
|
176
|
+
this.subscribeStates(tempId);
|
|
177
|
+
const lastState = await this.getStateAsync(tempId);
|
|
178
|
+
if(lastState !== undefined && lastState !== null){
|
|
179
|
+
this.activeStatesLastAdditionalValues[this.namespace + "." + tempId] = lastState.val;
|
|
180
|
+
}
|
|
181
|
+
else{
|
|
182
|
+
this.activeStatesLastAdditionalValues[this.namespace + "." + tempId] = state.val;
|
|
183
|
+
this.setState(tempId,state.val,true);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
if(customInfo.resetCronJob != ""){
|
|
188
|
+
if(!this.cronJobs[customInfo.resetCronJob]){
|
|
189
|
+
this.cronJobs[customInfo.resetCronJob] = {};
|
|
190
|
+
this.cronJobs[customInfo.resetCronJob][this.jobId] = schedule.scheduleJob(customInfo.resetCronJob,this.resetWithCronJob.bind(this,customInfo.resetCronJob));
|
|
191
|
+
}
|
|
192
|
+
this.cronJobs[customInfo.resetCronJob][this.createStatestring(id)] = {};
|
|
193
|
+
this.activeStates[id].lastCronJob = customInfo.resetCronJob;
|
|
194
|
+
}
|
|
195
|
+
else
|
|
196
|
+
{
|
|
197
|
+
this.activeStates[id].lastCronJob = "";
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// Subcribe main state
|
|
201
|
+
if(countUpSubscibecounter){
|
|
202
|
+
this.subscribeForeignStates(id);
|
|
203
|
+
this.subscribecounter += 1;
|
|
204
|
+
this.setState(this.subscribecounterId,this.subscribecounter,true);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
// if the id is scheduled, it will be deleted from active array
|
|
209
|
+
removefromCronJob(cronJob,id)
|
|
210
|
+
{
|
|
211
|
+
if(this.activeStates[id].lastCronJob != ""){
|
|
212
|
+
delete this.cronJobs[cronJob][this.createStatestring(id)];
|
|
213
|
+
if(Object.keys(this.cronJobs[cronJob]).length <= 1)
|
|
214
|
+
{
|
|
215
|
+
this.log.debug("job canceled: " + cronJob);
|
|
216
|
+
schedule.cancelJob(this.cronJobs[cronJob][this.jobId]);
|
|
217
|
+
delete this.cronJobs[cronJob];
|
|
218
|
+
}
|
|
219
|
+
this.activeStates[id].lastCronJob = "";
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
createStatestring(id){
|
|
224
|
+
return `${this.observedValuesId}${id.replace(/\./g, "_")}`;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
// clear the state from the active array. if selected the state will be deleted
|
|
228
|
+
async clearStateArrayElement(id, deleteState)
|
|
229
|
+
{
|
|
230
|
+
// Unsubscribe and delete states if exists
|
|
231
|
+
if(this.activeStates[id]){
|
|
232
|
+
this.removefromCronJob(this.activeStates[id].lastCronJob,id);
|
|
233
|
+
this.unsubscribeForeignStates(id);
|
|
234
|
+
this.log.debug(`state ${id} not longer subscribed`);
|
|
235
|
+
delete this.activeStates[id];
|
|
236
|
+
this.subscribecounter -= 1;
|
|
237
|
+
this.setState(this.subscribecounterId,this.subscribecounter,true);
|
|
238
|
+
}
|
|
239
|
+
if(this.config.deleteStatesWithDisable || deleteState){
|
|
240
|
+
for(const myId in this.additionalIds){
|
|
241
|
+
const tempId = this.createStatestring(id) + this.additionalIds[myId];
|
|
242
|
+
const myObj = await this.getObjectAsync(tempId);
|
|
243
|
+
if(myObj){
|
|
244
|
+
this.unsubscribeStatesAsync(tempId);
|
|
245
|
+
this.log.debug(`state ${tempId} removed`);
|
|
246
|
+
this.delObjectAsync(tempId);
|
|
247
|
+
this.log.debug(`state ${this.namespace}.${tempId} deleted`);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
// Delete channel Object
|
|
251
|
+
this.delObjectAsync(this.createStatestring(id));
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/***************************************************************************************
|
|
256
|
+
* ********************************** Changes ******************************************
|
|
257
|
+
***************************************************************************************/
|
|
258
|
+
|
|
259
|
+
async onObjectChange(id, obj) {
|
|
260
|
+
if (obj) {
|
|
261
|
+
try {
|
|
262
|
+
if(!obj.common.custom || !obj.common.custom[this.namespace]){
|
|
263
|
+
if(this.activeStates[id])
|
|
264
|
+
{
|
|
265
|
+
this.clearStateArrayElement(id,false);
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
else{
|
|
270
|
+
const customInfo = obj.common.custom[this.namespace];
|
|
271
|
+
if(this.activeStates[id])
|
|
272
|
+
{
|
|
273
|
+
const state = await this.getForeignStateAsync(id);
|
|
274
|
+
if(state){
|
|
275
|
+
if(!isDeepStrictEqual(this.activeStates[id].customInfo,customInfo)){
|
|
276
|
+
this.removefromCronJob(this.activeStates[id].lastCronJob,id);
|
|
277
|
+
await this.addObjectAndCreateState(id,obj.common,customInfo,state,false);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
else
|
|
282
|
+
{
|
|
283
|
+
const state = await this.getForeignStateAsync(id);
|
|
284
|
+
if(state)
|
|
285
|
+
{
|
|
286
|
+
this.addObjectAndCreateState(id,obj.common,customInfo,state,true);
|
|
287
|
+
}
|
|
288
|
+
else
|
|
289
|
+
{
|
|
290
|
+
this.log.error(`could not read state ${id}`);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
} catch (error) {
|
|
295
|
+
this.log.error(error);
|
|
296
|
+
this.clearStateArrayElement(id,false);
|
|
297
|
+
}
|
|
298
|
+
} else {
|
|
299
|
+
// The object was deleted
|
|
300
|
+
// Check if the object is kwnow
|
|
301
|
+
const obj = await this.getObjectAsync(this.createStatestring(id) + this.additionalIds.consumed);
|
|
302
|
+
if(this.activeStates[id] || obj)
|
|
303
|
+
{
|
|
304
|
+
this.clearStateArrayElement(id,true);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
resetWithCronJob(cronJob){
|
|
310
|
+
for(const ele in this.cronJobs[cronJob]){
|
|
311
|
+
if(ele != this.jobId){
|
|
312
|
+
this.resetValues(this.namespace + "." + ele + this.additionalIds.reset,this.namespace.length,this.additionalIds.reset.length);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Is called if a subscribed state changes
|
|
318
|
+
* @param {string} id
|
|
319
|
+
* @param {ioBroker.State | null | undefined} state
|
|
320
|
+
*/
|
|
321
|
+
async onStateChange(id, state) {
|
|
322
|
+
if (state) {
|
|
323
|
+
// Check if state.val is reachable
|
|
324
|
+
if(state.val !== undefined && state.val !== null){
|
|
325
|
+
// Check Changes in Foreign states
|
|
326
|
+
if(this.activeStates[id]){
|
|
327
|
+
let tempId = this.createStatestring(id) + this.additionalIds.max;
|
|
328
|
+
if(state.val > this.activeStatesLastAdditionalValues[this.namespace + "." + tempId]){
|
|
329
|
+
const tempValue = state.val;
|
|
330
|
+
this.activeStatesLastAdditionalValues[this.namespace + "." + tempId] = tempValue;
|
|
331
|
+
this.setStateAsync(tempId,tempValue,true);
|
|
332
|
+
}
|
|
333
|
+
else{
|
|
334
|
+
tempId = this.createStatestring(id) + this.additionalIds.min;
|
|
335
|
+
if(state.val < this.activeStatesLastAdditionalValues[this.namespace + "." + tempId]){
|
|
336
|
+
const tempValue = state.val;
|
|
337
|
+
this.activeStatesLastAdditionalValues[this.namespace + "." + tempId] = tempValue;
|
|
338
|
+
this.setStateAsync(tempId,tempValue,true);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
// Check Changes in interneal States
|
|
344
|
+
else if(this.activeStatesLastAdditionalValues[id] !== undefined && this.activeStatesLastAdditionalValues[id] !== null && !state.ack){
|
|
345
|
+
const extentionLength = this.additionalIds.reset.length;
|
|
346
|
+
const extention = id.substring(id.length - extentionLength);
|
|
347
|
+
const prefixLengt = this.namespace.length;
|
|
348
|
+
const prefix = id.substring(0,prefixLengt);
|
|
349
|
+
if(extention == this.additionalIds.reset && prefix == this.namespace){
|
|
350
|
+
// check that reset is true
|
|
351
|
+
if(state.val == true){
|
|
352
|
+
this.resetValues(id,prefixLengt,extentionLength);
|
|
353
|
+
this.setForeignStateAsync(id,true,true);
|
|
354
|
+
}
|
|
355
|
+
else{
|
|
356
|
+
this.setForeignStateAsync(id,false,true);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
else{
|
|
360
|
+
this.activeStatesLastAdditionalValues[id] = state.val;
|
|
361
|
+
this.setForeignStateAsync(id,state.val,true);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
} else {
|
|
367
|
+
// The state was deleted
|
|
368
|
+
this.log.debug(`state ${id} deleted`);
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
async resetValues(id,prefixLengt,extentionLength){
|
|
373
|
+
const subId = id.substring(prefixLengt + 1,id.length - extentionLength);
|
|
374
|
+
// Get current state
|
|
375
|
+
const curState = await this.getForeignStateAsync(this.activeStatesLastAdditionalValues[id]);
|
|
376
|
+
if(curState){
|
|
377
|
+
this.activeStatesLastAdditionalValues[this.namespace + "." + subId + this.additionalIds.max] = curState.val;
|
|
378
|
+
this.setStateAsync(subId + this.additionalIds.max,curState.val,true);
|
|
379
|
+
this.activeStatesLastAdditionalValues[this.namespace + "." + subId + this.additionalIds.min] = curState.val;
|
|
380
|
+
this.setStateAsync(subId + this.additionalIds.min,curState.val,true);
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
// If you need to accept messages in your adapter, uncomment the following block and the corresponding line in the constructor.
|
|
384
|
+
// /**
|
|
385
|
+
// * Some message was sent to this instance over message box. Used by email, pushover, text2speech, ...
|
|
386
|
+
// * Using this method requires "common.messagebox" property to be set to true in io-package.json
|
|
387
|
+
// * @param {ioBroker.Message} obj
|
|
388
|
+
// */
|
|
389
|
+
// onMessage(obj) {
|
|
390
|
+
// if (typeof obj === "object" && obj.message) {
|
|
391
|
+
// if (obj.command === "send") {
|
|
392
|
+
// // e.g. send email or pushover or whatever
|
|
393
|
+
// this.log.debug("send command");
|
|
394
|
+
|
|
395
|
+
// // Send response in callback if required
|
|
396
|
+
// if (obj.callback) this.sendTo(obj.from, obj.command, "Message received", obj.callback);
|
|
397
|
+
// }
|
|
398
|
+
// }
|
|
399
|
+
// }
|
|
400
|
+
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
|
|
404
|
+
if (require.main !== module) {
|
|
405
|
+
// Export the constructor in compact mode
|
|
406
|
+
/**
|
|
407
|
+
* @param {Partial<utils.AdapterOptions>} [options={}]
|
|
408
|
+
*/
|
|
409
|
+
module.exports = (options) => new DragIndicator(options);
|
|
410
|
+
} else {
|
|
411
|
+
// otherwise start the instance directly
|
|
412
|
+
new DragIndicator();
|
|
413
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "iobroker.drag-indicator",
|
|
3
|
+
"version": "1.13.6",
|
|
4
|
+
"description": "Shows the min and max of a selected value",
|
|
5
|
+
"author": {
|
|
6
|
+
"name": "BenAhrdt",
|
|
7
|
+
"email": "bsahrdt@gmail.com"
|
|
8
|
+
},
|
|
9
|
+
"homepage": "https://github.com/BenAhrdt/ioBroker.drag-indicator",
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"keywords": [
|
|
12
|
+
"drag-indicator",
|
|
13
|
+
"Schleppzeiger",
|
|
14
|
+
"min",
|
|
15
|
+
"max"
|
|
16
|
+
],
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "https://github.com/BenAhrdt/ioBroker.drag-indicator"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@iobroker/adapter-core": "^2.6.0",
|
|
23
|
+
"node-schedule": "^2.1.0"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@alcalzone/release-script": "^2.2.2",
|
|
27
|
+
"@iobroker/adapter-dev": "^1.0.0",
|
|
28
|
+
"@iobroker/testing": "^2.5.6",
|
|
29
|
+
"@types/chai": "^4.3.0",
|
|
30
|
+
"@types/chai-as-promised": "^7.1.5",
|
|
31
|
+
"@types/mocha": "^9.1.0",
|
|
32
|
+
"@types/node": "^14.18.12",
|
|
33
|
+
"@types/proxyquire": "^1.3.28",
|
|
34
|
+
"@types/sinon": "^10.0.11",
|
|
35
|
+
"@types/sinon-chai": "^3.2.8",
|
|
36
|
+
"chai": "^4.3.6",
|
|
37
|
+
"chai-as-promised": "^7.1.1",
|
|
38
|
+
"eslint": "^8.12.0",
|
|
39
|
+
"mocha": "^9.2.2",
|
|
40
|
+
"proxyquire": "^2.1.3",
|
|
41
|
+
"sinon": "^13.0.1",
|
|
42
|
+
"sinon-chai": "^3.7.0",
|
|
43
|
+
"typescript": "~4.5.5"
|
|
44
|
+
},
|
|
45
|
+
"main": "main.js",
|
|
46
|
+
"files": [
|
|
47
|
+
"admin{,/!(src)/**}/!(tsconfig|tsconfig.*).json",
|
|
48
|
+
"admin{,/!(src)/**}/*.{html,css,png,svg,jpg,js}",
|
|
49
|
+
"lib/",
|
|
50
|
+
"www/",
|
|
51
|
+
"io-package.json",
|
|
52
|
+
"LICENSE",
|
|
53
|
+
"main.js"
|
|
54
|
+
],
|
|
55
|
+
"scripts": {
|
|
56
|
+
"test:js": "mocha --config test/mocharc.custom.json \"{!(node_modules|test)/**/*.test.js,*.test.js,test/**/test!(PackageFiles|Startup).js}\"",
|
|
57
|
+
"test:package": "mocha test/package --exit",
|
|
58
|
+
"test:unit": "mocha test/unit --exit",
|
|
59
|
+
"test:integration": "mocha test/integration --exit",
|
|
60
|
+
"test": "npm run test:js && npm run test:package",
|
|
61
|
+
"check": "tsc --noEmit -p tsconfig.check.json",
|
|
62
|
+
"lint": "eslint",
|
|
63
|
+
"translate": "translate-adapter",
|
|
64
|
+
"release": "release-script"
|
|
65
|
+
},
|
|
66
|
+
"bugs": {
|
|
67
|
+
"url": "https://github.com/BenAhrdt/ioBroker.drag-indicator/issues"
|
|
68
|
+
},
|
|
69
|
+
"readmeFilename": "README.md"
|
|
70
|
+
}
|