22 Nov 2019, 17:02
@Matten-Matten sagte in Test Adapter enigma2 v1.2.x:
1.2.5 (2019-11-17)
- (Scrounger) add:
.enigma2.Timer_list
Damit kann man mit meiner Table des Material Design Wigdets Adapter ein ganz schickes Widget realisieren:
Skript um Daten aufzubereiten:
// import
const moment = require("moment");
const momentDurationFormatSetup = require("moment-duration-format");
moment.locale("de");
let enigma2AdapterTimerListId = 'enigma2.0.enigma2.Timer_list';
on({ id: enigma2AdapterTimerListId }, formatList);
function formatList() {
try {
let list = JSON.parse(getState(enigma2AdapterTimerListId).val);
let myList = [];
if (list && list !== null && list !== undefined && list !== '') {
for (var i = 0; i <= list.length - 1; i++) {
let listItem = list[i]
let startTime = moment(listItem.starTime * 1000);
let endTime = moment(listItem.endTime * 1000);
let recordDateFormatted = `${startTime.format('ddd')} ${startTime.format('DD.MM')}`
let starTimeFormatted = `${startTime.format('LT')}`
let endTimeFormatted = `${endTime.format('LT')}`
if (moment().isSame(startTime, 'day')) {
recordDateFormatted = `Heute ${startTime.format('DD.MM')}`;
} else if (moment().add(1, 'day').isSame(startTime, 'day')) {
recordDateFormatted = `Morgen ${startTime.format('DD.MM')}`;
}
let rawtitle = listItem.title;
let title = rawtitle;
let subtitle = listItem.subtitle;
if (title.includes(' - ')) {
title = rawtitle.substring(0, rawtitle.indexOf(' - ')).trim();
if (subtitle === '') {
subtitle = rawtitle.substring(rawtitle.indexOf(' - ') + 2, rawtitle.length).trim();
}
}
myList.push(
{
channelImage: `/vis.0/myImages/picons/${listItem.serviceRefName}.png`,
title: title,
recordDateFormatted: recordDateFormatted,
subtitle: subtitle,
starTimeFormatted: starTimeFormatted,
startTime: listItem.starTime,
endTimeFormatted: endTimeFormatted,
channel: listItem.channel,
}
)
}
myList.sort(function (a, b) {
// Liste sortieren nach Startzeit
return a.starTime == b.starTime ? 0 : +(a.starTime > b.starTime) || -1;
});
}
myDevices.Netzwerk.Devices.VuPlus.TimerList.setState(JSON.stringify(myList), true);
} catch (err) {
console.error(`[createList] error: ${err.message}`);
console.error(`[createList] stack: ${err.stack}`);
}
}
formatList();
Widget:
[{"tpl":"tplVis-materialdesign-Table","data":{"oid":"linkeddevices.0.Netzwerk.Devices.VuPlus.TimerList","g_fixed":false,"g_visibility":false,"g_css_font_text":false,"g_css_background":false,"g_css_shadow_padding":false,"g_css_border":false,"g_gestures":false,"g_signals":false,"g_last_change":false,"visibility-cond":"==","visibility-val":1,"visibility-groups-action":"hide","countCols":"2","tableLayout":"standard","showHeader":"true","headerTextSize":"11","showColumn0":"true","colType0":"image","textAlign0":"center","showColumn1":"true","colType1":"text","textAlign1":"left","signals-cond-0":"==","signals-val-0":true,"signals-icon-0":"/vis/signals/lowbattery.png","signals-icon-size-0":0,"signals-blink-0":false,"signals-horz-0":0,"signals-vert-0":0,"signals-hide-edit-0":false,"signals-cond-1":"==","signals-val-1":true,"signals-icon-1":"/vis/signals/lowbattery.png","signals-icon-size-1":0,"signals-blink-1":false,"signals-horz-1":0,"signals-vert-1":0,"signals-hide-edit-1":false,"signals-cond-2":"==","signals-val-2":true,"signals-icon-2":"/vis/signals/lowbattery.png","signals-icon-size-2":0,"signals-blink-2":false,"signals-horz-2":0,"signals-vert-2":0,"signals-hide-edit-2":false,"lc-type":"last-change","lc-is-interval":true,"lc-is-moment":false,"lc-format":"","lc-position-vert":"top","lc-position-horz":"right","lc-offset-vert":0,"lc-offset-horz":0,"lc-font-size":"12px","lc-font-family":"","lc-font-style":"","lc-bkg-color":"","lc-color":"","lc-border-width":"0","lc-border-style":"","lc-border-color":"","lc-border-radius":10,"lc-zindex":0,"showColumn2":"true","colType2":"text","textAlign2":"right","showColumn3":"true","colType3":"text","textAlign3":"center","imageSize0":"50","sortKey1":"channel","showColumn4":"true","colType4":"text","textAlign4":"center","showColumn5":"true","colType5":"text","textAlign5":"center","showColumn6":"true","colType6":"text","textAlign6":"center","showColumn7":"true","colType7":"text","textAlign7":"center","showColumn8":"true","colType8":"text","textAlign8":"center","label0":"Kanal","label1":"Aufnahme","label2":"Zeit","padding_left0":"6","colorHeaderRowText":"#ffffff","colorRowBackground":"","colorHeaderRowBackground":"#44739e","headerFontFamily":"RobotoCondensed-Regular","rowHeight":"","suffix1":"<br>\n<span style=\"display: inline-block; white-space: nowrap; overflow: hidden !important; text-overflow: ellipsis; max-width: 170px; font-size: 12px; font-family: RobotoCondensed-LightItalic; color: #8a8a8a\">#[obj.subtitle]</span>\n","textSize1":"14","fontFamily1":"RobotoCondensed-Regular","textColor1":"#44739e","padding_right0":"6","padding_left1":"0","sortKey0":"channel","sortKey2":"startTime","fontFamily2":"RobotoCondensed-LightItalic","textSize2":"11px","suffix2":"<br>\n<span style=\"display: inline-block; white-space: nowrap; overflow: hidden !important; max-width: 150px; font-size: 12px; font-family: RobotoCondensed-LightItalic; color: #8a8a8a\">#[obj.starTimeFormatted] - #[obj.endTimeFormatted]</span>\n","padding_left2":"0","padding_right1":"0","textColor2":"#44739e"},"style":{"left":"667px","top":"16px","width":"340px","height":"372px","overflow-y":"auto"},"widgetSet":"materialdesign"}]
Zur Info ich hab die Channel picons lokal abgelegt, da meine Box nicht immer läuft.
Ihr könnt aber im Skript natürlich auch das verwenden:
@Matten-Matten sagte in Test Adapter enigma2 v1.2.x:
http://192.168.0.1:80/picon/1_0_19_2B5C_41B_1_FFFF014A_0_0_0.png