mirror of
https://github.com/lasthead0/yandex2mqtt.git
synced 2025-08-09 01:21:01 +03:00
test
This commit is contained in:
70
app.js
70
app.js
@@ -94,24 +94,6 @@ global.devices.forEach(device => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
/* */
|
|
||||||
var noticeRequest;
|
|
||||||
const yc = config.yandex;
|
|
||||||
if (yc != 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,
|
||||||
@@ -130,33 +112,33 @@ global.mqttClient = mqtt.connect(`mqtt://${config.mqtt.host}`, {
|
|||||||
ldevice.updateState(`${message}`, instance);
|
ldevice.updateState(`${message}`, instance);
|
||||||
|
|
||||||
/* */
|
/* */
|
||||||
// if ((yc = config.yandex) != undefined) {
|
if ((yc = config.yandex) != undefined) {
|
||||||
// const noticeRequest = https.request({
|
const noticeRequest = https.request({
|
||||||
// hostname: 'dialogs.yandex.net',
|
hostname: 'dialogs.yandex.net',
|
||||||
// port: 443,
|
port: 443,
|
||||||
// path: `/api/v1/skills/${yc.skillId}/callback/state`,
|
path: `/api/v1/skills/${yc.skillId}/callback/state`,
|
||||||
// method: 'POST',
|
method: 'POST',
|
||||||
// headers: {
|
headers: {
|
||||||
// 'Authorization': yc.token,
|
'Authorization': yc.token,
|
||||||
// 'Content-Type': 'application/json'
|
'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),
|
||||||
payload: {
|
payload: {
|
||||||
user_id: "1",
|
user_id: "1",
|
||||||
devices: [{
|
devices: [{
|
||||||
id: deviceId,
|
id: deviceId,
|
||||||
capabilities: st.capabilities,
|
capabilities: st.capabilities,
|
||||||
properties: st.properties
|
properties: st.properties
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
noticeRequest.end();
|
noticeRequest.end();
|
||||||
// }
|
}
|
||||||
/* */
|
/* */
|
||||||
|
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user