Skip to content

Commit

Permalink
Merge pull request #1292 from ticaki/main
Browse files Browse the repository at this point in the history
Error due to an empty character string when subscribing to icon IDs
  • Loading branch information
Armilar authored Jan 11, 2025
2 parents 8184c10 + c9deae3 commit c83921c
Showing 1 changed file with 12 additions and 20 deletions.
32 changes: 12 additions & 20 deletions ioBroker/DEV/NSPanelTs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ ReleaseNotes:
- 22.11.2024 - v4.4.0.10 Fix: Bug #1266 trigger timeoutScreensaver
- 22.11.2024 - v4.4.0.11 Add new value 'PopupNotify' to ActivePage
- 07.12.2024 - v4.4.0.12 Add JSDocs and some small fixes
- 11.01.2025 - v4.4.0.13 Error due to an empty character string when subscribing to icon IDs

Todo:
- XX.12.2024 - v5.0.0 ioBroker Adapter
Expand Down Expand Up @@ -1006,7 +1007,7 @@ export const config: Config = {
// _________________________________ DE: Ab hier keine Konfiguration mehr _____________________________________
// _________________________________ EN: No more configuration from here _____________________________________

const scriptVersion: string = 'v4.4.0.12';
const scriptVersion: string = 'v4.4.0.13';
const tft_version: string = 'v4.4.0';
const desired_display_firmware_version = 53;
const berry_driver_version = 9;
Expand Down Expand Up @@ -2385,26 +2386,16 @@ on({ id: [String(NSPanel_Path) + 'Relay.1', String(NSPanel_Path) + 'Relay.2'], c
*/
async function SubscribeMRIcons() {
try {
let arr = config.mrIcon1ScreensaverEntity.ScreensaverEntity != null ? [config.mrIcon1ScreensaverEntity.ScreensaverEntity] : [];
arr = config.mrIcon1ScreensaverEntity.ScreensaverEntityValue != null ? [...arr, config.mrIcon1ScreensaverEntity.ScreensaverEntityValue] : arr;
if (arr.length > 0) {
on({ id: arr, change: 'ne' }, async function (obj) {
if (obj.id!.substring(0, 4) == 'mqtt') {
let Button = obj.id!.split('.');
if (getState(NSPanel_Path + 'Relay.' + Button[Button.length - 1].substring(5, 6)).val != obj.state.val) {
await setStateAsync(NSPanel_Path + 'Relay.' + Button[Button.length - 1].substring(5, 6), obj.state.val == 'ON' ? true : false);
}
} else {
HandleScreensaverStatusIcons();
}
});
const mrEntities = [config.mrIcon1ScreensaverEntity, config.mrIcon2ScreensaverEntity];
let arr: string[] = []
for (const mrEntity of mrEntities) {
arr = typeof mrEntity.ScreensaverEntity == 'string' && mrEntity.ScreensaverEntity !== '' ? [mrEntity.ScreensaverEntity] : [];
arr = typeof mrEntity.ScreensaverEntityValue == 'string' && mrEntity.ScreensaverEntityValue !== '' ? [...arr, mrEntity.ScreensaverEntityValue] : arr;
}
arr = config.mrIcon2ScreensaverEntity.ScreensaverEntity != null ? [config.mrIcon2ScreensaverEntity.ScreensaverEntity] : [];
arr = config.mrIcon2ScreensaverEntity.ScreensaverEntityValue != null ? [...arr, config.mrIcon2ScreensaverEntity.ScreensaverEntityValue] : arr;
if (arr.length > 0) {
on({ id: arr, change: 'ne' }, async function (obj) {
if (obj.id!.substring(0, 4) == 'mqtt') {
let Button = obj.id!.split('.');
if (obj.id && obj.id.substring(0, 4) == 'mqtt') {
let Button = obj.id.split('.');
if (getState(NSPanel_Path + 'Relay.' + Button[Button.length - 1].substring(5, 6)).val != obj.state.val) {
await setStateAsync(NSPanel_Path + 'Relay.' + Button[Button.length - 1].substring(5, 6), obj.state.val == 'ON' ? true : false);
}
Expand All @@ -2413,6 +2404,7 @@ async function SubscribeMRIcons() {
}
});
}

} catch (err: any) {
log('error at function SubscribeMRIcons: ' + err.message, 'warn');
}
Expand Down Expand Up @@ -3252,7 +3244,7 @@ let scheduleSwichScreensaver = adapterSchedule(undefined, screensaverChangeTime,

function InitHWButton1Color() {
try {
if (config.mrIcon1ScreensaverEntity.ScreensaverEntity != null || config.mrIcon1ScreensaverEntity.ScreensaverEntity != undefined) {
if ([null, undefined, ''].indexOf(config.mrIcon1ScreensaverEntity.ScreensaverEntity) == -1) {
on({ id: config.mrIcon1ScreensaverEntity.ScreensaverEntity, change: 'ne' }, async function () {
HandleScreensaverUpdate();
});
Expand Down Expand Up @@ -3280,7 +3272,7 @@ InitHWButton1Color();
*/
function InitHWButton2Color() {
try {
if (config.mrIcon2ScreensaverEntity.ScreensaverEntity != null || config.mrIcon2ScreensaverEntity.ScreensaverEntity != undefined) {
if ([null, undefined, ''].indexOf(config.mrIcon2ScreensaverEntity.ScreensaverEntity) == -1 ) {
on({ id: config.mrIcon2ScreensaverEntity.ScreensaverEntity, change: 'ne' }, async function () {
HandleScreensaverUpdate();
});
Expand Down

0 comments on commit c83921c

Please sign in to comment.