node-red-contrib-alice 2.3.3 → 2.3.4

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/README.md CHANGED
@@ -1,62 +1,97 @@
1
1
  # NodeRed Home (node-red-contrib-alice)
2
2
 
3
- **NodeRed Home** (node-red-contrib-alice) - это сервис позволит, в несколько простых шагов, подключить любые ваши устройства заведенные в Node-RED к умному дому от Яндекса и управлять ими с помощью голосового помощника Алиса.
4
-
5
3
  [![platform](https://img.shields.io/badge/platform-Node--RED-red?logo=nodered)](https://nodered.org)
6
4
  [![Min Node Version](https://img.shields.io/node/v/node-red-contrib-alice.svg)](https://nodejs.org/en/)
7
- ![Repo size](https://img.shields.io/github/repo-size/efa2000/node-red-contrib-alice)
8
5
  [![GitHub version](https://img.shields.io/github/package-json/v/efa2000/node-red-contrib-alice?logo=npm)](https://www.npmjs.com/package/node-red-contrib-alice)
9
- [![Package Quality](https://packagequality.com/shield/node-red-contrib-alice.svg)](https://packagequality.com/#?package=node-red-contrib-alice)
10
- ![GitHub last commit](https://img.shields.io/github/last-commit/efa2000/node-red-contrib-alice/master)
11
6
  ![NPM Total Downloads](https://img.shields.io/npm/dt/node-red-contrib-alice.svg)
12
7
  ![NPM Downloads per month](https://img.shields.io/npm/dm/node-red-contrib-alice)
13
8
 
14
- #### Обсудить и получить поддержку от сообщества и автора можно в Телеграм канале [https://t.me/nodered_home_chat](https://t.me/nodered_home_chat)
15
-
16
- ## Инструкция (RUS)
17
- ### Использование
18
- #### Как настроить навык:
19
- 1. Установите и настройте Node-Red
20
- 2. Из интерфейса Node-Red добавьте модуль node-red-contrib-alice или с использованием npm
21
- ```
22
- npm install node-red-contrib-alice
23
- ```
24
- 3. Добавьте в свою схему устройства и умения Алисы и зарегистрируйтесь на вкладке настройки
25
- 4. Настройте их связь с вашими устройствами
26
- 5. В приложении Яндекс добавьте навык NodeRed Home
27
- 6. Заведенные устройства появятся автоматически
28
-
29
- ### Концепция
30
- Кождое устройство может иметь неограниченное число умений (функционала)
31
- К примеру, лампочка может иметь умение включения/выклюяения, но так же дополнительное умение установки цвета и яркости
32
- Умения устройства можно объеденять в любом порядке
33
- Более подробно о умениях и устройствах можно почитать в документации Yandex [Документация Яндекса](https://yandex.ru/dev/dialogs/alice/doc/smart-home/concepts/capability-types-docpage/)
34
-
35
- ### Особенности
36
- Для того, что бы устройство ответило Алисе, что комманда выполнена успешно, на вход должно прийти соответсвующее значение.
37
- Если ваше устройство отвечает дольше или совсем не возвращает подтверждение просто добавьте оставьте галочку Response включенной
38
-
39
- ### Тарифы
40
- до 5-ти зарегистрированных на шлюзе устройств - бесплатно
41
- 5-ть и более зарегистрированных на шлюзе устройств - 199 руб./мес.
42
-
43
- ## Instruction (ENG - Google Translate)
44
- The module allows you to use Node-Red together with the Yandex.Alice voice assistant service (voice control of smart home devices)
45
-
46
- ### Use
47
- #### How to set up a skill:
48
- 1. Install and configure Node-Red
49
- 2. From the Node-Red interface add the node-red-contrib-alice module or using npm
50
- ```
51
- npm install node-red-contrib-alice
52
- ```
53
- 3. Add Alice’s devices and capability to your circuit and register on the settings tab
54
- 4. Configure their connection with your devices
55
- 5. In the Yandex application, add the NodeRed Home skill
56
- 6. Started devices will appear automatically
57
-
58
- ### Concept
59
- Each device can have an unlimited number of capability (functionality)
60
- For example, a light bulb may have the capability to turn on / off, but also the additional capability to set the color and brightness
61
- Device capabilites can be combined in any order
62
- You can read more about capability and devices in the Yandex documentation [Yandex Documentation] (https://yandex.ru/dev/dialogs/alice/doc/smart-home/concepts/capability-types-docpage/)
9
+ Интеграция Node-RED с умным домом Яндекса. Подключите любые устройства из Node-RED к Алисе и управляйте ими голосом.
10
+
11
+ Integration of Node-RED with Yandex Smart Home. Connect any device from Node-RED to Alice voice assistant.
12
+
13
+ **Telegram:** [https://t.me/nodered_home_chat](https://t.me/nodered_home_chat) поддержка и обсуждение / support & discussion
14
+
15
+ **Сайт / Website:** [https://nodered-home.ru](https://nodered-home.ru)
16
+
17
+ ---
18
+
19
+ ## Быстрый старт
20
+
21
+ 1. Установите Node-RED ([инструкция](https://nodered.org/docs/getting-started/))
22
+ 2. Установите модуль из палитры Node-RED или через npm:
23
+ ```
24
+ npm install node-red-contrib-alice
25
+ ```
26
+ 3. Перетащите на рабочую область ноду **alice-device** и нужные умения (on/off, range, color, mode и т.д.)
27
+ 4. Откройте настройки ноды alice-device, нажмите «Зарегистрироваться» — авторизуйтесь через Яндекс
28
+ 5. Соедините умения с вашими устройствами в Node-RED
29
+ 6. В приложении «Дом с Алисой» добавьте навык **NodeRed Home** — устройства появятся автоматически
30
+
31
+ ## Концепция
32
+
33
+ Каждое устройство в Node-RED состоит из:
34
+ - **alice-device** — само устройство (лампочка, розетка, кондиционер и т.д.)
35
+ - **Умения** функции устройства, которые подключаются к alice-device:
36
+ - **on_off** включение/выключение
37
+ - **range** — числовые параметры (яркость, громкость, температура)
38
+ - **color** управление цветом
39
+ - **mode** режимы работы (скорость вентилятора, режим кондиционера)
40
+ - **toggle** — переключатели (пауза, беззвучный режим)
41
+ - **sensor** — датчики (температура, влажность, CO2)
42
+ - **event** события (открытие двери, движение)
43
+ - **video** видеопоток
44
+
45
+ Умения можно комбинировать в любом порядке. Например, лампочка = on_off + range (яркость) + color.
46
+
47
+ Подробнее об устройствах и умениях: [документация Яндекса](https://yandex.ru/dev/dialogs/alice/doc/smart-home/concepts/capability-types-docpage/)
48
+
49
+ ## Подтверждение команд
50
+
51
+ Когда Алиса отправляет команду, устройство должно вернуть подтверждение (отправить значение на вход ноды умения). Если ваше устройство не отвечает или отвечает медленно — включите опцию **Response** в настройках умения, и подтверждение будет отправлено автоматически.
52
+
53
+ ## Тарифы
54
+
55
+ - До 4 устройств **бесплатно**
56
+ - 5 и более устройств **299 руб./мес.**
57
+
58
+ ---
59
+
60
+ ## Quick Start
61
+
62
+ 1. Install Node-RED ([guide](https://nodered.org/docs/getting-started/))
63
+ 2. Install the module from the Node-RED palette or via npm:
64
+ ```
65
+ npm install node-red-contrib-alice
66
+ ```
67
+ 3. Drag an **alice-device** node and the desired capability nodes (on/off, range, color, mode, etc.) onto your flow
68
+ 4. Open the alice-device settings, click "Register" and sign in with your Yandex account
69
+ 5. Wire the capability nodes to your devices in Node-RED
70
+ 6. In the Yandex "Home with Alice" app, add the **NodeRed Home** skill — your devices will appear automatically
71
+
72
+ ## Concept
73
+
74
+ Each device in Node-RED consists of:
75
+ - **alice-device** — the device itself (light, switch, AC, etc.)
76
+ - **Capabilities** — device functions connected to alice-device:
77
+ - **on_off** — turn on/off
78
+ - **range** — numeric parameters (brightness, volume, temperature)
79
+ - **color** — color control
80
+ - **mode** — operating modes (fan speed, AC mode)
81
+ - **toggle** — toggles (mute, pause)
82
+ - **sensor** — sensors (temperature, humidity, CO2)
83
+ - **event** — events (door open, motion detected)
84
+ - **video** — video stream
85
+
86
+ Capabilities can be combined in any order. For example, a light = on_off + range (brightness) + color.
87
+
88
+ More about devices and capabilities: [Yandex documentation](https://yandex.ru/dev/dialogs/alice/doc/smart-home/concepts/capability-types-docpage/)
89
+
90
+ ## Command Confirmation
91
+
92
+ When Alice sends a command, the device must return a confirmation (send a value to the capability node input). If your device does not respond or responds slowly, enable the **Response** option in the capability settings — the confirmation will be sent automatically.
93
+
94
+ ## Pricing
95
+
96
+ - Up to 4 devices — **free**
97
+ - 5 or more devices — **299 RUB/month**
@@ -10,13 +10,11 @@ module.exports = (RED) => {
10
10
  const temperature_min = parseInt(config.temperature_min);
11
11
  const temperature_max = parseInt(config.temperature_max);
12
12
  const color_scene = config.color_scene || [];
13
- let needConvert = false;
14
13
  let response = config.response;
15
14
  let color_support = config.color_support;
16
15
  let lastValue;
17
16
  if (scheme == "rgb_normal") {
18
17
  scheme = "rgb";
19
- needConvert = true;
20
18
  }
21
19
  if (config.response === undefined) {
22
20
  response = true;
@@ -194,6 +192,7 @@ module.exports = (RED) => {
194
192
  });
195
193
  });
196
194
  this.on('close', (removed, done) => {
195
+ device.setMaxListeners(device.getMaxListeners() - 1);
197
196
  if (removed) {
198
197
  device.delCapability(this.id)
199
198
  .then(() => { done(); })
@@ -92,7 +92,7 @@ module.exports = (RED) => {
92
92
  axios_1.default.request({
93
93
  timeout: 5000,
94
94
  method: 'POST',
95
- url: 'https://api.nodered-home.ru/gtw/device/state',
95
+ url: 'https://state.nodered-home.ru/gtw/device/state',
96
96
  headers: {
97
97
  'content-type': 'application/json',
98
98
  'Authorization': "Bearer " + service.getToken()
@@ -3,6 +3,7 @@ module.exports = (RED) => {
3
3
  function AliceMode(config) {
4
4
  RED.nodes.createNode(this, config);
5
5
  const device = RED.nodes.getNode(config.device);
6
+ device.setMaxListeners(device.getMaxListeners() + 1);
6
7
  const ctype = 'devices.capabilities.mode';
7
8
  const instance = config.instance || '';
8
9
  const modes = config.modes;
@@ -119,6 +120,7 @@ module.exports = (RED) => {
119
120
  });
120
121
  });
121
122
  this.on('close', (removed, done) => {
123
+ device.setMaxListeners(device.getMaxListeners() - 1);
122
124
  if (removed) {
123
125
  device.delCapability(this.id)
124
126
  .then(() => { done(); })
@@ -9,7 +9,6 @@ module.exports = (RED) => {
9
9
  const instance = 'on';
10
10
  let response = config.response;
11
11
  let split = config.split;
12
- let initState = false;
13
12
  const curentState = {
14
13
  type: ctype,
15
14
  state: {
@@ -38,7 +37,6 @@ module.exports = (RED) => {
38
37
  device.setCapability(id, capab)
39
38
  .then(() => {
40
39
  this.debug("Capability initilization - success!");
41
- initState = true;
42
40
  this.status({ fill: "green", shape: "dot", text: "online" });
43
41
  })
44
42
  .catch(err => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-red-contrib-alice",
3
- "version": "2.3.3",
3
+ "version": "2.3.4",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "start": "npm run build && node-red",
@@ -25,14 +25,12 @@ export = (RED: NodeAPI): void => {
25
25
  const temperature_min = parseInt(config.temperature_min);
26
26
  const temperature_max = parseInt(config.temperature_max);
27
27
  const color_scene = config.color_scene || [];
28
- let needConvert = false;
29
28
  let response = config.response;
30
29
  let color_support = config.color_support;
31
30
  let lastValue: string | undefined;
32
31
 
33
32
  if (scheme == "rgb_normal") {
34
33
  scheme = "rgb";
35
- needConvert = true;
36
34
  }
37
35
  if (config.response === undefined) {
38
36
  response = true;
@@ -210,6 +208,7 @@ export = (RED: NodeAPI): void => {
210
208
  });
211
209
 
212
210
  this.on('close', (removed: boolean, done: () => void) => {
211
+ device.setMaxListeners(device.getMaxListeners() - 1);
213
212
  if (removed) {
214
213
  device.delCapability(this.id)
215
214
  .then(() => { done(); })
@@ -110,7 +110,7 @@ export = (RED: NodeAPI): void => {
110
110
  axios.request({
111
111
  timeout: 5000,
112
112
  method: 'POST',
113
- url: 'https://api.nodered-home.ru/gtw/device/state',
113
+ url: 'https://state.nodered-home.ru/gtw/device/state',
114
114
  headers: {
115
115
  'content-type': 'application/json',
116
116
  'Authorization': "Bearer " + service.getToken()
package/src/alice-mode.ts CHANGED
@@ -5,6 +5,7 @@ export = (RED: NodeAPI): void => {
5
5
  function AliceMode(this: Node, config: AliceModeConfig): void {
6
6
  RED.nodes.createNode(this, config);
7
7
  const device = RED.nodes.getNode(config.device) as AliceDeviceNode;
8
+ device.setMaxListeners(device.getMaxListeners() + 1);
8
9
 
9
10
  const ctype = 'devices.capabilities.mode';
10
11
  const instance = config.instance || '';
@@ -122,6 +123,7 @@ export = (RED: NodeAPI): void => {
122
123
  });
123
124
 
124
125
  this.on('close', (removed: boolean, done: () => void) => {
126
+ device.setMaxListeners(device.getMaxListeners() - 1);
125
127
  if (removed) {
126
128
  device.delCapability(this.id)
127
129
  .then(() => { done(); })
@@ -12,7 +12,6 @@ export = (RED: NodeAPI): void => {
12
12
  const instance = 'on';
13
13
  let response = config.response;
14
14
  let split = config.split;
15
- let initState = false;
16
15
 
17
16
  const curentState: CapabilityState = {
18
17
  type: ctype,
@@ -46,7 +45,6 @@ export = (RED: NodeAPI): void => {
46
45
  device.setCapability(id, capab)
47
46
  .then(() => {
48
47
  this.debug("Capability initilization - success!");
49
- initState = true;
50
48
  this.status({ fill: "green", shape: "dot", text: "online" });
51
49
  })
52
50
  .catch(err => {
@@ -1,91 +0,0 @@
1
- <script type="text/javascript">
2
- let udyaconfig={};
3
- RED.nodes.registerType('Alice-Get',{
4
- category: 'alice',
5
- inputs:1,
6
- outputs:1,
7
- icon: "alice.png",
8
- color: "#D8BFD8",
9
- defaults:{
10
- service: {value:"", type:"alice-service"},
11
- device: {value:undefined}
12
- },
13
- label: function(){
14
- return this.name || "Alice-Get";
15
- },
16
- oneditprepare: ()=>{
17
- $("#node-input-service").change(function(e){
18
- if (this.value &&this.value!='_ADD_'){
19
- $.ajax({
20
- url: "/noderedhome/"+this.value+"/getfullconfig",
21
- type:"GET"
22
- })
23
- .done(result=>{
24
- // RED.notify("Full Alice SmartHome config successfully retrieved", {type:"success"});
25
- console.log(result);
26
- udyaconfig=result;
27
- updateHouse(result.households);
28
- })
29
- .fail(error=>{
30
- RED.notify("Error when retrieve Alice SmartHome config", {type:"error"});
31
- });
32
- }
33
- });
34
- $('#node-input-home')
35
- .prop('disabled', 'disabled')
36
- .change((e)=>{
37
- let val = $('#node-input-home').find(":selected").val();
38
- console.log(val);
39
- });
40
-
41
- $('#node-input-room').prop('disabled', 'disabled');
42
- $('#node-input-device').prop('disabled', 'disabled');
43
-
44
- }
45
- });
46
- function updateHouse(data){
47
- $('#node-input-home')
48
- .find('option')
49
- .remove()
50
- .end();
51
- udyaconfig.households.forEach(h => {
52
- $('#node-input-home')
53
- .append('<option value="'+h.id+'">'+h.name+'</option>');
54
- });
55
- $('#node-input-home')
56
- .prop('disabled', false);
57
- };
58
- function updaterooms(house){
59
- $('#node-input-room')
60
- .find('option')
61
- .remove()
62
- .end();
63
- udyaconfig.households.forEach(h => {
64
- if (h.household_id==house){
65
- $('#node-input-room')
66
- .append('<option value="'+h.id+'">'+h.name+'</option>');
67
- }
68
- });
69
- $('#node-input-room').prop('disabled', false);
70
- };
71
-
72
- </script>
73
-
74
- <script type="text/x-red" data-template-name="Alice-Get">
75
- <div class="form-row">
76
- <label for="node-input-service">Account</label>
77
- <input id="node-input-service">
78
- </div>
79
- <div class="form-row">
80
- <label for="node-input-home">Home</label>
81
- <select id="node-input-home" style="width: 70%;"></select>
82
- </div>
83
- <div class="form-row">
84
- <label for="node-input-room">Room</label>
85
- <select id="node-input-room" style="width: 70%;"></select>
86
- </div>
87
- <div class="form-row">
88
- <label for="node-input-device">Room</label>
89
- <select id="node-input-device" style="width: 70%;"></select>
90
- </div>
91
- </script>
@@ -1,9 +0,0 @@
1
- "use strict";
2
- module.exports = (RED) => {
3
- function AliceGet(config) {
4
- RED.nodes.createNode(this, config);
5
- const _service = RED.nodes.getNode(config.service);
6
- }
7
- RED.nodes.registerType("Alice-Get", AliceGet);
8
- };
9
- //# sourceMappingURL=alice-get.js.map
@@ -1,91 +0,0 @@
1
- <script type="text/javascript">
2
- let udyaconfig={};
3
- RED.nodes.registerType('Alice-Get',{
4
- category: 'alice',
5
- inputs:1,
6
- outputs:1,
7
- icon: "alice.png",
8
- color: "#D8BFD8",
9
- defaults:{
10
- service: {value:"", type:"alice-service"},
11
- device: {value:undefined}
12
- },
13
- label: function(){
14
- return this.name || "Alice-Get";
15
- },
16
- oneditprepare: ()=>{
17
- $("#node-input-service").change(function(e){
18
- if (this.value &&this.value!='_ADD_'){
19
- $.ajax({
20
- url: "/noderedhome/"+this.value+"/getfullconfig",
21
- type:"GET"
22
- })
23
- .done(result=>{
24
- // RED.notify("Full Alice SmartHome config successfully retrieved", {type:"success"});
25
- console.log(result);
26
- udyaconfig=result;
27
- updateHouse(result.households);
28
- })
29
- .fail(error=>{
30
- RED.notify("Error when retrieve Alice SmartHome config", {type:"error"});
31
- });
32
- }
33
- });
34
- $('#node-input-home')
35
- .prop('disabled', 'disabled')
36
- .change((e)=>{
37
- let val = $('#node-input-home').find(":selected").val();
38
- console.log(val);
39
- });
40
-
41
- $('#node-input-room').prop('disabled', 'disabled');
42
- $('#node-input-device').prop('disabled', 'disabled');
43
-
44
- }
45
- });
46
- function updateHouse(data){
47
- $('#node-input-home')
48
- .find('option')
49
- .remove()
50
- .end();
51
- udyaconfig.households.forEach(h => {
52
- $('#node-input-home')
53
- .append('<option value="'+h.id+'">'+h.name+'</option>');
54
- });
55
- $('#node-input-home')
56
- .prop('disabled', false);
57
- };
58
- function updaterooms(house){
59
- $('#node-input-room')
60
- .find('option')
61
- .remove()
62
- .end();
63
- udyaconfig.households.forEach(h => {
64
- if (h.household_id==house){
65
- $('#node-input-room')
66
- .append('<option value="'+h.id+'">'+h.name+'</option>');
67
- }
68
- });
69
- $('#node-input-room').prop('disabled', false);
70
- };
71
-
72
- </script>
73
-
74
- <script type="text/x-red" data-template-name="Alice-Get">
75
- <div class="form-row">
76
- <label for="node-input-service">Account</label>
77
- <input id="node-input-service">
78
- </div>
79
- <div class="form-row">
80
- <label for="node-input-home">Home</label>
81
- <select id="node-input-home" style="width: 70%;"></select>
82
- </div>
83
- <div class="form-row">
84
- <label for="node-input-room">Room</label>
85
- <select id="node-input-room" style="width: 70%;"></select>
86
- </div>
87
- <div class="form-row">
88
- <label for="node-input-device">Room</label>
89
- <select id="node-input-device" style="width: 70%;"></select>
90
- </div>
91
- </script>
package/src/alice-get.ts DELETED
@@ -1,15 +0,0 @@
1
- import { NodeAPI, Node, NodeDef } from "node-red";
2
-
3
- interface NodeAliceGetConfig extends NodeDef {
4
- service: string;
5
- name: string;
6
- }
7
-
8
- export = (RED: NodeAPI): void => {
9
- function AliceGet(this: Node, config: NodeAliceGetConfig): void {
10
- RED.nodes.createNode(this, config);
11
- const _service = RED.nodes.getNode(config.service);
12
- }
13
-
14
- RED.nodes.registerType("Alice-Get", AliceGet);
15
- };