mirror of
https://github.com/lasthead0/yandex2mqtt.git
synced 2025-08-08 09:01:00 +03:00
test
This commit is contained in:
41
app.js
41
app.js
@@ -94,6 +94,23 @@ global.devices.forEach(device => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/* */
|
||||||
|
var noticeRequest;
|
||||||
|
if ((yc = config.yandex) != undefined) {
|
||||||
|
noticeRequest = https.request({
|
||||||
|
hostname: 'dialogs.yandex.net',
|
||||||
|
port: 443,
|
||||||
|
path: `/api/v1/skills/${yc.skillId}/callback/state`,
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Authorization': yc.token,
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
}
|
||||||
|
}, res => {
|
||||||
|
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
/* Create MQTT client (variable) in global */
|
/* Create MQTT client (variable) in global */
|
||||||
global.mqttClient = mqtt.connect(`mqtt://${config.mqtt.host}`, {
|
global.mqttClient = mqtt.connect(`mqtt://${config.mqtt.host}`, {
|
||||||
port: config.mqtt.port,
|
port: config.mqtt.port,
|
||||||
@@ -112,18 +129,19 @@ global.mqttClient = mqtt.connect(`mqtt://${config.mqtt.host}`, {
|
|||||||
ldevice.updateState(`${message}`, instance);
|
ldevice.updateState(`${message}`, instance);
|
||||||
|
|
||||||
/* */
|
/* */
|
||||||
const noticeRequest = https.request({
|
// if ((yc = config.yandex) != undefined) {
|
||||||
hostname: 'dialogs.yandex.net',
|
// const noticeRequest = https.request({
|
||||||
port: 443,
|
// hostname: 'dialogs.yandex.net',
|
||||||
path: `/api/v1/skills/${config.yandex.skillId}/callback/state`,
|
// port: 443,
|
||||||
method: 'POST',
|
// path: `/api/v1/skills/${yc.skillId}/callback/state`,
|
||||||
headers: {
|
// method: 'POST',
|
||||||
'Authorization': 'AQAAAAAPv-V2AAT7o_ps6gEtgkNNjlE2ENZt96w',
|
// headers: {
|
||||||
'Content-Type': 'application/json'
|
// 'Authorization': yc.token,
|
||||||
}
|
// 'Content-Type': 'application/json'
|
||||||
}, res => {
|
// }
|
||||||
|
// }, res => {
|
||||||
|
|
||||||
});
|
// });
|
||||||
const st = ldevice.getState();
|
const st = ldevice.getState();
|
||||||
noticeRequest.write(JSON.stringify({
|
noticeRequest.write(JSON.stringify({
|
||||||
ts: Math.floor(Date.now() / 1000),
|
ts: Math.floor(Date.now() / 1000),
|
||||||
@@ -137,6 +155,7 @@ global.mqttClient = mqtt.connect(`mqtt://${config.mqtt.host}`, {
|
|||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
noticeRequest.end();
|
noticeRequest.end();
|
||||||
|
// }
|
||||||
/* */
|
/* */
|
||||||
|
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user