Create Alias for PageAlarm
This commit is contained in:
Thomas
2023-11-18 21:20:27 +01:00
parent 367bdaf8d6
commit cc21d555c5

View File

@@ -4699,14 +4699,25 @@ function GenerateAlarmPage(page: PageAlarm): Payload[] {
out_msgs.push({ payload: 'pageType~cardAlarm' });
let nsPath = NSPanel_Alarm_Path + 'Alarm.';
if (existsState(nsPath + 'AlarmPin') == false || existsState(nsPath + 'AlarmState') == false || existsState(nsPath + 'AlarmType') == false || existsState(nsPath + 'PIN_Failed') == false || existsState(nsPath + 'PANEL') == false) {
createState(nsPath + 'AlarmPin', '0000', { type: 'string' }, function () { setState(nsPath + 'AlarmPin', '0000') });
createState(nsPath + 'AlarmState', 'disarmed', { type: 'string' }, function () { setState(nsPath + 'AlarmState', 'disarmed') });
createState(nsPath + 'AlarmType', 'D1', { type: 'string' }, function () { setState(nsPath + 'AlarmType', 'D1') });
createState(nsPath + 'PIN_Failed', 0, { type: 'number' }, function () { setState(nsPath + 'PIN_Failed', 0) });
createState(nsPath + 'PANEL', NSPanel_Path, { type: 'string' }, function () { setState(nsPath + 'PANEL', NSPanel_Path) });
if (isSetOptionActive) {
if (existsState(nsPath + 'AlarmPin') == false || existsState(nsPath + 'AlarmState') == false || existsState(nsPath + 'AlarmType') == false || existsState(nsPath + 'PIN_Failed') == false || existsState(nsPath + 'PANEL') == false) {
createState(nsPath + 'AlarmPin', '0000', { type: 'string' }, function () { setState(nsPath + 'AlarmPin', '0000') });
createState(nsPath + 'AlarmState', 'disarmed', { type: 'string' }, function () { setState(nsPath + 'AlarmState', 'disarmed') });
createState(nsPath + 'AlarmType', 'D1', { type: 'string' }, function () { setState(nsPath + 'AlarmType', 'D1') });
createState(nsPath + 'PIN_Failed', 0, { type: 'number' }, function () { setState(nsPath + 'PIN_Failed', 0) });
createState(nsPath + 'PANEL', NSPanel_Path, { type: 'string' }, function () { setState(nsPath + 'PANEL', NSPanel_Path) });
if (autoCreateAlias) {
setObject(AliasPath + 'Alarm', {type: 'channel', common: {role: 'sensor.alarm.fire', name:'Alarm'}, native: {}});
await createAliasAsync(AliasPath + 'Alarm.ACTUAL', nsPath + 'AlarmState', true, <iobJS.StateCommon>{ type: 'string', role: 'state', name: 'ACTUAL' });
await createAliasAsync(AliasPath + 'Alarm.PIN', nsPath + 'AlarmPin', true, <iobJS.StateCommon>{ type: 'string', role: 'state', name: 'PIN' });
await createAliasAsync(AliasPath + 'Alarm.TYPE', nsPath + 'AlarmType', true, <iobJS.StateCommon>{ type: 'string', role: 'state', name: 'TYPE' });
await createAliasAsync(AliasPath + 'Alarm.PIN_Failed', nsPath + 'PIN_Failed', true, <iobJS.StateCommon>{ type: 'string', role: 'state', name: 'PIN_Failed' });
await createAliasAsync(AliasPath + 'Alarm.PANEL', nsPath + 'PANEL', true, <iobJS.StateCommon>{ type: 'string', role: 'state', name: 'PANEL' });
}
}
}
if (existsState(nsPath + 'AlarmPin') && existsState(nsPath + 'AlarmState') && existsState(nsPath + 'AlarmType')) {
//let entityPin = getState(nsPath + 'AlarmPin').val;
let entityState = getState(nsPath + 'AlarmState').val;