iobroker.hass 1.0.1 → 1.1.2
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 +1 -1
- package/README.md +82 -1
- package/admin/i18n/de/translations.json +8 -0
- package/admin/i18n/en/translations.json +8 -0
- package/admin/i18n/es/translations.json +8 -0
- package/admin/i18n/fr/translations.json +8 -0
- package/admin/i18n/it/translations.json +8 -0
- package/admin/i18n/nl/translations.json +8 -0
- package/admin/i18n/pl/translations.json +8 -0
- package/admin/i18n/pt/translations.json +8 -0
- package/admin/i18n/ru/translations.json +8 -0
- package/admin/i18n/zh-cn/translations.json +8 -0
- package/admin/index_m.html +108 -75
- package/admin/words.js +10 -18
- package/io-package.json +221 -127
- package/lib/hass.js +5 -4
- package/lib/tools.js +92 -0
- package/main.js +40 -12
- package/package.json +13 -7
- package/admin/index.html +0 -76
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
The MIT License (MIT)
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2018-
|
|
3
|
+
Copyright (c) 2018-2022 bluefox <dogafox@gmail.com>
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
package/README.md
CHANGED
|
@@ -1,15 +1,85 @@
|
|
|
1
1
|

|
|
2
2
|
# ioBroker.hass
|
|
3
3
|
|
|
4
|
+

|
|
5
|
+

