node-red-contrib-yandex-station-management 0.3.8 → 0.3.10
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 +2 -0
- package/nodes/yandex-login.js +9 -9
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -21,6 +21,8 @@
|
|
|
21
21
|
|
|
22
22
|
Второй из варинатов его получения описан в [FAQ](#faq)
|
|
23
23
|
|
|
24
|
+
Третий из вариантов получения токена описан [тут](https://github.com/MarshalX/yandex-music-api/discussions/513#discussioncomment-2729781)
|
|
25
|
+
|
|
24
26
|
Возможна работа с несколькими устройствами(протестировано) и несколькими учетными записями(протестировано).
|
|
25
27
|
|
|
26
28
|
Состоит из 4 нод, позволяющих гибко настраивать автоматизации и использовать голосовые уведомления:
|
package/nodes/yandex-login.js
CHANGED
|
@@ -66,7 +66,7 @@ module.exports = function(RED) {
|
|
|
66
66
|
headers:
|
|
67
67
|
{
|
|
68
68
|
'Content-Type': 'application/json',
|
|
69
|
-
'Authorization': '
|
|
69
|
+
'Authorization': 'OAuth ' + token
|
|
70
70
|
}
|
|
71
71
|
};
|
|
72
72
|
// вариант для снижения частоты запросов на серверы ЯНдекса для обновления списка устройств. Требует тестирования.
|
|
@@ -183,7 +183,7 @@ module.exports = function(RED) {
|
|
|
183
183
|
qs: { device_id: device.id, platform: device.platform },
|
|
184
184
|
headers:
|
|
185
185
|
{
|
|
186
|
-
'Authorization': '
|
|
186
|
+
'Authorization': 'OAuth ' + node.token,
|
|
187
187
|
'Content-Type': 'application/json'
|
|
188
188
|
}
|
|
189
189
|
};
|
|
@@ -295,7 +295,7 @@ module.exports = function(RED) {
|
|
|
295
295
|
device.watchDog = setTimeout(() => {
|
|
296
296
|
if (typeof(device) != 'undefined' && typeof(device.ws) != 'undefined') {device.ws.close()}
|
|
297
297
|
}, 10000);
|
|
298
|
-
device.pingInterval = setInterval(onPing,
|
|
298
|
+
device.pingInterval = setInterval(onPing,1500,device);
|
|
299
299
|
debugMessage(`${device.id}: Kill connection watchdog`);
|
|
300
300
|
clearTimeout(device.watchDogConn);
|
|
301
301
|
clearTimeout(device.timer);
|
|
@@ -395,7 +395,7 @@ module.exports = function(RED) {
|
|
|
395
395
|
};
|
|
396
396
|
|
|
397
397
|
function messageConstructor(messageType, message, device){
|
|
398
|
-
let commands = ['play', 'stop', 'next', 'prev', 'ping'];
|
|
398
|
+
let commands = ['play', 'stop', 'next', 'prev', 'ping', 'softwareVersion'];
|
|
399
399
|
let extraCommands = ['forward', 'backward', 'volumeup', 'volumedown', 'volume'];
|
|
400
400
|
switch(messageType){
|
|
401
401
|
case 'command':
|
|
@@ -455,7 +455,7 @@ module.exports = function(RED) {
|
|
|
455
455
|
} else {
|
|
456
456
|
debugMessage(`Bad command ${message.payload}`)
|
|
457
457
|
//node.error(`You can send commands in msg.payload from list as String ${commands + extraCommands}`);
|
|
458
|
-
return [{"command": "
|
|
458
|
+
return [{"command": "softwareVersion"}];
|
|
459
459
|
}
|
|
460
460
|
case 'voice':
|
|
461
461
|
debugMessage(`Message Voice command: ${message}`);
|
|
@@ -595,9 +595,9 @@ module.exports = function(RED) {
|
|
|
595
595
|
}
|
|
596
596
|
|
|
597
597
|
debugMessage('unknown command')
|
|
598
|
-
return messageConstructor('command', { 'payload': '
|
|
598
|
+
return messageConstructor('command', { 'payload': 'softwareVersion' })
|
|
599
599
|
} else {
|
|
600
|
-
return messageConstructor('command', { 'payload': '
|
|
600
|
+
return messageConstructor('command', { 'payload': 'softwareVersion' })
|
|
601
601
|
}
|
|
602
602
|
case 'raw':
|
|
603
603
|
if (Array.isArray(message.payload)) { return message.payload }
|
|
@@ -665,11 +665,11 @@ module.exports = function(RED) {
|
|
|
665
665
|
}
|
|
666
666
|
}
|
|
667
667
|
function onPing(device) {
|
|
668
|
-
if (device) {sendMessage(device.id, 'command', {payload: '
|
|
668
|
+
if (device) {sendMessage(device.id, 'command', {payload: 'softwareVersion'});}
|
|
669
669
|
}
|
|
670
670
|
|
|
671
671
|
function onPing(device) {
|
|
672
|
-
sendMessage(device.id, 'command', {payload: '
|
|
672
|
+
sendMessage(device.id, 'command', {payload: 'softwareVersion'});
|
|
673
673
|
}
|
|
674
674
|
function getStatus(id) {
|
|
675
675
|
let device = searchDeviceByID(id);
|