Get dp from NSPanelSendTopic

This commit is contained in:
ticaki
2024-01-08 22:23:06 +01:00
parent 2621b22ffd
commit aa3e90ef98

View File

@@ -204,7 +204,6 @@ let Debug: boolean = false;
// EN: Adapt to the MQTT adapter instance directories
const NSPanelReceiveTopic: string = 'mqtt.0.SmartHome.NSPanel_1.tele.RESULT';
const NSPanelSendTopic: string = 'mqtt.0.SmartHome.NSPanel_1.cmnd.CustomSend';
NSPanelStateTopic = 'mqtt.0.SmartHome.NSPanel_1.stat'
// DE: nur ändern, falls der User im Tasmota vor dem Kompilieren umbenannt wurde (Standard Tasmota: admin)
// EN: only change if the user was renamed in Tasmota before compiling (default Tasmota: admin)
@@ -972,9 +971,6 @@ let weatherForecast: boolean;
let pageCounter: number = 0;
let alwaysOn: boolean = false;
var NSPanelStateTopic = NSPanelStateTopic !== undefined ? NSPanelStateTopic : ''
const axios = require('axios');
const dayjs = require('dayjs');
const moment = require('moment');
@@ -1731,8 +1727,8 @@ on({id: [String(NSPanel_Path) + 'Config.Dateformat.Switch.weekday',
});
//Set Relays from Tasmota
if (NSPanelStateTopic != '') {
on({id: [String(NSPanelStateTopic) + '.POWER1',String(NSPanelStateTopic) + '.POWER2'], change: "ne"}, (obj) => {
const NSPanelStatTopic = NSPanelSendTopic.replace('.tele.','.stat.').replace('.CustomSend','.');
on({id: [String(NSPanelStatTopic) + 'POWER1',String(NSPanelStatTopic) + 'POWER2'], change: "ne"}, (obj) => {
if (!obj || !obj.id) return
const n = obj.id.substring(obj.id.length-1);
if ( n === '1' || n === '2') {
@@ -1740,8 +1736,7 @@ if (NSPanelStateTopic != '') {
setState(NSPanel_Path + 'Relay.' + n, obj.state.val == 'ON' ? true : false, true);
}
}
})
}
})
//Control Relays from DP's
on({id: [String(NSPanel_Path) + 'Relay.1',String(NSPanel_Path) + 'Relay.2'], change: "ne", ack: false}, async function (obj) {
try {