|
|
4
6
|
[](https://www.npmjs.com/package/iobroker.hass)
|
|
7
|
+
|
|
8
|
+

|
|
9
|
+
[](https://weblate.iobroker.net/engage/adapters/?utm_source=widget)
|
|
5
10
|
[](https://www.npmjs.com/package/iobroker.hass)
|
|
6
11
|
|
|
12
|
+
**This adapter uses Sentry libraries to automatically report exceptions and code errors to the developers.** For more details and for information how to disable the error reporting see [Sentry-Plugin Documentation](https://github.com/ioBroker/plugin-sentry#plugin-sentry)! Sentry reporting is used starting with js-controller 3.0.
|
|
13
|
+
|
|
7
14
|
|
|
8
15
|
This adapter allows the connecting of Home Assistant to ioBroker.
|
|
9
16
|
|
|
10
17
|
## Usage
|
|
11
18
|
Create a long term token in HASS and use it as PW (copy it also in the repeat field).
|
|
12
19
|
|
|
20
|
+
Then it should read out all attributes for all devices. Services might be controllable (e.g. "turn_on"). To control services you have two options:
|
|
21
|
+
* Set the state with an ack=false value which is not a string (e.g. Boolean true) then it will be triggered also in HASS without additional service data
|
|
22
|
+
* Set the state with an ack=false String value which is a stringified JSON object to call the service and use the JSON object as service data
|
|
23
|
+
|
|
24
|
+
For the last option on a light.turn_off with e.g. `{"transition":10,"flash":"short"}` these two service data details are sent with the call to HASS. The available fields with their data definition can be seen in the JSON definition of the ioBroker object in the native.fields section and would look like the following in the above example:
|
|
25
|
+
|
|
26
|
+
`
|
|
27
|
+
...
|
|
28
|
+
native: {
|
|
29
|
+
"fields": {
|
|
30
|
+
"transition": {
|
|
31
|
+
"name": "Transition",
|
|
32
|
+
"description": "Duration it takes to get to next state.",
|
|
33
|
+
"selector": {
|
|
34
|
+
"number": {
|
|
35
|
+
"min": 0,
|
|
36
|
+
"max": 300,
|
|
37
|
+
"unit_of_measurement": "seconds"
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"flash": {
|
|
42
|
+
"name": "Flash",
|
|
43
|
+
"description": "If the light should flash.",
|
|
44
|
+
"advanced": true,
|
|
45
|
+
"selector": {
|
|
46
|
+
"select": {
|
|
47
|
+
"options": [
|
|
48
|
+
"long",
|
|
49
|
+
"short"
|
|
50
|
+
]
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
"entity_id": "light.mi_control_hub_light",
|
|
56
|
+
"attr": "turn_off",
|
|
57
|
+
"type": "light"
|
|
58
|
+
}
|
|
59
|
+
...
|
|
60
|
+
`
|
|
61
|
+
|
|
62
|
+
For some services like set_speed it is required to call with a JSON object like `{speed: "high"}` in general to provide required values. In this case the field definition look e.g. like:
|
|
63
|
+
|
|
64
|
+
```
|
|
65
|
+
...
|
|
66
|
+
native: {
|
|
67
|
+
"fields": {
|
|
68
|
+
"speed": {
|
|
69
|
+
"name": "Speed",
|
|
70
|
+
"description": "Speed setting.",
|
|
71
|
+
"required": true,
|
|
72
|
+
"example": "low",
|
|
73
|
+
"selector": {
|
|
74
|
+
"text": null
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
...
|
|
79
|
+
}
|
|
80
|
+
...
|
|
81
|
+
```
|
|
82
|
+
|
|
13
83
|
## Configuration
|
|
14
84
|
There is a good article about connection.
|
|
15
85
|
|
|
@@ -23,6 +93,17 @@ Please check it https://www.smarthomejetzt.de/mit-iobroker-auf-eine-home-assista
|
|
|
23
93
|
-->
|
|
24
94
|
|
|
25
95
|
## Changelog
|
|
96
|
+
### 1.1.2 (2022-03-29)
|
|
97
|
+
* (Apollon77) Fix crash cases reported by Sentry
|
|
98
|
+
|
|
99
|
+
### 1.1.1 (2022-03-25)
|
|
100
|
+
* (Apollon77) Show password fields masked again in config
|
|
101
|
+
|
|
102
|
+
### 1.1.0 (2022-03-24)
|
|
103
|
+
* IMPORTANT: You need to re-enter the password once after installing this version!
|
|
104
|
+
* (Apollon77) Implement Service triggers to use any value to trigger or stringified JSON to call with fields
|
|
105
|
+
* (Apollon77) Optimize unload handling
|
|
106
|
+
* (Apollon7) Add Sentry for crash reporting
|
|
26
107
|
|
|
27
108
|
### 1.0.1 (2021-09-04)
|
|
28
109
|
* IMPORTANT: js-controller 2.0 is needed st least!
|
|
@@ -38,7 +119,7 @@ Please check it https://www.smarthomejetzt.de/mit-iobroker-auf-eine-home-assista
|
|
|
38
119
|
## License
|
|
39
120
|
The MIT License (MIT)
|
|
40
121
|
|
|
41
|
-
Copyright (c) 2018-
|
|
122
|
+
Copyright (c) 2018-2022 bluefox <dogafox@gmail.com>
|
|
42
123
|
|
|
43
124
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
44
125
|
of this software and associated documentation files (the "Software"), to deal
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
{
|
|
2
|
+
"Home assistant IP:": "IP-Adresse des Heimassistenten:",
|
|
3
|
+
"Home assistant WS Port:": "Home Assistant WS-Port:",
|
|
4
|
+
"Password repeat:": "Passwort wiederholen:",
|
|
5
|
+
"Password:": "Passwort:",
|
|
6
|
+
"Passwords missmatch!": "Passwörter stimmen nicht überein!",
|
|
7
|
+
"Secure:": "HTTPS?"
|
|
8
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
{
|
|
2
|
+
"Home assistant IP:": "IP del asistente de hogar:",
|
|
3
|
+
"Home assistant WS Port:": "Asistente doméstico Puerto WS:",
|
|
4
|
+
"Password repeat:": "Repite la contraseña:",
|
|
5
|
+
"Password:": "Clave:",
|
|
6
|
+
"Passwords missmatch!": "¡Las contraseñas no coinciden!",
|
|
7
|
+
"Secure:": "¿HTTPS?:"
|
|
8
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
{
|
|
2
|
+
"Home assistant IP:": "IP de l'assistant à domicile :",
|
|
3
|
+
"Home assistant WS Port:": "Port WS de l'assistant domestique :",
|
|
4
|
+
"Password repeat:": "Répéter le mot de passe :",
|
|
5
|
+
"Password:": "Mot de passe:",
|
|
6
|
+
"Passwords missmatch!": "Les mots de passe ne correspondent pas !",
|
|
7
|
+
"Secure:": "HTTPS ?"
|
|
8
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
{
|
|
2
|
+
"Home assistant IP:": "IP assistente domestico:",
|
|
3
|
+
"Home assistant WS Port:": "Porta WS dell'assistente domestico:",
|
|
4
|
+
"Password repeat:": "Ripeti password:",
|
|
5
|
+
"Password:": "Parola d'ordine:",
|
|
6
|
+
"Passwords missmatch!": "Le password non corrispondono!",
|
|
7
|
+
"Secure:": "HTTPS?"
|
|
8
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
{
|
|
2
|
+
"Home assistant IP:": "Thuisassistent IP:",
|
|
3
|
+
"Home assistant WS Port:": "Thuisassistent WS Poort:",
|
|
4
|
+
"Password repeat:": "Wachtwoord herhalen:",
|
|
5
|
+
"Password:": "Wachtwoord:",
|
|
6
|
+
"Passwords missmatch!": "Wachtwoorden komen niet overeen!",
|
|
7
|
+
"Secure:": "HTTPS?"
|
|
8
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
{
|
|
2
|
+
"Home assistant IP:": "IP do assistente doméstico:",
|
|
3
|
+
"Home assistant WS Port:": "Assistente doméstico Porta WS:",
|
|
4
|
+
"Password repeat:": "Repetição de senha:",
|
|
5
|
+
"Password:": "Senha:",
|
|
6
|
+
"Passwords missmatch!": "As senhas não correspondem!",
|
|
7
|
+
"Secure:": "HTTPS?"
|
|
8
|
+
}
|
package/admin/index_m.html
CHANGED
|
@@ -1,75 +1,108 @@
|
|
|
1
|
-
<html>
|
|
2
|
-
<head>
|
|
3
|
-
|
|
4
|
-
<link rel="stylesheet" type="text/css" href="../../css/adapter.css"/>
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
<script type="text/javascript" src="../../
|
|
8
|
-
<script type="text/javascript" src="../../
|
|
9
|
-
|
|
10
|
-
<script type="text/javascript" src="../../js/
|
|
11
|
-
<script type="text/javascript" src="
|
|
12
|
-
|
|
13
|
-
<script type="text/javascript">
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
if (settings
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
onChange();
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
obj[$this.attr('id')] = $this.
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
<
|
|
67
|
-
<
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
1
|
+
<html>
|
|
2
|
+
<head>
|
|
3
|
+
<!-- Materialze style -->
|
|
4
|
+
<link rel="stylesheet" type="text/css" href="../../css/adapter.css"/>
|
|
5
|
+
<link rel="stylesheet" type="text/css" href="../../lib/css/materialize.css">
|
|
6
|
+
|
|
7
|
+
<script type="text/javascript" src="../../lib/js/jquery-3.2.1.min.js"></script>
|
|
8
|
+
<script type="text/javascript" src="../../socket.io/socket.io.js"></script>
|
|
9
|
+
|
|
10
|
+
<script type="text/javascript" src="../../js/translate.js"></script>
|
|
11
|
+
<script type="text/javascript" src="../../lib/js/materialize.js"></script>
|
|
12
|
+
<script type="text/javascript" src="../../js/adapter-settings.js"></script>
|
|
13
|
+
<script type="text/javascript" src="words.js"></script>
|
|
14
|
+
|
|
15
|
+
<script type="text/javascript">
|
|
16
|
+
|
|
17
|
+
function load(settings, onChange) {
|
|
18
|
+
if (!settings) return;
|
|
19
|
+
|
|
20
|
+
if (settings.password === undefined) settings.password = '';
|
|
21
|
+
settings.passwordRepeat = settings.password;
|
|
22
|
+
|
|
23
|
+
$('.value').each(function () {
|
|
24
|
+
var key = $(this).attr('id');
|
|
25
|
+
var $value = $('#' + key + '.value');
|
|
26
|
+
if ($value.attr('type') === 'checkbox') {
|
|
27
|
+
$value.prop('checked', settings[key]).change(function() {
|
|
28
|
+
onChange();
|
|
29
|
+
});
|
|
30
|
+
} else {
|
|
31
|
+
$value.val(settings[key]).change(function() {
|
|
32
|
+
onChange();
|
|
33
|
+
}).keyup(function() {
|
|
34
|
+
onChange();
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
// Signal to admin, that no changes yet
|
|
39
|
+
onChange(false);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function save(callback) {
|
|
43
|
+
var obj = {};
|
|
44
|
+
|
|
45
|
+
if ($('#password').val() !== $('#passwordRepeat').val()) {
|
|
46
|
+
showMessage(_('Passwords missmatch!'), _('Warning'), 'alert');
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
$('.value').each(function () {
|
|
51
|
+
var $this = $(this);
|
|
52
|
+
if ($this.attr('type') === 'checkbox') {
|
|
53
|
+
obj[$this.attr('id')] = $this.prop('checked');
|
|
54
|
+
} else {
|
|
55
|
+
obj[$this.attr('id')] = $this.val();
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
delete obj.passwordRepeat;
|
|
59
|
+
|
|
60
|
+
callback(obj);
|
|
61
|
+
}
|
|
62
|
+
</script>
|
|
63
|
+
</head>
|
|
64
|
+
<body>
|
|
65
|
+
<div class="m adapter-container">
|
|
66
|
+
<div class="row">
|
|
67
|
+
<div class="col s12 m4 l2">
|
|
68
|
+
<img src="hass.png" class="logo">
|
|
69
|
+
</div>
|
|
70
|
+
</div>
|
|
71
|
+
|
|
72
|
+
<div class="row">
|
|
73
|
+
<div class="col s12 m8 l8">
|
|
74
|
+
<div class="col s4 input-field">
|
|
75
|
+
<input type="text" class="value" id="host" />
|
|
76
|
+
<label for="host" class="translate">Home assistant IP:</label>
|
|
77
|
+
</div>
|
|
78
|
+
<div class="col s4 input-field">
|
|
79
|
+
<input type="text" class="value" id="port" size="5" maxlength="5"/>
|
|
80
|
+
<label for="port" class="translate">Home assistant WS Port:</label>
|
|
81
|
+
</div>
|
|
82
|
+
</div>
|
|
83
|
+
</div>
|
|
84
|
+
|
|
85
|
+
<div class="row">
|
|
86
|
+
<div class="col s12 m8 l8">
|
|
87
|
+
<div class="col s6 m4 input-field">
|
|
88
|
+
<input type="password" class="value" id="password" />
|
|
89
|
+
<label for="password" class="translate">Password:</label>
|
|
90
|
+
</div>
|
|
91
|
+
<div class="col s6 m4 input-field">
|
|
92
|
+
<input type="password" class="value" id="passwordRepeat" />
|
|
93
|
+
<label for="passwordRepeat" class="translate">Password repeat:</label>
|
|
94
|
+
</div>
|
|
95
|
+
</div>
|
|
96
|
+
</div>
|
|
97
|
+
|
|
98
|
+
<div class="row">
|
|
99
|
+
<div class="col s12 m8 l8">
|
|
100
|
+
<div class="col s6 m4 input-field">
|
|
101
|
+
<input id="secure" type="checkbox" class="value" />
|
|
102
|
+
<span for="secure" class="translate">Secure:</span>
|
|
103
|
+
</div>
|
|
104
|
+
</div>
|
|
105
|
+
</div>
|
|
106
|
+
</div>
|
|
107
|
+
</body>
|
|
108
|
+
</html>
|
package/admin/words.js
CHANGED
|
@@ -1,19 +1,11 @@
|
|
|
1
|
+
/*global systemDictionary:true */
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
1
4
|
systemDictionary = {
|
|
2
|
-
"
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"Password:":
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
|
|
9
|
-
"tooltip_password": {
|
|
10
|
-
"en": "Optional. Only if FHEM requires password.",
|
|
11
|
-
"de": "Optional. Nur falls in FHEM konfiguriert",
|
|
12
|
-
"ru": "Не обязательно. Только если настроено в FHEM"
|
|
13
|
-
},
|
|
14
|
-
"tooltip_prompt": {
|
|
15
|
-
"en": "You can change standard prompt from 'hass>' to something else.",
|
|
16
|
-
"de": "Man kann hier ein eigenes Prompt setzen. Default ist 'hass>'",
|
|
17
|
-
"ru": "Можно задать собственный промпт. По умолчанию 'hass>'"
|
|
18
|
-
}
|
|
19
|
-
};
|
|
5
|
+
"Home assistant IP:": { "en": "Home assistant IP:", "de": "IP-Adresse des Heimassistenten:", "ru": "Домашний помощник IP:", "pt": "IP do assistente doméstico:", "nl": "Thuisassistent IP:", "fr": "IP de l'assistant à domicile :", "it": "IP assistente domestico:", "es": "IP del asistente de hogar:", "pl": "Adres IP asystenta domowego:", "zh-cn": "家庭助理IP:"},
|
|
6
|
+
"Home assistant WS Port:": { "en": "Home assistant WS Port:", "de": "Home Assistant WS-Port:", "ru": "Домашний помощник WS Порт:", "pt": "Assistente doméstico Porta WS:", "nl": "Thuisassistent WS Poort:", "fr": "Port WS de l'assistant domestique :", "it": "Porta WS dell'assistente domestico:", "es": "Asistente doméstico Puerto WS:", "pl": "Asystent domowy Port WS:", "zh-cn": "家庭助理 WS 端口:"},
|
|
7
|
+
"Password repeat:": { "en": "Password repeat:", "de": "Passwort wiederholen:", "ru": "Повтор пароля:", "pt": "Repetição de senha:", "nl": "Wachtwoord herhalen:", "fr": "Répéter le mot de passe :", "it": "Ripeti password:", "es": "Repite la contraseña:", "pl": "Powtórz hasło:", "zh-cn": "密码重复:"},
|
|
8
|
+
"Password:": { "en": "Password:", "de": "Passwort:", "ru": "Пароль:", "pt": "Senha:", "nl": "Wachtwoord:", "fr": "Mot de passe:", "it": "Parola d'ordine:", "es": "Clave:", "pl": "Hasło:", "zh-cn": "密码:"},
|
|
9
|
+
"Passwords missmatch!": { "en": "Passwords missmatch!", "de": "Passwörter stimmen nicht überein!", "ru": "Пароли не совпадают!", "pt": "As senhas não correspondem!", "nl": "Wachtwoorden komen niet overeen!", "fr": "Les mots de passe ne correspondent pas !", "it": "Le password non corrispondono!", "es": "¡Las contraseñas no coinciden!", "pl": "Niezgodność haseł!", "zh-cn": "密码不匹配!"},
|
|
10
|
+
"Secure:": { "en": "HTTPS?", "de": "HTTPS?", "ru": "HTTPS?", "pt": "HTTPS?", "nl": "HTTPS?", "fr": "HTTPS ?", "it": "HTTPS?", "es": "¿HTTPS?", "pl": "HTTPS?", "zh-cn": "HTTPS?"},
|
|
11
|
+
};
|
package/io-package.json
CHANGED
|
@@ -1,133 +1,227 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
"news": {
|
|
30
|
-
"1.0.1": {
|
|
31
|
-
"en": "IMPORTANT: js-controller 2.0 is needed st least!\nFix start issue\n(Apollon77/Garfonso) Fix issue where value could not be set in hass",
|
|
32
|
-
"de": "WICHTIG: js-controller 2.0 wird am wenigsten benötigt!\nStartproblem beheben\n(Apollon77/Garfonso) Problem behoben, bei dem der Wert nicht in Hass festgelegt werden konnte",
|
|
33
|
-
"ru": "ВАЖНО: js-controller 2.0 нужен как минимум!\nИсправить проблему с запуском\n(Apollon77 / Garfonso) Исправлена ошибка, из-за которой значение не могло быть установлено в hass.",
|
|
34
|
-
"pt": "IMPORTANTE: o js-controller 2.0 é o mínimo necessário!\nCorrigir problema inicial\n(Apollon77 / Garfonso) Correção do problema em que o valor não podia ser definido em hass",
|
|
35
|
-
"nl": "BELANGRIJK: js-controller 2.0 is minimaal nodig!\nStartprobleem oplossen\n(Apollon77/Garfonso) Probleem opgelost waarbij de waarde niet kon worden ingesteld in hass",
|
|
36
|
-
"fr": "IMPORTANT : js-controller 2.0 est au moins nécessaire !\nRésoudre le problème de démarrage\n(Apollon77/Garfonso) Correction d'un problème où la valeur ne pouvait pas être définie dans hass",
|
|
37
|
-
"it": "IMPORTANTE: come minimo è necessario js-controller 2.0!\nRisolvi il problema di avvio\n(Apollon77/Garfonso) Risolto il problema per cui il valore non poteva essere impostato in hass",
|
|
38
|
-
"es": "IMPORTANTE: ¡js-controller 2.0 es lo menos necesario!\nSolucionar problema de inicio\n(Apollon77 / Garfonso) Se solucionó el problema por el cual no se podía establecer el valor en hass",
|
|
39
|
-
"pl": "WAŻNE: js-controller 2.0 jest potrzebny przynajmniej!\nNapraw problem z uruchomieniem\n(Apollon77/Garfonso) Napraw problem, w którym nie można było ustawić wartości w hass",
|
|
40
|
-
"zh-cn": "重要提示:至少需要 js-controller 2.0!\n修复启动问题\n(Apollon77/Garfonso) 修复无法在 hass 中设置值的问题"
|
|
41
|
-
},
|
|
42
|
-
"1.0.0": {
|
|
43
|
-
"en": "added the support of compact mode",
|
|
44
|
-
"de": "fügte die Unterstützung des Kompaktmodus hinzu",
|
|
45
|
-
"ru": "добавлена поддержка компактного режима",
|
|
46
|
-
"pt": "adicionado o suporte do modo compacto",
|
|
47
|
-
"nl": "de ondersteuning van de compacte modus toegevoegd",
|
|
48
|
-
"fr": "ajouté le support du mode compact",
|
|
49
|
-
"it": "aggiunto il supporto della modalità compatta",
|
|
50
|
-
"es": "agregó el soporte del modo compacto",
|
|
51
|
-
"pl": "dodano obsługę trybu kompaktowego",
|
|
52
|
-
"zh-cn": "增加了对紧凑模式的支持"
|
|
53
|
-
},
|
|
54
|
-
"0.1.0": {
|
|
55
|
-
"en": "initial version",
|
|
56
|
-
"de": "erste Version",
|
|
57
|
-
"ru": "Первоначальная версия",
|
|
58
|
-
"pt": "versão inicial",
|
|
59
|
-
"nl": "eerste versie",
|
|
60
|
-
"fr": "version initiale",
|
|
61
|
-
"it": "versione iniziale",
|
|
62
|
-
"es": "versión inicial",
|
|
63
|
-
"pl": "początkowa wersja"
|
|
64
|
-
}
|
|
65
|
-
},
|
|
66
|
-
"localLink": "http://%host%:8123",
|
|
67
|
-
"platform": "Javascript/Node.js",
|
|
68
|
-
"mode": "daemon",
|
|
69
|
-
"icon": "hass.png",
|
|
70
|
-
"enabled": true,
|
|
71
|
-
"compact": true,
|
|
72
|
-
"materialize": true,
|
|
73
|
-
"license": "MIT",
|
|
74
|
-
"extIcon": "https://raw.githubusercontent.com/ioBroker/ioBroker.hass/master/admin/hass.png",
|
|
75
|
-
"keywords": [
|
|
76
|
-
"HASS",
|
|
77
|
-
"Home",
|
|
78
|
-
"assistant"
|
|
79
|
-
],
|
|
80
|
-
"readme": "https://github.com/ioBroker/ioBroker.hass/blob/master/README.md",
|
|
81
|
-
"loglevel": "info",
|
|
82
|
-
"type": "iot-systems",
|
|
83
|
-
"authors": [
|
|
84
|
-
"bluefox <dogafox@gmail.com>"
|
|
85
|
-
],
|
|
86
|
-
"dependencies": [
|
|
87
|
-
{
|
|
88
|
-
"js-controller": ">=2.0.0"
|
|
89
|
-
}
|
|
90
|
-
],
|
|
91
|
-
"connectionType": "local",
|
|
92
|
-
"dataSource": "push",
|
|
93
|
-
"tier": 2
|
|
2
|
+
"common": {
|
|
3
|
+
"name": "hass",
|
|
4
|
+
"version": "1.1.2",
|
|
5
|
+
"title": "Home Assistant",
|
|
6
|
+
"titleLang": {
|
|
7
|
+
"en": "Home Assistant",
|
|
8
|
+
"de": "Home-Assistent",
|
|
9
|
+
"ru": "Домашний помощник",
|
|
10
|
+
"pt": "Home Assistant",
|
|
11
|
+
"nl": "Thuisassistent",
|
|
12
|
+
"fr": "Assistante à domicile",
|
|
13
|
+
"it": "Assistente domiciliare",
|
|
14
|
+
"es": "Asistente de hogar",
|
|
15
|
+
"pl": "Asystent domowy",
|
|
16
|
+
"zh-cn": "家庭助理"
|
|
17
|
+
},
|
|
18
|
+
"desc": {
|
|
19
|
+
"en": "Home Assistant connection for ioBroker",
|
|
20
|
+
"de": "Home Assistant Verbindung für ioBroker",
|
|
21
|
+
"ru": "Подключение Home Assistant для ioBroker",
|
|
22
|
+
"pt": "Conexão do Home Assistant para ioBroker",
|
|
23
|
+
"nl": "Home Assistant-verbinding voor ioBroker",
|
|
24
|
+
"fr": "Connexion Home Assistant pour ioBroker",
|
|
25
|
+
"it": "Connessione Home Assistant per ioBroker",
|
|
26
|
+
"es": "Conexión de Home Assistant para ioBroker",
|
|
27
|
+
"pl": "Połączenie Home Assistant dla ioBroker",
|
|
28
|
+
"zh-cn": "ioBroker 的家庭助理连接"
|
|
94
29
|
},
|
|
95
|
-
"
|
|
96
|
-
|
|
97
|
-
"
|
|
98
|
-
"
|
|
99
|
-
"
|
|
30
|
+
"news": {
|
|
31
|
+
"1.1.2": {
|
|
32
|
+
"en": "Fix crash cases reported by Sentry",
|
|
33
|
+
"de": "Von Sentry gemeldete Absturzfälle beheben",
|
|
34
|
+
"ru": "Исправить случаи сбоев, о которых сообщил Sentry",
|
|
35
|
+
"pt": "Corrigir casos de travamento relatados pelo Sentinela",
|
|
36
|
+
"nl": "Herstel crashgevallen gemeld door Sentry",
|
|
37
|
+
"fr": "Correction des cas de plantage signalés par Sentry",
|
|
38
|
+
"it": "Risolvi i casi di crash segnalati da Sentry",
|
|
39
|
+
"es": "Solucionar casos de fallas informados por Sentry",
|
|
40
|
+
"pl": "Napraw przypadki awarii zgłoszone przez Sentry",
|
|
41
|
+
"zh-cn": "修复 Sentry 报告的崩溃案例"
|
|
42
|
+
},
|
|
43
|
+
"1.1.1": {
|
|
44
|
+
"en": "Show password fields masked again in config",
|
|
45
|
+
"de": "Passwortfelder in config wieder maskiert anzeigen",
|
|
46
|
+
"ru": "Показать поля пароля снова замаскированные в конфигурации",
|
|
47
|
+
"pt": "Mostrar campos de senha mascarados novamente na configuração",
|
|
48
|
+
"nl": "Toon wachtwoordvelden opnieuw gemaskeerd in config",
|
|
49
|
+
"fr": "Afficher à nouveau les champs de mot de passe masqués dans la configuration",
|
|
50
|
+
"it": "Mostra i campi password mascherati di nuovo in config",
|
|
51
|
+
"es": "Mostrar campos de contraseña enmascarados nuevamente en la configuración",
|
|
52
|
+
"pl": "Pokaż ponownie zamaskowane pola haseł w konfiguracji",
|
|
53
|
+
"zh-cn": "在配置中再次显示被屏蔽的密码字段"
|
|
54
|
+
},
|
|
55
|
+
"1.1.0": {
|
|
56
|
+
"en": "IMPORTANT: You need to re-enter the password once after installing this version!\nImplement Service triggers to use any value to trigger or stringified JSON to call with fields\nOptimize unload handling\nAdd Sentry for crash reporting",
|
|
57
|
+
"de": "WICHTIG: Nach der Installation dieser Version müssen Sie das Passwort einmalig neu eingeben!\nImplementieren Sie Dienstauslöser, um einen beliebigen Wert zum Auslösen oder stringifiziertes JSON zum Aufrufen mit Feldern zu verwenden\nEntladehandling optimieren\nFügen Sie Sentry für Absturzberichte hinzu",
|
|
58
|
+
"ru": "ВАЖНО: Вам необходимо повторно ввести пароль один раз после установки этой версии!\nРеализовать триггеры службы, чтобы использовать любое значение для запуска или строкового JSON для вызова с полями.\nОптимизация обработки разгрузки\nДобавьте Sentry для отчетов о сбоях",
|
|
59
|
+
"pt": "IMPORTANTE: Você precisa redigitar a senha uma vez depois de instalar esta versão!\nImplemente gatilhos de serviço para usar qualquer valor para acionar ou JSON stringified para chamar com campos\nOtimize o manuseio de descarga\nAdicionar Sentinela para relatórios de falhas",
|
|
60
|
+
"nl": "BELANGRIJK: u moet het wachtwoord één keer opnieuw invoeren na het installeren van deze versie!\nImplementeer servicetriggers om elke waarde te gebruiken om te activeren of stringified JSON om met velden aan te roepen\nOptimaliseer de losverwerking\nSentry toevoegen voor crashrapportage",
|
|
61
|
+
"fr": "IMPORTANT : Vous devez ressaisir le mot de passe une fois après l'installation de cette version !\nImplémentez des déclencheurs de service pour utiliser n'importe quelle valeur pour déclencher ou JSON stringifié pour appeler avec des champs\nOptimiser la gestion des déchargements\nAjouter Sentry pour les rapports de plantage",
|
|
62
|
+
"it": "IMPORTANTE: è necessario reinserire la password una volta dopo aver installato questa versione!\nImplementa i trigger del servizio per utilizzare qualsiasi valore per attivare o JSON in formato stringa per chiamare con i campi\nOttimizza la gestione dello scarico\nAggiungi Sentinella per la segnalazione degli arresti anomali",
|
|
63
|
+
"es": "IMPORTANTE: ¡Debe volver a ingresar la contraseña una vez después de instalar esta versión!\nImplementar disparadores de servicio para usar cualquier valor para disparar o JSON en cadena para llamar con campos\nOptimizar el manejo de descarga\nAgregar Sentry para informes de fallas",
|
|
64
|
+
"pl": "WAŻNE: Po zainstalowaniu tej wersji należy raz ponownie wprowadzić hasło!\nZaimplementuj wyzwalacze usługi, aby używać dowolnej wartości do wyzwalania lub skróconego JSON do wywołania z polami\nZoptymalizuj obsługę rozładunku\nDodaj Sentry do zgłaszania awarii",
|
|
65
|
+
"zh-cn": "重要提示:安装此版本后需要重新输入一次密码!\n实现服务触发器以使用任何值触发或字符串化 JSON 以使用字段调用\n优化卸载处理\n添加 Sentry 以进行崩溃报告"
|
|
66
|
+
},
|
|
67
|
+
"1.0.1": {
|
|
68
|
+
"en": "IMPORTANT: js-controller 2.0 is needed st least!\nFix start issue\n(Apollon77/Garfonso) Fix issue where value could not be set in hass",
|
|
69
|
+
"de": "WICHTIG: js-controller 2.0 wird am wenigsten benötigt!\nStartproblem beheben\n(Apollon77/Garfonso) Problem behoben, bei dem der Wert nicht in Hass festgelegt werden konnte",
|
|
70
|
+
"ru": "ВАЖНО: js-controller 2.0 нужен как минимум!\nИсправить проблему с запуском\n(Apollon77 / Garfonso) Исправлена ошибка, из-за которой значение не могло быть установлено в hass.",
|
|
71
|
+
"pt": "IMPORTANTE: o js-controller 2.0 é o mínimo necessário!\nCorrigir problema inicial\n(Apollon77 / Garfonso) Correção do problema em que o valor não podia ser definido em hass",
|
|
72
|
+
"nl": "BELANGRIJK: js-controller 2.0 is minimaal nodig!\nStartprobleem oplossen\n(Apollon77/Garfonso) Probleem opgelost waarbij de waarde niet kon worden ingesteld in hass",
|
|
73
|
+
"fr": "IMPORTANT : js-controller 2.0 est au moins nécessaire !\nRésoudre le problème de démarrage\n(Apollon77/Garfonso) Correction d'un problème où la valeur ne pouvait pas être définie dans hass",
|
|
74
|
+
"it": "IMPORTANTE: come minimo è necessario js-controller 2.0!\nRisolvi il problema di avvio\n(Apollon77/Garfonso) Risolto il problema per cui il valore non poteva essere impostato in hass",
|
|
75
|
+
"es": "IMPORTANTE: ¡js-controller 2.0 es lo menos necesario!\nSolucionar problema de inicio\n(Apollon77 / Garfonso) Se solucionó el problema por el cual no se podía establecer el valor en hass",
|
|
76
|
+
"pl": "WAŻNE: js-controller 2.0 jest potrzebny przynajmniej!\nNapraw problem z uruchomieniem\n(Apollon77/Garfonso) Napraw problem, w którym nie można było ustawić wartości w hass",
|
|
77
|
+
"zh-cn": "重要提示:至少需要 js-controller 2.0!\n修复启动问题\n(Apollon77/Garfonso) 修复无法在 hass 中设置值的问题"
|
|
78
|
+
},
|
|
79
|
+
"1.0.0": {
|
|
80
|
+
"en": "added the support of compact mode",
|
|
81
|
+
"de": "fügte die Unterstützung des Kompaktmodus hinzu",
|
|
82
|
+
"ru": "добавлена поддержка компактного режима",
|
|
83
|
+
"pt": "adicionado o suporte do modo compacto",
|
|
84
|
+
"nl": "de ondersteuning van de compacte modus toegevoegd",
|
|
85
|
+
"fr": "ajouté le support du mode compact",
|
|
86
|
+
"it": "aggiunto il supporto della modalità compatta",
|
|
87
|
+
"es": "agregó el soporte del modo compacto",
|
|
88
|
+
"pl": "dodano obsługę trybu kompaktowego",
|
|
89
|
+
"zh-cn": "增加了对紧凑模式的支持"
|
|
90
|
+
},
|
|
91
|
+
"0.1.0": {
|
|
92
|
+
"en": "initial version",
|
|
93
|
+
"de": "erste Version",
|
|
94
|
+
"ru": "Первоначальная версия",
|
|
95
|
+
"pt": "versão inicial",
|
|
96
|
+
"nl": "eerste versie",
|
|
97
|
+
"fr": "version initiale",
|
|
98
|
+
"it": "versione iniziale",
|
|
99
|
+
"es": "versión inicial",
|
|
100
|
+
"pl": "początkowa wersja",
|
|
101
|
+
"zh-cn": "初始版本"
|
|
102
|
+
}
|
|
100
103
|
},
|
|
101
|
-
"
|
|
102
|
-
"
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
104
|
+
"localLink": "http://%host%:8123",
|
|
105
|
+
"platform": "Javascript/Node.js",
|
|
106
|
+
"mode": "daemon",
|
|
107
|
+
"icon": "hass.png",
|
|
108
|
+
"enabled": true,
|
|
109
|
+
"compact": true,
|
|
110
|
+
"materialize": true,
|
|
111
|
+
"license": "MIT",
|
|
112
|
+
"extIcon": "https://raw.githubusercontent.com/ioBroker/ioBroker.hass/master/admin/hass.png",
|
|
113
|
+
"keywords": [
|
|
114
|
+
"HASS",
|
|
115
|
+
"Home",
|
|
116
|
+
"assistant"
|
|
117
|
+
],
|
|
118
|
+
"readme": "https://github.com/ioBroker/ioBroker.hass/blob/master/README.md",
|
|
119
|
+
"loglevel": "info",
|
|
120
|
+
"type": "iot-systems",
|
|
121
|
+
"authors": [
|
|
122
|
+
"bluefox <dogafox@gmail.com>"
|
|
123
|
+
],
|
|
124
|
+
"dependencies": [
|
|
125
|
+
{
|
|
126
|
+
"js-controller": ">=3.0.0"
|
|
127
|
+
}
|
|
128
|
+
],
|
|
129
|
+
"globalDependencies": [
|
|
130
|
+
{
|
|
131
|
+
"admin": ">=5.1.28"
|
|
132
|
+
}
|
|
133
|
+
],
|
|
134
|
+
"plugins": {
|
|
135
|
+
"sentry": {
|
|
136
|
+
"dsn": "https://1b2a1e8335f84cc49a67dd5ac2b07573@sentry.iobroker.net/182"
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
"connectionType": "local",
|
|
140
|
+
"dataSource": "push",
|
|
141
|
+
"tier": 2,
|
|
142
|
+
"messages": [
|
|
143
|
+
{
|
|
144
|
+
"condition": {
|
|
145
|
+
"operand": "and",
|
|
146
|
+
"rules": [
|
|
147
|
+
"oldVersion<1.1.0",
|
|
148
|
+
"newVersion>=1.1.0"
|
|
149
|
+
]
|
|
150
|
+
},
|
|
151
|
+
"title": {
|
|
152
|
+
"en": "Re-enter the password after Update!",
|
|
153
|
+
"de": "Passwort muss nach dem Update erneut eingegeben werden!",
|
|
154
|
+
"ru": "Повторно введите пароль после обновления!",
|
|
155
|
+
"pt": "Digite novamente a senha após Atualizar!",
|
|
156
|
+
"nl": "Voer het wachtwoord opnieuw in na Update!",
|
|
157
|
+
"fr": "Entrez à nouveau le mot de passe après la mise à jour !",
|
|
158
|
+
"it": "Reinserire la password dopo l'aggiornamento!",
|
|
159
|
+
"es": "Vuelva a ingresar la contraseña después de ¡Actualizar!",
|
|
160
|
+
"pl": "Wprowadź hasło ponownie po aktualizacji!",
|
|
161
|
+
"zh-cn": "更新后重新输入密码!"
|
|
110
162
|
},
|
|
111
|
-
{
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
"native": {}
|
|
163
|
+
"text": {
|
|
164
|
+
"en": "After installing this update the password/token used to access the HASS installation needs to be re-entered in the Instance-Settings!",
|
|
165
|
+
"de": "Nach der Installation dieses Updates muss das Passwort/Token für den Zugriff auf die HASS-Installation in den Instanz-Einstellungen erneut eingegeben werden!",
|
|
166
|
+
"ru": "После установки этого обновления пароль/токен, используемый для доступа к установке HASS, необходимо повторно ввести в настройках экземпляра!",
|
|
167
|
+
"pt": "Depois de instalar esta atualização, a senha/token usado para acessar a instalação do HASS precisa ser reinserido nas configurações da instância!",
|
|
168
|
+
"nl": "Na het installeren van deze update moet het wachtwoord/token dat wordt gebruikt om toegang te krijgen tot de HASS-installatie opnieuw worden ingevoerd in de Instance-Settings!",
|
|
169
|
+
"fr": "Après l'installation de cette mise à jour, le mot de passe/jeton utilisé pour accéder à l'installation HASS doit être ressaisi dans les paramètres d'instance !",
|
|
170
|
+
"it": "Dopo aver installato questo aggiornamento, la password/token utilizzato per accedere all'installazione HASS deve essere reinserito nelle impostazioni dell'istanza!",
|
|
171
|
+
"es": "¡Después de instalar esta actualización, la contraseña/token utilizada para acceder a la instalación de HASS debe volver a ingresarse en la configuración de la instancia!",
|
|
172
|
+
"pl": "Po zainstalowaniu tej aktualizacji hasło/token używane do uzyskania dostępu do instalacji HASS należy ponownie wprowadzić w ustawieniach instancji!",
|
|
173
|
+
"zh-cn": "安装此更新后,用于访问 HASS 安装的密码/令牌需要在实例设置中重新输入!"
|
|
123
174
|
},
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
"native": {}
|
|
131
|
-
}
|
|
175
|
+
"level": "warn",
|
|
176
|
+
"buttons": [
|
|
177
|
+
"agree",
|
|
178
|
+
"cancel"
|
|
179
|
+
]
|
|
180
|
+
}
|
|
132
181
|
]
|
|
133
|
-
}
|
|
182
|
+
},
|
|
183
|
+
"native": {
|
|
184
|
+
"host": "127.0.0.1",
|
|
185
|
+
"port": 8123,
|
|
186
|
+
"password": "",
|
|
187
|
+
"secure": false
|
|
188
|
+
},
|
|
189
|
+
"protectedNative": [
|
|
190
|
+
"password"
|
|
191
|
+
],
|
|
192
|
+
"encryptedNative": [
|
|
193
|
+
"password"
|
|
194
|
+
],
|
|
195
|
+
"objects": [],
|
|
196
|
+
"instanceObjects": [
|
|
197
|
+
{
|
|
198
|
+
"_id": "info",
|
|
199
|
+
"type": "channel",
|
|
200
|
+
"common": {
|
|
201
|
+
"name": "Information"
|
|
202
|
+
},
|
|
203
|
+
"native": {}
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
"_id": "info.connection",
|
|
207
|
+
"type": "state",
|
|
208
|
+
"common": {
|
|
209
|
+
"role": "indicator.connected",
|
|
210
|
+
"name": "If connected to HASS server",
|
|
211
|
+
"type": "boolean",
|
|
212
|
+
"read": true,
|
|
213
|
+
"write": false,
|
|
214
|
+
"def": false
|
|
215
|
+
},
|
|
216
|
+
"native": {}
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
"_id": "entities",
|
|
220
|
+
"type": "channel",
|
|
221
|
+
"common": {
|
|
222
|
+
"name": "HASS entities"
|
|
223
|
+
},
|
|
224
|
+
"native": {}
|
|
225
|
+
}
|
|
226
|
+
]
|
|
227
|
+
}
|
package/lib/hass.js
CHANGED
|
@@ -92,7 +92,7 @@ function HASS(options, log) {
|
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
function callService(socket, service, domain, serviceData, callback) {
|
|
95
|
+
function callService(socket, service, domain, serviceData, target, callback) {
|
|
96
96
|
if (socket && typeof socket.send === 'function') {
|
|
97
97
|
const id = currentId++;
|
|
98
98
|
requests[id] = {type: 'call_service', cb: callback, ts: Date.now()};
|
|
@@ -101,7 +101,8 @@ function HASS(options, log) {
|
|
|
101
101
|
type: 'call_service',
|
|
102
102
|
domain: domain || '',
|
|
103
103
|
service: service,
|
|
104
|
-
service_data: serviceData
|
|
104
|
+
service_data: serviceData,
|
|
105
|
+
target
|
|
105
106
|
}));
|
|
106
107
|
} else {
|
|
107
108
|
callback && callback('not connected');
|
|
@@ -228,11 +229,11 @@ function HASS(options, log) {
|
|
|
228
229
|
}
|
|
229
230
|
};
|
|
230
231
|
|
|
231
|
-
this.callService = function (service, domain, serviceData, callback) {
|
|
232
|
+
this.callService = function (service, domain, serviceData, target, callback) {
|
|
232
233
|
if (!connected) {
|
|
233
234
|
typeof callback === 'function' && callback('not connected');
|
|
234
235
|
} else {
|
|
235
|
-
callService(this.socket, service, domain, serviceData, callback);
|
|
236
|
+
callService(this.socket, service, domain, serviceData, target, callback);
|
|
236
237
|
}
|
|
237
238
|
};
|
|
238
239
|
|
package/lib/tools.js
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
const axios = require("axios");
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Tests whether the given variable is a real object and not an Array
|
|
5
|
+
* @param {any} it The variable to test
|
|
6
|
+
* @returns {it is Record<string, any>}
|
|
7
|
+
*/
|
|
8
|
+
function isObject(it) {
|
|
9
|
+
// This is necessary because:
|
|
10
|
+
// typeof null === 'object'
|
|
11
|
+
// typeof [] === 'object'
|
|
12
|
+
// [] instanceof Object === true
|
|
13
|
+
return Object.prototype.toString.call(it) === "[object Object]";
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Tests whether the given variable is really an Array
|
|
18
|
+
* @param {any} it The variable to test
|
|
19
|
+
* @returns {it is any[]}
|
|
20
|
+
*/
|
|
21
|
+
function isArray(it) {
|
|
22
|
+
if (Array.isArray != null)
|
|
23
|
+
return Array.isArray(it);
|
|
24
|
+
return Object.prototype.toString.call(it) === "[object Array]";
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Choose the right tranalation API
|
|
29
|
+
* @param {string} text The text to translate
|
|
30
|
+
* @param {string} targetLang The target languate
|
|
31
|
+
* @param {string} yandex api key
|
|
32
|
+
* @returns {Promise<string>}
|
|
33
|
+
*/
|
|
34
|
+
async function translateText(text, targetLang, yandex) {
|
|
35
|
+
if (targetLang === "en") {
|
|
36
|
+
return text;
|
|
37
|
+
}
|
|
38
|
+
if (yandex) {
|
|
39
|
+
return await translateYandex(text, targetLang, yandex);
|
|
40
|
+
} else {
|
|
41
|
+
return await translateGoogle(text, targetLang);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Translates text with Yandex API
|
|
47
|
+
* @param {string} text The text to translate
|
|
48
|
+
* @param {string} targetLang The target languate
|
|
49
|
+
* @param {string} yandex api key
|
|
50
|
+
* @returns {Promise<string>}
|
|
51
|
+
*/
|
|
52
|
+
async function translateYandex(text, targetLang, yandex) {
|
|
53
|
+
if (targetLang === "zh-cn") {
|
|
54
|
+
targetLang = "zh";
|
|
55
|
+
}
|
|
56
|
+
try {
|
|
57
|
+
const url = `https://translate.yandex.net/api/v1.5/tr.json/translate?key=${yandex}&text=${encodeURIComponent(text)}&lang=en-${targetLang}`;
|
|
58
|
+
const response = await axios({url, timeout: 15000});
|
|
59
|
+
if (response.data && response.data['text']) {
|
|
60
|
+
return response.data['text'][0];
|
|
61
|
+
}
|
|
62
|
+
throw new Error("Invalid response for translate request");
|
|
63
|
+
} catch (e) {
|
|
64
|
+
throw new Error(`Could not translate to "${targetLang}": ${e}`);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Translates text with Google API
|
|
70
|
+
* @param {string} text The text to translate
|
|
71
|
+
* @param {string} targetLang The target languate
|
|
72
|
+
* @returns {Promise<string>}
|
|
73
|
+
*/
|
|
74
|
+
async function translateGoogle(text, targetLang) {
|
|
75
|
+
try {
|
|
76
|
+
const url = `http://translate.googleapis.com/translate_a/single?client=gtx&sl=en&tl=${targetLang}&dt=t&q=${encodeURIComponent(text)}&ie=UTF-8&oe=UTF-8`;
|
|
77
|
+
const response = await axios({url, timeout: 15000});
|
|
78
|
+
if (isArray(response.data)) {
|
|
79
|
+
// we got a valid response
|
|
80
|
+
return response.data[0][0][0];
|
|
81
|
+
}
|
|
82
|
+
throw new Error("Invalid response for translate request");
|
|
83
|
+
} catch (e) {
|
|
84
|
+
throw new Error(`Could not translate to "${targetLang}": ${e}`);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
module.exports = {
|
|
89
|
+
isArray,
|
|
90
|
+
isObject,
|
|
91
|
+
translateText
|
|
92
|
+
};
|
package/main.js
CHANGED
|
@@ -12,6 +12,8 @@ let connected = false;
|
|
|
12
12
|
let hass;
|
|
13
13
|
let adapter;
|
|
14
14
|
const hassObjects = {};
|
|
15
|
+
let delayTimeout = null;
|
|
16
|
+
let stopped = false;
|
|
15
17
|
|
|
16
18
|
function startAdapter(options) {
|
|
17
19
|
options = options || {};
|
|
@@ -35,6 +37,17 @@ function startAdapter(options) {
|
|
|
35
37
|
} else {
|
|
36
38
|
const serviceData = {};
|
|
37
39
|
const fields = hassObjects[id].native.fields;
|
|
40
|
+
const target = {};
|
|
41
|
+
|
|
42
|
+
let requestFields = {};
|
|
43
|
+
if (typeof state.val === 'string') {
|
|
44
|
+
try {
|
|
45
|
+
requestFields = JSON.parse(state.val);
|
|
46
|
+
} catch (err) {
|
|
47
|
+
adapter.log.info(`Ignore data for service call ${id} is no valid JSON: ${err.message}`);
|
|
48
|
+
requestFields = {};
|
|
49
|
+
}
|
|
50
|
+
}
|
|
38
51
|
|
|
39
52
|
for (const field in fields) {
|
|
40
53
|
if (!fields.hasOwnProperty(field)) {
|
|
@@ -42,15 +55,15 @@ function startAdapter(options) {
|
|
|
42
55
|
}
|
|
43
56
|
|
|
44
57
|
if (field === 'entity_id') {
|
|
45
|
-
|
|
46
|
-
} else {
|
|
47
|
-
serviceData[field] =
|
|
58
|
+
target.entity_id = hassObjects[id].native.entity_id
|
|
59
|
+
} else if (requestFields[field] !== undefined) {
|
|
60
|
+
serviceData[field] = requestFields[field];
|
|
48
61
|
}
|
|
49
62
|
}
|
|
50
63
|
serviceData.entity_id = hassObjects[id].native.entity_id
|
|
51
64
|
|
|
52
65
|
adapter.log.debug(`Send to HASS for service ${hassObjects[id].native.attr} with ${hassObjects[id].native.domain || hassObjects[id].native.type} and data ${JSON.stringify(serviceData)}`)
|
|
53
|
-
hass.callService(hassObjects[id].native.attr, hassObjects[id].native.domain || hassObjects[id].native.type, serviceData, err =>
|
|
66
|
+
hass.callService(hassObjects[id].native.attr, hassObjects[id].native.domain || hassObjects[id].native.type, serviceData, target, err =>
|
|
54
67
|
err && adapter.log.error('Cannot control ' + id + ': ' + err));
|
|
55
68
|
}
|
|
56
69
|
}
|
|
@@ -65,6 +78,8 @@ function startAdapter(options) {
|
|
|
65
78
|
}
|
|
66
79
|
|
|
67
80
|
function stop(callback) {
|
|
81
|
+
stopped = true;
|
|
82
|
+
delayTimeout && clearTimeout(delayTimeout);
|
|
68
83
|
hass && hass.close();
|
|
69
84
|
callback && callback();
|
|
70
85
|
}
|
|
@@ -318,7 +333,8 @@ function parseStates(entities, services, callback) {
|
|
|
318
333
|
common: {
|
|
319
334
|
desc: service[s].description,
|
|
320
335
|
read: false,
|
|
321
|
-
write: true
|
|
336
|
+
write: true,
|
|
337
|
+
type: 'mixed'
|
|
322
338
|
},
|
|
323
339
|
native: {
|
|
324
340
|
object_id: entity.object_id,
|
|
@@ -355,6 +371,10 @@ function main() {
|
|
|
355
371
|
|
|
356
372
|
hass.on('state_changed', entity => {
|
|
357
373
|
adapter.log.debug(`HASS-Message: State Changed: ${JSON.stringify(entity)}`);
|
|
374
|
+
if (!entity || typeof entity.entity_id !== 'string') {
|
|
375
|
+
return;
|
|
376
|
+
}
|
|
377
|
+
|
|
358
378
|
const id = adapter.namespace + '.entities.' + entity.entity_id + '.';
|
|
359
379
|
const lc = entity.last_changed ? new Date(entity.last_changed).getTime() : undefined;
|
|
360
380
|
const ts = entity.last_updated ? new Date(entity.last_updated).getTime() : undefined;
|
|
@@ -363,7 +383,7 @@ function main() {
|
|
|
363
383
|
}
|
|
364
384
|
if (entity.attributes) {
|
|
365
385
|
for (const attr in entity.attributes) {
|
|
366
|
-
if (!entity.attributes.hasOwnProperty(attr) || attr === 'friendly_name' || attr === 'unit_of_measurement' || attr === 'icon') {
|
|
386
|
+
if (!entity.attributes.hasOwnProperty(attr) || attr === 'friendly_name' || attr === 'unit_of_measurement' || attr === 'icon'|| !attr.length) {
|
|
367
387
|
continue;
|
|
368
388
|
}
|
|
369
389
|
let val = entity.attributes[attr];
|
|
@@ -386,14 +406,22 @@ function main() {
|
|
|
386
406
|
return;
|
|
387
407
|
}
|
|
388
408
|
//adapter.log.debug(JSON.stringify(config));
|
|
389
|
-
setTimeout(() =>
|
|
390
|
-
|
|
409
|
+
delayTimeout = setTimeout(() => {
|
|
410
|
+
delayTimeout = null;
|
|
411
|
+
!stopped && hass.getStates((err, states) => {
|
|
412
|
+
if (stopped) {
|
|
413
|
+
return;
|
|
414
|
+
}
|
|
391
415
|
if (err) {
|
|
392
416
|
return adapter.log.error('Cannot read states: ' + err);
|
|
393
417
|
}
|
|
394
418
|
//adapter.log.debug(JSON.stringify(states));
|
|
395
|
-
setTimeout(() =>
|
|
396
|
-
|
|
419
|
+
delayTimeout = setTimeout(() => {
|
|
420
|
+
delayTimeout = null;
|
|
421
|
+
!stopped && hass.getServices((err, services) => {
|
|
422
|
+
if (stopped) {
|
|
423
|
+
return;
|
|
424
|
+
}
|
|
397
425
|
if (err) {
|
|
398
426
|
adapter.log.error('Cannot read states: ' + err);
|
|
399
427
|
} else {
|
|
@@ -403,8 +431,8 @@ function main() {
|
|
|
403
431
|
adapter.subscribeStates('*');
|
|
404
432
|
});
|
|
405
433
|
}
|
|
406
|
-
}), 100);
|
|
407
|
-
}), 100);
|
|
434
|
+
})}, 100);
|
|
435
|
+
})}, 100);
|
|
408
436
|
});
|
|
409
437
|
}
|
|
410
438
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "iobroker.hass",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "Home Assistant",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "bluefox",
|
|
@@ -26,19 +26,25 @@
|
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"websocket": "^1.0.34",
|
|
29
|
-
"ws": "^8.
|
|
30
|
-
"@iobroker/adapter-core": "^2.
|
|
29
|
+
"ws": "^8.5.0",
|
|
30
|
+
"@iobroker/adapter-core": "^2.6.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@alcalzone/release-script": "^
|
|
33
|
+
"@alcalzone/release-script": "^3.5.6",
|
|
34
|
+
"@alcalzone/release-script-plugin-iobroker": "^3.5.7",
|
|
35
|
+
"@alcalzone/release-script-plugin-license": "^3.5.3",
|
|
36
|
+
"axios": "^0.26.1",
|
|
34
37
|
"gulp": "^4.0.2",
|
|
35
|
-
"mocha": "^9.
|
|
36
|
-
"chai": "^4.3.
|
|
38
|
+
"mocha": "^9.2.2",
|
|
39
|
+
"chai": "^4.3.6"
|
|
37
40
|
},
|
|
38
41
|
"main": "main.js",
|
|
39
42
|
"scripts": {
|
|
40
43
|
"test": "node node_modules/mocha/bin/mocha --exit",
|
|
41
|
-
"release": "
|
|
44
|
+
"release": "release-script",
|
|
45
|
+
"release-patch": "release-script patch --yes",
|
|
46
|
+
"release-minor": "release-script minor --yes",
|
|
47
|
+
"release-major": "release-script major --yes"
|
|
42
48
|
},
|
|
43
49
|
"bugs": {
|
|
44
50
|
"url": "https://github.com/ioBroker/ioBroker.hass/issues"
|
package/admin/index.html
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
<html>
|
|
2
|
-
<head>
|
|
3
|
-
<link rel="stylesheet" type="text/css" href="../../lib/css/themes/jquery-ui/redmond/jquery-ui.min.css"/>
|
|
4
|
-
<link rel="stylesheet" type="text/css" href="../../css/adapter.css"/>
|
|
5
|
-
|
|
6
|
-
<script type="text/javascript" src="../../lib/js/jquery-1.11.1.min.js"></script>
|
|
7
|
-
<script type="text/javascript" src="../../socket.io/socket.io.js"></script>
|
|
8
|
-
<script type="text/javascript" src="../../lib/js/jquery-ui-1.10.3.full.min.js"></script>
|
|
9
|
-
<script type="text/javascript" src="../../js/translate.js"></script>
|
|
10
|
-
<script type="text/javascript" src="../../js/adapter-settings.js"></script>
|
|
11
|
-
<script type="text/javascript" src="words.js"></script>
|
|
12
|
-
|
|
13
|
-
<script type="text/javascript">
|
|
14
|
-
|
|
15
|
-
function load(settings, onChange) {
|
|
16
|
-
if (!settings) return;
|
|
17
|
-
|
|
18
|
-
if (settings.password === undefined) settings.password = '';
|
|
19
|
-
if (settings.prompt === undefined) settings.prompt = 'hass>';
|
|
20
|
-
|
|
21
|
-
$('.value').each(function () {
|
|
22
|
-
var key = $(this).attr('id');
|
|
23
|
-
var $value = $('#' + key + '.value');
|
|
24
|
-
if ($value.attr('type') === 'checkbox') {
|
|
25
|
-
$value.prop('checked', settings[key]).change(function() {
|
|
26
|
-
onChange();
|
|
27
|
-
});
|
|
28
|
-
} else {
|
|
29
|
-
$value.val(settings[key]).change(function() {
|
|
30
|
-
onChange();
|
|
31
|
-
}).keyup(function() {
|
|
32
|
-
onChange();
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
// Signal to admin, that no changes yet
|
|
37
|
-
onChange(false);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function save(callback) {
|
|
41
|
-
var obj = {};
|
|
42
|
-
|
|
43
|
-
if ($('#password').val() !== $('#passwordRepeat').val()) {
|
|
44
|
-
showMessage(_('Passwords missmatch!'), _('Warning'), 'alert');
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
$('.value').each(function () {
|
|
49
|
-
var $this = $(this);
|
|
50
|
-
if ($this.attr('type') === 'checkbox') {
|
|
51
|
-
obj[$this.attr('id')] = $this.prop('checked');
|
|
52
|
-
} else {
|
|
53
|
-
obj[$this.attr('id')] = $this.val();
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
callback(obj);
|
|
57
|
-
}
|
|
58
|
-
</script>
|
|
59
|
-
|
|
60
|
-
</head>
|
|
61
|
-
<body>
|
|
62
|
-
<div id="adapter-container">
|
|
63
|
-
<table><tr>
|
|
64
|
-
<td><img src="hass.png"/></td>
|
|
65
|
-
<td><h3 class="translate">FHEM adapter settings</h3></td>
|
|
66
|
-
</tr></table>
|
|
67
|
-
<table>
|
|
68
|
-
<tr><td><label class="translate" for="host">Home assistant IP:</label></td><td class="admin-icon"></td><td><input class="value" id="host" /></td></tr>
|
|
69
|
-
<tr><td><label class="translate" for="port">Home assistant WS Port:</label></td><td class="admin-icon"></td><td><input class="value" id="port" size="5" maxlength="5"/></td></tr>
|
|
70
|
-
<tr><td><label class="translate" for="password">Password:</label></td><td class="admin-icon"></td><td><input class="value" id="password" type="password"/></td></tr>
|
|
71
|
-
<tr><td><label class="translate" for="passwordRepeat">Password repeat:</label></td><td class="admin-icon"></td><td><input type="password" id="passwordRepeat"/></td></tr>
|
|
72
|
-
<tr><td><label class="translate" for="secure">Secure:</label></td><td class="admin-icon"></td><td><input class="value" id="secure" type="checkbox"/></td></tr>
|
|
73
|
-
</table>
|
|
74
|
-
</div>
|
|
75
|
-
</body>
|
|
76
|
-
</html>
|