Compare commits

...

3 Commits

Author SHA1 Message Date
Armilar
a12bc03dd7 v4.3.3.42 - DEVUpdate NSPanelTs.ts
Elapsed Fixes in cardMedia
2024-02-07 13:28:46 +01:00
Armilar
6b1a65f8f4 v4.3.3.42 - Update NSPanelTs.ts
Minor Fixes in cardMedia
2024-02-07 11:25:58 +01:00
Thomas
9d94155480 Update NSPanelTs.ts
Fix: bottomScreensaverEntity[i].ScreensaverEntityIconColor
Zeile 8899
2024-02-07 10:38:59 +01:00

View File

@@ -1,5 +1,5 @@
/*-----------------------------------------------------------------------
TypeScript v4.3.3.41 zur Steuerung des SONOFF NSPanel mit dem ioBroker by @Armilar / @TT-Tom / @ticaki / @Britzelpuf / @Sternmiere / @ravenS0ne
TypeScript v4.3.3.42 zur Steuerung des SONOFF NSPanel mit dem ioBroker by @Armilar / @TT-Tom / @ticaki / @Britzelpuf / @Sternmiere / @ravenS0ne
- abgestimmt auf TFT 53 / v4.3.3 / BerryDriver 9 / Tasmota 13.3.0
@joBr99 Projekt: https://github.com/joBr99/nspanel-lovelace-ui/tree/main/ioBroker
NsPanelTs.ts (dieses TypeScript in ioBroker) Stable: https://github.com/joBr99/nspanel-lovelace-ui/blob/main/ioBroker/NsPanelTs.ts
@@ -111,6 +111,7 @@ ReleaseNotes:
- 05.02.2024 - v4.3.3.40 Fix: SqueezeboxRPC-Media-Player and add some Functions
- 06.02.2024 - v4.3.3.41 Fix: activeBrightness -> null
- 06.02.2024 - v4.3.3.41 Fix: bHome -> corrected PageId
- 07.02.2024 - v4.3.3.42 Minor Fixes
Todo:
@@ -978,7 +979,7 @@ export const config: Config = {
// _________________________________ DE: Ab hier keine Konfiguration mehr _____________________________________
// _________________________________ EN: No more configuration from here _____________________________________
const scriptVersion: string = 'v4.3.3.41';
const scriptVersion: string = 'v4.3.3.42';
const tft_version: string = 'v4.3.3';
const desired_display_firmware_version = 53;
const berry_driver_version = 9;
@@ -4823,7 +4824,23 @@ function subscribeMediaSubscriptionsBoseAdd(id: string): void {
}
function subscribeMediaSubscriptionsSqueezeboxAdd(id: string): void {
on({id: [id + '.ELAPSED'], change: "any"}, async function () {
on({id: [id + '.DURATION',
id + '.ELAPSED'], change: "any"}, async function () {
(function () { if (timeoutMedia) { clearTimeout(timeoutMedia); timeoutMedia = null; } })();
timeoutMedia = setTimeout(async function () {
if (useMediaEvents) {
GeneratePage(activePage!);
setTimeout(async function () {
GeneratePage(activePage!);
}, 50);
}
},50)
});
}
function subscribeMediaSubscriptionsSpotifyAdd(id: string): void {
on({id: [id + '.DURATION',
id + '.ELAPSED'], change: "any"}, async function () {
(function () { if (timeoutMedia) { clearTimeout(timeoutMedia); timeoutMedia = null; } })();
timeoutMedia = setTimeout(async function () {
if (useMediaEvents) {
@@ -4961,6 +4978,13 @@ async function createAutoMediaAlias (id: string, mediaDevice: string, adapterPla
log('error at function createAutoMediaAlias Adapter spotify-premium: ' + err.message, 'warn');
}
}
//Add Spotify Datapoints > v4.3.3.42
//Spotify-Premium has Role value and a known Bug in player.progress
if (existsObject(id + '.DURATION') == false) {
const dpPath: string = adapterPlayerInstance;
await createAliasAsync(id + '.DURATION', dpPath + 'player.duration', true, <iobJS.StateCommon> {type: 'string', role: 'media.duration.text', name: 'DURATION'});
await createAliasAsync(id + '.ELAPSED', dpPath + 'player.progress', true, <iobJS.StateCommon> {type: 'string', role: 'media.elapsed.text', name: 'ELAPSED'});
}
}
break;
@@ -5126,6 +5150,8 @@ function GenerateMediaPage(page: NSPanel.PageMedia): NSPanel.Payload[] {
subscribeMediaSubscriptionsBoseAdd(page.items[0].id);
} else if (v2Adapter == 'squeezeboxrpc') {
subscribeMediaSubscriptionsSqueezeboxAdd(page.items[0].id);
} else if (v2Adapter == 'spotify-premium') {
subscribeMediaSubscriptionsSpotifyAdd(page.items[0].id);
}
}
}
@@ -5141,6 +5167,8 @@ function GenerateMediaPage(page: NSPanel.PageMedia): NSPanel.Payload[] {
subscribeMediaSubscriptionsBoseAdd(page.items[0].id);
} else if (v2Adapter == 'squeezeboxrpc') {
subscribeMediaSubscriptionsSqueezeboxAdd(page.items[0].id);
} else if (v2Adapter == 'spotify-premium') {
subscribeMediaSubscriptionsSpotifyAdd(page.items[0].id);
}
} else if (page.type == 'cardMedia' && pageCounter == -1) {
//Do Nothing
@@ -5151,8 +5179,8 @@ function GenerateMediaPage(page: NSPanel.PageMedia): NSPanel.Payload[] {
if (existsObject(id)) {
let name = getState(id + '.ALBUM').val;
let title = getState(id + '.TITLE').val;
if (title.length > 27) {
title = title.slice(0, 27) + '...';
if (title.length > 26) {
title = title.slice(0, 26) + '...';
}
if (existsObject(id + '.DURATION') && existsObject(id + '.ELAPSED')) {
if (v2Adapter == 'alexa2') {
@@ -5173,8 +5201,15 @@ function GenerateMediaPage(page: NSPanel.PageMedia): NSPanel.Payload[] {
if(parseInt(vDuration.slice(0,2)) < 9) {
vDuration = vDuration.slice(1);
}
}
title = title + ' (' + vElapsed + '|' + vDuration + ')';
}
if (vDuration != '0:00') {
title = title + ' (' + vElapsed + '|' + vDuration + ')';
} else {
title = title + ' (' + vElapsed + ')';
}
if (title == ' (0:00)') {
title = '';
}
} else if (v2Adapter == 'sonos' && getState(page.items[0].adapterPlayerInstance + 'root.' + page.items[0].mediaDevice + '.current_type').val == 0) {
let vElapsed = getState(id + '.ELAPSED').val;
if (vElapsed.length == 5) {
@@ -5230,6 +5265,24 @@ function GenerateMediaPage(page: NSPanel.PageMedia): NSPanel.Payload[] {
}
}
// Settings >>Aktualisierungsintervall für Statusinformationen<< = 1 !
// If the refresh time is set to 1 second in the spotify-premium.X instance,
// the elapsed refresh bug '00:00' is not visible
if (v2Adapter == 'spotify-premium') {
let vElapsed: string = getState(id + '.ELAPSED').val;
if (vElapsed.substring(0,1) == '0') {
vElapsed = vElapsed.slice(1)
}
let vDuration: string = getState(id + '.DURATION').val;
if (vDuration.substring(0,1) == '0') {
vDuration = vDuration.slice(1)
}
title = title + ' (' + vElapsed + '|' + vDuration + ')';
if (title == ' (0:00|0:00)') {
title = '';
}
}
let shuffle = getState(id + '.SHUFFLE').val;
//New Adapter/Player
@@ -5303,9 +5356,10 @@ function GenerateMediaPage(page: NSPanel.PageMedia): NSPanel.Payload[] {
//Logitech Squeezebox RPC
if (v2Adapter == 'squeezeboxrpc') {
media_icon = Icons.GetIcon('dlna');
let nameLength = name.length;
if (nameLength == 0) {
name = page.items[0].mediaDevice;
if (name.length == 0) {
name = page.heading;
} else if (name.length > 16) {
name = name.slice(0,16) + '...'
}
}
@@ -5323,6 +5377,8 @@ function GenerateMediaPage(page: NSPanel.PageMedia): NSPanel.Payload[] {
}
if (nameLength == 0) {
name = 'Alexa Player';
} else {
name = name.slice(0,16) + '...';
}
author = getState(id + '.ARTIST').val + ' | ' + getState(id + '.ALBUM').val;
if (author.length > 30) {
@@ -5702,6 +5758,7 @@ function GenerateMediaPage(page: NSPanel.PageMedia): NSPanel.Payload[] {
}
}
async function createAutoAlarmAlias (id: string, nsPath: string){
try {
if (Debug){
@@ -8839,9 +8896,10 @@ function HandleScreensaverUpdate(): void {
iconColor + '~' +
config.bottomScreensaverEntity[4].ScreensaverEntityText + '~' +
val
}
} // Ende zusätzlichen Status Alternativ Layout
} else {
// USER definierte Bottom Entities
let checkpoint = true;
let i = 0;
for (i = 0; i < maxEntities - 1 && i < config.bottomScreensaverEntity.length; i++) {
@@ -8895,7 +8953,7 @@ function HandleScreensaverUpdate(): void {
}
}
const temp = config.bottomScreensaverEntity[4].ScreensaverEntityIconColor
const temp = config.bottomScreensaverEntity[i].ScreensaverEntityIconColor
if (temp && typeof temp == 'string' && existsObject(temp)) {
iconColor = getState(temp).val;
}