function HandleButtonEvent(words: any): void {
try {
let tempid = words[2].split('?');
let id = tempid[0];
let buttonAction = words[3];
if (Debug) {
console.log(words[0] + ' - ' + words[1] + ' - ' + words[2] + ' - ' + words[3] + ' - ' + words[4] + ' - PageId: ' + pageId);
}
if ((words[2]).substring(0, 8) == 'navigate') {
GeneratePage(eval((words[2]).substring(9, (words[2]).length)));
return;
}
if (words[2] == 'bNext' || words[2] == 'bPrev' || words[2] == 'bUp' || words[2] == 'bHome' || words[2] == 'bSubNext' || words[2] == 'bSubPrev' ) {
buttonAction = words[2];
}
if (Debug) {
console.log(buttonAction);
}
let pageNum:number = 0;
if (buttonAction.startsWith('swipe')) {
buttonAction = 'bExit';
}
switch (buttonAction) {
case 'bUp':
if (pageId < 0) { // Prüfen, ob button1page oder button2page
pageId = 0;
UnsubscribeWatcher();
GeneratePage(config.pages[pageId]);
} else {
pageNum = (((pageId - 1) % config.pages.length) + config.pages.length) % config.pages.length;
pageId = pageNum;
UnsubscribeWatcher();
if (activePage != undefined && activePage.parent != undefined) {
//update pageID
for (let i = 0; i < config.pages.length; i++) {
if (config.pages[i] == activePage.parent) {
pageId = i;
break;
}
}
GeneratePage(activePage.parent);
}
else {
GeneratePage(config.pages[pageId]);
}
break;
}
break;
case 'bNext':
pageNum = (((pageId + 1) % config.pages.length) + config.pages.length) % config.pages.length;
pageId = pageNum;
UnsubscribeWatcher();
GeneratePage(config.pages[pageId]);
break;
case 'bSubNext':
UnsubscribeWatcher();
GeneratePage(eval(activePage.next));
break;
case 'bPrev':
pageNum = (((pageId - 1) % config.pages.length) + config.pages.length) % config.pages.length;
pageId = pageNum;
UnsubscribeWatcher();
if (activePage != undefined && activePage.parent != undefined) {
//update pageID
for (let i = 0; i < config.pages.length; i++) {
if (config.pages[i] == activePage.parent) {
pageId = i;
break;
}
}
GeneratePage(activePage.parent);
}
else {
GeneratePage(config.pages[pageId]);
}
break;
case 'bSubPrev':
UnsubscribeWatcher();
GeneratePage(eval(activePage.prev));
break;
case 'bExit':
if (getState(NSPanel_Path + 'Config.Screensaver.screenSaverDoubleClick').val && words[2] == 'screensaver') {
if (words[4] >= 2) {
setIfExists(NSPanel_Path + 'ScreensaverInfo.popupNotifyHeading', '');
setIfExists(NSPanel_Path + 'ScreensaverInfo.popupNotifyText', '');
if (existsObject(NSPanel_Path + 'ScreensaverInfo.bExitPage') && getState(NSPanel_Path + 'ScreensaverInfo.bExitPage').val != null) {
pageId = getState(NSPanel_Path + 'ScreensaverInfo.bExitPage').val;
activePage = config.pages[pageId];
GeneratePage(activePage);
} else {
GeneratePage(activePage);
}
} else {
setIfExists(NSPanel_Path + 'ScreensaverInfo.popupNotifyHeading', '');
setIfExists(NSPanel_Path + 'ScreensaverInfo.popupNotifyText', '');
screensaverEnabled = true;
break;
}
} else {
if (Debug) {
console.log('bExit: ' + words[4] + ' - ' + pageId);
}
setIfExists(NSPanel_Path + 'ScreensaverInfo.popupNotifyHeading', '');
setIfExists(NSPanel_Path + 'ScreensaverInfo.popupNotifyText', '');
if (existsObject(NSPanel_Path + 'ScreensaverInfo.bExitPage') && getState(NSPanel_Path + 'ScreensaverInfo.bExitPage').val != null) {
pageId = getState(NSPanel_Path + 'ScreensaverInfo.bExitPage').val
activePage = config.pages[pageId];
GeneratePage(activePage);
} else {
GeneratePage(activePage);
}
}
break;
case 'bHome':
if (Debug) {
console.log('bExit: ' + words[4] + ' - ' + pageId);
}
UnsubscribeWatcher();
if (activePage.home != undefined) {
GeneratePage(eval(activePage.home));
} else {
GeneratePage(config.pages[0]);
}
break;
case 'notifyAction':
if (words[4] == 'yes') {
setState(popupNotifyInternalName, <iobJS.State>{ val: words[2], ack: true });
setState(popupNotifyAction, <iobJS.State>{ val: true, ack: true });
} else if (words[4] == 'no') {
setState(popupNotifyInternalName, <iobJS.State>{ val: words[2], ack: true });
setState(popupNotifyAction, <iobJS.State>{ val: false, ack: true });
}
setIfExists(config.panelSendTopic, 'exitPopup');
break;
case 'OnOff':
if (existsObject(id)) {
let action = false;
if (words[4] == '1')
action = true;
let o = getObject(id);
switch (o.common.role) {
case 'level.mode.fan':
case 'socket':
case 'light':
let pageItem = findPageItem(id);
if(pageItem.monobutton != undefined && pageItem.monobutton == true){
triggerButton(id + ".SET");
}
else {
setIfExists(id + '.SET', action);
}
break;
case 'dimmer':
setIfExists(id + '.ON_SET', action) ? true : setIfExists(id + '.ON_ACTUAL', action);
break;
case 'ct':
setIfExists(id + '.ON', action);
break;
case 'rgb':
case 'rgbSingle':
case 'hue':
setIfExists(id + '.ON_ACTUAL', action);
}
}
break;
case 'button':
if (existsObject(id)) {
let action = false;
if (words[4] == '1')
action = true;
let o = getObject(id);
switch (o.common.role) {
case 'lock':
case 'button':
toggleState(id + '.SET') ? true : toggleState(id + '.ON_SET');
break;
case 'buttonSensor':
if (existsObject(id + '.ACTUAL')) {
toggleState(id + '.ACTUAL');
}
break;
case 'socket':
case 'light':
// Änderung für Monobutton
let pageItem = findPageItem(id);
if(pageItem.monobutton != undefined && pageItem.monobutton == true){
triggerButton(id + ".SET");
}
else {
toggleState(id + ".SET") ? true : toggleState(id + ".ON_SET");
}
break;
case 'dimmer':
toggleState(id + '.ON_SET') ? true : toggleState(id + '.ON_ACTUAL');
break;
case 'ct':
toggleState(id + '.ON');
break;
case 'rgb':
case 'rgbSingle':
case 'hue': // Armilar
toggleState(id + '.ON_ACTUAL');
case 'media':
if (tempid[1] == 'repeat') {
let pageItemRepeat = findPageItem(id);
let adapterInstanceRepeat = pageItemRepeat.adapterPlayerInstance;
let adapterRepeat = adapterInstanceRepeat.split('.');
let deviceAdapterRP = adapterRepeat[0];
switch (deviceAdapterRP) {
case 'spotify-premium':
let stateSpotifyRepeat = getState(id + '.REPEAT').val
if (stateSpotifyRepeat == 'off') {
setIfExists(id + '.REPEAT', 'context');
} else if (stateSpotifyRepeat == 'context') {
setIfExists(id + '.REPEAT', 'track');
} else if (stateSpotifyRepeat == 'track') {
setIfExists(id + '.REPEAT', 'off');
}
break;
case 'alexa2':
try {
if (getState(id + '.REPEAT').val == 'false') {
setIfExists(id + '.REPEAT', true);
} else {
setIfExists(id + '.REPEAT', false);
}
} catch (err) {
console.log('Repeat kann nicht verändert werden');
}
break;
case 'volumio':
request({ url:`${getState(adapterInstanceRepeat+'info.host').val}/api/commands/?cmd=repeat`, headers: {'User-Agent': 'ioBroker'} },
async (error, response, result)=>{}); /* nothing todo @ error */
break;
}
}
}
}
break;
case 'up':
setIfExists(id + '.OPEN', true);
break;
case 'stop':
setIfExists(id + '.STOP', true);
break;
case 'down':
setIfExists(id + '.CLOSE', true);
break;
case 'positionSlider':
(function () { if (timeoutSlider) { clearTimeout(timeoutSlider); timeoutSlider = null; } })();
timeoutSlider = setTimeout(async function () {
setIfExists(id + '.SET', parseInt(words[4])) ? true : setIfExists(id + '.ACTUAL', parseInt(words[4]));
}, 250);
break;
case 'tiltOpen':
setIfExists(id + '.TILT_OPEN', true);
break;
case 'tiltStop':
setIfExists(id + '.TILT_STOP', true);
break;
case 'tiltClose':
setIfExists(id + '.TILT_CLOSE', true);
break;
case 'tiltSlider':
(function () { if (timeoutSlider) { clearTimeout(timeoutSlider); timeoutSlider = null; } })();
timeoutSlider = setTimeout(async function () {
setIfExists(id + '.TILT_SET', parseInt(words[4])) ? true : setIfExists(id + '.TILT_ACTUAL', parseInt(words[4]));
}, 250);
break;
case 'brightnessSlider':
(function () { if (timeoutSlider) { clearTimeout(timeoutSlider); timeoutSlider = null; } })();
timeoutSlider = setTimeout(async function () {
if (existsObject(id)) {
let o = getObject(id);
let pageItem = findPageItem(id);
switch (o.common.role) {
case 'dimmer':
if (pageItem.minValueBrightness != undefined && pageItem.maxValueBrightness != undefined) {
let sliderPos = Math.trunc(scale(parseInt(words[4]), 0, 100, pageItem.maxValueBrightness, pageItem.minValueBrightness));
setIfExists(id + '.SET', sliderPos) ? true : setIfExists(id + '.ACTUAL', sliderPos);
} else {
setIfExists(id + '.SET', parseInt(words[4])) ? true : setIfExists(id + '.ACTUAL', parseInt(words[4]));
}
break;
case 'rgb':
case 'ct':
case 'rgbSingle':
case 'hue':
if (pageItem.minValueBrightness != undefined && pageItem.maxValueBrightness != undefined) {
let sliderPos = Math.trunc(scale(parseInt(words[4]), 0, 100, pageItem.maxValueBrightness, pageItem.minValueBrightness));
setIfExists(id + '.DIMMER', sliderPos);
} else {
setIfExists(id + '.DIMMER', parseInt(words[4]));
}
break;
}
}
}, 250);
break;
case 'colorTempSlider': // Armilar - Slider tickt verkehrt - Hell = 0 / Dunkel = 100 -> Korrektur
(function () { if (timeoutSlider) { clearTimeout(timeoutSlider); timeoutSlider = null; } })();
timeoutSlider = setTimeout(async function () {
let pageItem = findPageItem(id);
if (pageItem.minValueColorTemp !== undefined && pageItem.maxValueColorTemp !== undefined) {
let colorTempK = Math.trunc(scale(parseInt(words[4]), 0, 100, pageItem.minValueColorTemp, pageItem.maxValueColorTemp));
setIfExists(id + '.TEMPERATURE', (colorTempK));
} else {
setIfExists(id + '.TEMPERATURE', 100 - words[4]);
}
}, 250);
break;
case 'colorWheel':
let colorCoordinates = words[4].split('|');
let rgb = pos_to_color(colorCoordinates[0], colorCoordinates[1]);
if (Debug) {
console.log(rgb);
}
if (Debug) {
console.log(getHue(rgb.red, rgb.green, rgb.blue));
}
let o = getObject(id);
switch (o.common.role) {
case 'hue':
setIfExists(id + '.HUE', getHue(rgb.red, rgb.green, rgb.blue));
break;
case 'rgb':
setIfExists(id + '.RED', rgb.red);
setIfExists(id + '.GREEN', rgb.green);
setIfExists(id + '.BLUE', rgb.blue);
break;
case 'rgbSingle':
let pageItem = findPageItem(id);
if (pageItem.colormode == "xy") {
//Für z.B. Deconz XY
setIfExists(id + ".RGB", rgb_to_cie(rgb.red, rgb.green, rgb.blue));
if (Debug) {
console.log(rgb_to_cie(rgb.red, rgb.green, rgb.blue));
}
}
else {
//Für RGB
setIfExists(id + ".RGB", ConvertRGBtoHex(rgb.red, rgb.green, rgb.blue));
}
break;
}
break;
case 'tempUpd':
setIfExists(id + '.SET', parseInt(words[4]) / 10);
break;
case 'media-back':
setIfExists(id + '.PREV', true);
break;
case 'media-pause':
let pageItemTemp = findPageItem(id);
let adaInstanceSplit = pageItemTemp.adapterPlayerInstance.split('.');
if (adaInstanceSplit[0] == 'squeezeboxrpc') {
let stateVal = getState(pageItemTemp.adapterPlayerInstance + 'state').val;
if (stateVal == 0) {
setState(pageItemTemp.adapterPlayerInstance + 'state', 1);
} else if (stateVal == 1) {
setState(pageItemTemp.adapterPlayerInstance + 'state', 0);
} else if (stateVal == null) {
setState(pageItemTemp.adapterPlayerInstance + 'state', 1);
}
} else {
if (getState(id + '.STATE').val === true) {
setIfExists(id + '.PAUSE', true);
} else {
setIfExists(id + '.PLAY', true);
}
}
break;
case 'media-next':
setIfExists(id + '.NEXT', true);
break;
case 'media-shuffle':
if ((findPageItem(id).adapterPlayerInstance).startsWith("volumio")) { findPageItem(id).playList = []; break; } //Volumio: empty playlist $uha-20230103
if (getState(id + '.SHUFFLE').val == 'off') {
setIfExists(id + '.SHUFFLE', 'on');
} else {
setIfExists(id + '.SHUFFLE', 'off');
}
break;
case 'volumeSlider':
setIfExists(id + '.VOLUME', parseInt(words[4]))
break;
case 'mode-speakerlist':
let pageItem = findPageItem(id);
let adapterInstance = pageItem.adapterPlayerInstance;
let adapter = adapterInstance.split('.');
let deviceAdapter = adapter[0];
switch (deviceAdapter) {
case 'spotify-premium':
let strDevicePI = pageItem.speakerList[words[4]];
let strDeviceID = spotifyGetDeviceID(strDevicePI);
setState(adapterInstance + 'devices.' + strDeviceID + ".useForPlayback", true);
break;
case 'alexa2':
let i_list = Array.prototype.slice.apply($('[state.id="' + adapterInstance + 'Echo-Devices.*.Info.name"]'));
for (let i_index in i_list) {
let i = i_list[i_index];
if ((getState(i).val) === pageItem.speakerList[words[4]]) {
console.log(getState(i).val + ' - ' + pageItem.speakerList[words[4]]);
let deviceId = i;
deviceId = deviceId.split('.');
setIfExists(adapterInstance + 'Echo-Devices.' + pageItem.mediaDevice + '.Commands.textCommand', 'Schiebe meine Musik auf ' + pageItem.speakerList[words[4]]);
pageItem.mediaDevice = deviceId[3];
}
}
break;
case 'sonos':
break;
case 'chromecast':
break;
}
break;
case 'mode-playlist':
let pageItemPL = findPageItem(id);
let adapterInstancePL = pageItemPL.adapterPlayerInstance;
let adapterPL = adapterInstancePL.split('.');
let deviceAdapterPL = adapterPL[0];
switch (deviceAdapterPL) {
case 'spotify-premium':
let strDevicePI = pageItemPL.playList[words[4]];
console.log(strDevicePI);
let playlistListString = (getState(adapterInstancePL + 'playlists.playlistListString').val).split(';');
let playlistListIds = (getState(adapterInstancePL + 'playlists.playlistListIds').val).split(';');
let playlistIndex = playlistListString.indexOf(strDevicePI);
setState(adapterInstancePL + 'playlists.playlistList', playlistListIds[playlistIndex]);
setTimeout(async function () {
globalTracklist = (function () { try {return JSON.parse(getState(adapterInstancePL + 'player.playlist.trackListArray').val);} catch(e) {return {};}})();
}, 2000);
break;
case 'alexa2':
let tempListItem = pageItemPL.playList[words[4]].split('.');
setState(adapterInstancePL + 'Echo-Devices.' + pageItemPL.mediaDevice + '.Music-Provider.' + tempListItem[0], tempListItem[1]);
break;
case 'volumio':
let strDevicePL = pageItemPL.playList[words[4]];
request({ url:`${getState(adapterInstancePL+'info.host').val}/api/commands/?cmd=playplaylist&name=${strDevicePL}`, headers: {'User-Agent': 'ioBroker'} },
async (error, response, result)=>{}); /* nothing todo @ error */
break;
}
break;
case 'mode-tracklist':
let pageItemTL = findPageItem(id);
let adapterInstanceTL = pageItemTL.adapterPlayerInstance;
let adapterTL = adapterInstanceTL.split('.')
let deviceAdapterTL = adapterTL[0];
switch (deviceAdapterTL) {
case 'spotify-premium':
let trackArray = (function () { try {return JSON.parse(getState(pageItemTL.adapterPlayerInstance + 'player.playlist.trackListArray').val);} catch(e) {return {};}})();
setState(adapterInstanceTL + 'player.trackId', getAttr(trackArray, words[4] + '.id'));
break;
case 'alexa2':
if (Debug) console.log('Aktuell hat alexa2 keine Tracklist');
break;
case 'volumio':
request({ url:`${getState(adapterInstanceTL+'info.host').val}/api/commands/?cmd=play&N=${words[4]}`, headers: {'User-Agent': 'ioBroker'} },
async (error, response, result)=>{}); /* nothing todo @ error */
break;
}
break;
case 'mode-repeat':
let pageItemRP = findPageItem(id);
let adapterInstanceRP = pageItemRP.adapterPlayerInstance;
let adapterRP = adapterInstanceRP.split('.');
let deviceAdapterRP = adapterRP[0];
switch (deviceAdapterRP) {
case 'spotify-premium':
setIfExists(id + '.REPEAT', pageItemRP.repeatList[words[4]]);
break;
case 'alexa2':
break;
}
break;
case 'mode-equalizer':
let pageItemEQ = findPageItem(id);
if (Debug) console.log(id);
let lastIndex = (id.split('.')).pop();
setState(NSPanel_Path + 'Media.Player.' + lastIndex + '.EQ.activeMode', pageItemEQ.equalizerList[words[4]]);
setTimeout(async function () {
GenerateDetailPage('popupInSel','equalizer', pageItemEQ);
}, 2000);
break;
case 'mode-insel':
setIfExists(id + '.VALUE', parseInt(words[4]));
break;
case 'media-OnOff':
let pageItemTem = findPageItem(id);
let adaInstanceSpli = pageItemTem.adapterPlayerInstance.split('.');
if (adaInstanceSpli[0] == 'squeezeboxrpc') {
let stateVal = getState(pageItemTem.adapterPlayerInstance + 'Power').val;
if (stateVal === 0) {
setState(pageItemTem.adapterPlayerInstance + 'Power', 1);
setIfExists(id + '.STOP', false);
setIfExists(id + '.STATE', 1);
} else {
setState(pageItemTem.adapterPlayerInstance + 'Power', 0);
setIfExists(id + '.STOP', true);
setIfExists(id + '.STATE', 0);
}
} else {
setIfExists(id + '.STOP', true);
}
break;
case 'timer-start':
if (words[4] != undefined) {
let timer_panel = words[4].split(':');
setIfExists(id + '.ACTUAL', (parseInt(timer_panel[1]) * 60) + parseInt(timer_panel[2]));
}
setIfExists(id + '.STATE', 'active');
break;
case 'timer-pause':
setIfExists(id + '.STATE', 'paused');
break;
case 'timer-cancle':
setIfExists(id + '.STATE', 'idle');
setIfExists(id + '.ACTUAL', 0);
break;
case 'timer-finish':
setIfExists(id + '.STATE', 'idle');
setIfExists(id + '.ACTUAL', 0);
break;
case 'hvac_action':
if (words[4] == 'BOOT' || words[4] == 'PART' || words[4] == 'AUTT' || words[4] == 'MANT' || words[4] == 'VACT') {
switch (words[4]) {
case 'BOOT':
setIfExists(words[2] + '.' + 'BOOST', !getState(words[2] + '.' + 'BOOST').val);
break;
case 'PART':
setIfExists(words[2] + '.' + 'PARTY', !getState(words[2] + '.' + 'PARTY').val);
break;
case 'AUTT':
setIfExists(words[2] + '.' + 'AUTOMATIC', !getState(words[2] + '.' + 'AUTOMATIC').val);
break;
case 'MANT':
setIfExists(words[2] + '.' + 'MANUAL', !getState(words[2] + '.' + 'MANUAL').val);
break;
case 'VACT':
setIfExists(words[2] + '.' + 'VACATION', !getState(words[2] + '.' + 'VACATION').val);
break;
}
let modes = ['BOOT', 'PART', 'AUTT', 'MANT', 'VACT'];
let modesDP = ['BOOST', 'PARTY', 'AUTOMATIC', 'MANUAL', 'VACATION'];
for (let mode=0; mode < 5; mode++) {
if (words[4] != modes[mode]) {
setIfExists(words[2] + '.' + modesDP[mode], false);
}
}
GeneratePage(config.pages[pageId]);
} else {
let HVACMode = 0;
switch (words[4]) {
case 'POWER':
HVACMode = 0;
setIfExists(words[2] + '.' + words[4], !getState(words[2] + '.' + words[4]).val);
if (getState(words[2] + '.' + words[4]).val) {
HVACMode = 1;
}
break;
case 'AUTO':
HVACMode = 1;
break;
case 'COOL':
HVACMode = 2;
break;
case 'HEAT':
HVACMode = 3;
break;
case 'ECO':
HVACMode = 4;
break;
case 'FAN':
HVACMode = 5;
break;
case 'DRY':
HVACMode = 6;
break;
case 'SWING':
HVACMode = getState(words[2] + '.MODE').val;
if (getState(words[2] + '.SWING').val == 0) {
setIfExists(words[2] + '.SWING', 1);
} else {
setIfExists(words[2] + '.' + 'SWING', 0);
}
break;
}
setIfExists(words[2] + '.' + 'MODE', HVACMode);
GeneratePage(config.pages[pageId]);
}
break;
case 'mode-modus1':
let pageItemT1 = findPageItem(id);
setIfExists(id + '.' + pageItemT1.setThermoAlias[0], pageItemT1.popupThermoMode1[parseInt(words[4])]);
break;
case 'mode-modus2':
let pageItemT2 = findPageItem(id);
setIfExists(id + '.' + pageItemT2.setThermoAlias[1], pageItemT2.popupThermoMode2[parseInt(words[4])]);
break;
case 'mode-modus3':
let pageItemT3 = findPageItem(id);
setIfExists(id + '.' + pageItemT3.setThermoAlias[2], pageItemT3.popupThermoMode3[parseInt(words[4])]);
break;
case 'number-set':
let nobj = getObject(id);
switch (nobj.common.role) {
case 'level.mode.fan':
(function () { if (timeoutSlider) { clearTimeout(timeoutSlider); timeoutSlider = null; } })();
timeoutSlider = setTimeout(async function () {
setIfExists(id + '.SPEED', parseInt(words[4]));
}, 250);
break;
default:
(function () { if (timeoutSlider) { clearTimeout(timeoutSlider); timeoutSlider = null; } })();
timeoutSlider = setTimeout(async function () {
setIfExists(id + '.SET', parseInt(words[4])) ? true : setIfExists(id + '.ACTUAL', parseInt(words[4]));
}, 250);
break;
}
break;
case 'mode-preset_modes':
setIfExists(id + '.MODE', parseInt(words[4]));
break;
case 'A1': // Alarm-Page Alarm 1 aktivieren
if (words[4] != '') {
setIfExists(id + '.TYPE', 'A1');
setIfExists(id + '.PIN', words[4]);
setIfExists(id + '.ACTUAL', 'arming');
setIfExists(id + '.PANEL', NSPanel_Path);
}
setTimeout(function(){
GeneratePage(activePage);
},250);
break;
case 'A2': // Alarm-Page Alarm 2 aktivieren
if (words[4] != '') {
setIfExists(id + '.TYPE', 'A2');
setIfExists(id + '.PIN', words[4]);
setIfExists(id + '.ACTUAL', 'arming');
setIfExists(id + '.PANEL', NSPanel_Path);
}
setTimeout(function(){
GeneratePage(activePage);
},250);
break;
case 'A3': // Alarm-Page Alarm 3 aktivieren
if (words[4] != '') {
setIfExists(id + '.TYPE', 'A3');
setIfExists(id + '.PIN', words[4]);
setIfExists(id + '.ACTUAL', 'arming');
setIfExists(id + '.PANEL', NSPanel_Path);
}
setTimeout(function(){
GeneratePage(activePage);
},250);
break;
case 'A4': // Alarm-Page Alarm 4 aktivieren
if (words[4] != '') {
setIfExists(id + '.TYPE', 'A4');
setIfExists(id + '.PIN', words[4]);
setIfExists(id + '.ACTUAL', 'arming');
setIfExists(id + '.PANEL', NSPanel_Path);
}
setTimeout(function(){
GeneratePage(activePage);
},250);
break;
case 'D1': // Alarm-Page Alarm Deaktivieren
if (Debug) {
console.log('D1: ' + getState(id + '.PIN').val);
}
if (Debug) {
console.log(words[4]);
}
if (words[4] != '') {
if (getState(id + '.PIN').val == words[4]) {
setIfExists(id + '.PIN', '0000');
setIfExists(id + '.TYPE', 'D1');
setIfExists(id + '.ACTUAL', 'pending');
setIfExists(id + '.PIN_Failed', 0);
} else {
setIfExists(id + '.PIN_Failed', getState(id + '.PIN_Failed').val + 1);
setIfExists(id + '.ACTUAL', 'triggered');
}
setIfExists(id + '.PANEL', NSPanel_Path);
setTimeout(function(){
GeneratePage(activePage);
},500);
}
break;
default:
break;
}
} catch (err) {
console.log('function HandleButtonEvent: ' + err.message);
}
}