Voici mon code, si cela t'interresse pour les blinds, je ne voulais pas "pouvoir" ouvrir un volet ouvert, du coup j'ai tout repris à ma sauce, la gestion de % aussi.
Code : Tout sélectionner
//blinds
var blind1 = ['<img src=', $.domoticzurl, '/images/blinds48sel.png hspace=1 width=40 onclick="SwitchToggle(', item.idx, ', \'Off\',', txt_blind_up, ',', item.Protected, ')">'].join('');
var blind2 = ['<img src=', $.domoticzurl, '/images/blindsopen48sel.png hspace=1 width=40 onclick="SwitchToggle(', item.idx, ', \'On\',', txt_blind_down, ',', item.Protected, ')">'].join('');
var blind3 = ['<img src=', $.domoticzurl, '/images/blinds48sel.png hspace=1 width=40 onclick="SwitchToggle(', item.idx, ', \'On\',', txt_blind_up, ',', item.Protected, ')">'].join('');
var blind4 = ['<img src=', $.domoticzurl, '/images/blindsopen48sel.png hspace=1 width=40 onclick="SwitchToggle(', item.idx, ', \'Off\',', txt_blind_down, ',', item.Protected, ')">'].join('');
var blind5 = ['<img src=', $.domoticzurl, '/images/blinds48.png hspace=1 width=40 onclick="SwitchToggle(', item.idx, ', \'On\',', txt_blind_down, ',', item.Protected, ')">'].join('');
var blind6 = ['<img src=', $.domoticzurl, '/images/blindsopen48.png hspace=1 width=40 onclick="SwitchToggle(', item.idx, ', \'Off\',', txt_blind_up, ',', item.Protected, ')">'].join('');
var blind7 = ['<img src=', $.domoticzurl, '/images/blinds48.png hspace=1 width=40 onclick="SwitchToggle(', item.idx, ', \'Off\',', txt_blind_up, ',', item.Protected, ')">'].join('');
var blind8 = ['<img src=', $.domoticzurl, '/images/blindsopen48.png hspace=1 width=40 onclick="SwitchToggle(', item.idx, ', \'On\',', txt_blind_down, ',', item.Protected, ')">'].join('');
var stop = ['<img src=', $.domoticzurl, '/images/blindsstop.png hspace=1 height=40 onclick="SwitchToggle(', item.idx, ', \'Stop\',', txt_blind_stop, ',', item.Protected, ')">'].join('');
if (vdata === 'Closed' && (item.SwitchType === 'Blinds' || item.SwitchType === 'Venetian Blinds EU' || item.SwitchType === 'Venetian Blinds US')) {
vdata = [blind1].join('');
}else if (vdata === 'Open' && (item.SwitchType === 'Blinds' || item.SwitchType === 'Venetian Blinds EU' || item.SwitchType === 'Venetian Blinds US')) {
vdata = [blind2].join('');
}else if (vdata === 'Stopped'&& (item.SwitchType === 'Blinds' || item.SwitchType === 'Venetian Blinds EU' || item.SwitchType === 'Venetian Blinds US')) {
vdata = [blind5,blind6].join('');
}else if (vdata === 'Closed' && item.SwitchType === 'Blinds Inverted') {
vdata = [blind3].join('');
}else if (vdata === 'Open' && item.SwitchType === 'Blinds Inverted') {
vdata = [blind4].join('');
}else if (vdata === 'Stopped' && item.SwitchType === 'Blinds Inverted') {
vdata = [blind7,blind8].join('');
}
if (item.Type === 'RFY' || item.SwitchType === 'Venetian Blinds EU' || item.SwitchType === 'Venetian Blinds US') {
vdata = [vdata, stop].join('');
}
if (item.Status === 'Closed' && item.SwitchType === 'Blinds Percentage') {
vdesc = [vdesc, '<span class="percent"> 100<sup> %</sup></span>'].join('');
var blindmin = ['<img src=icons/min.png vspace=4 hspace=4 width=30 onclick="DimLevel100(\'min\',100,', item.idx, ',', item.Protected, ')">'].join('');
vdata = [blind1, blindmin].join('');
}else if (item.Status === 'Open' && item.SwitchType === 'Blinds Percentage') {
var blindplus = ['<img src=icons/plus.png vspace=4 hspace=4 width=30 onclick="DimLevel100(\'plus\',0,', item.idx, ',', item.Protected, ')">'].join('');
vdesc = [vdesc, '<span class="percent"> 0<sup> %</sup></span>'].join('');
vdata = [blind2, blindplus].join('');
}else if (item.Status !== 'Open' && item.Status !== 'Closed' && item.SwitchType === 'Blinds Percentage'){
var vpercent = item.LevelInt + 1;
vdesc = [vdesc, '<span class="percent"> ', vpercent, '<sup> %</sup></span>'].join('');
if (vpercent >= 90){
var blindplus = ['<img src=icons/plus.png vspace=4 hspace=4 width=30 onclick="SwitchToggle(', item.idx, ', \'On\',', txt_blind_down, ',', item.Protected, ')">'].join('');
var blindmin = ['<img src=icons/min.png vspace=4 hspace=4 width=30 onclick="DimLevel100(\'min\',', vpercent, ',', item.idx, ',', item.Protected, ')">'].join('');
}else if(vpercent <= 10){
var blindplus = ['<img src=icons/plus.png vspace=4 hspace=4 width=30 onclick="DimLevel100(\'plus\',', vpercent, ',', item.idx, ',', item.Protected, ')">'].join('');
var blindmin = ['<img src=icons/min.png vspace=4 hspace=4 width=30 onclick="SwitchToggle(', item.idx, ', \'Off\',', txt_blind_up, ',', item.Protected, ')">'].join('');
}else{
var blindplus = ['<img src=icons/plus.png vspace=4 hspace=4 width=30 onclick="DimLevel100(\'plus\',', vpercent, ',', item.idx, ',', item.Protected, ')">'].join('');
var blindmin = ['<img src=icons/min.png vspace=4 hspace=4 width=30 onclick="DimLevel100(\'min\',', vpercent, ',', item.idx, ',', item.Protected, ')">'].join('');
}
vdata = [blindmin, blind5, blind6, blindplus].join('');
}else if (item.Status === 'Closed' && item.SwitchType === 'Blinds Percentage Inverted') {
vdesc = [vdesc, '<span class="percent"> 100<sup> %</sup></span>'].join('');
var blindmin = ['<img src=icons/min.png vspace=4 hspace=4 width=30 onclick="DimLevel100(\'min\',100,', item.idx, ',', item.Protected, ')">'].join('');
vdata = [blind3, blindmin].join('');
}else if (item.Status === 'Open' && item.SwitchType === 'Blinds Percentage Inverted') {
var blindplus = ['<img src=icons/plus.png vspace=4 hspace=4 width=30 onclick="DimLevel100(\'plus\',0,', item.idx, ',', item.Protected, ')">'].join('');
vdesc = [vdesc, '<span class="percent"> 0<sup> %</sup></span>'].join('');
vdata = [blind4, blindplus].join('');
}else if (item.Status !== 'Open' && item.Status !== 'Closed' && item.SwitchType === 'Blinds Percentage Inverted'){
var vpercent = item.LevelInt + 1;
vdesc = [vdesc, '<span class="percent"> ', vpercent, '<sup> %</sup></span>'].join('');
if (vpercent >= 90){
var blindplus = ['<img src=icons/plus.png vspace=4 hspace=4 width=30 onclick="SwitchToggle(', item.idx, ', \'Off\',', txt_blind_down, ',', item.Protected, ')">'].join('');
var blindmin = ['<img src=icons/min.png vspace=4 hspace=4 width=30 onclick="DimLevel100(\'min\',', vpercent, ',', item.idx, ',', item.Protected, ')">'].join('');
}else if(vpercent <= 10){
var blindplus = ['<img src=icons/plus.png vspace=4 hspace=4 width=30 onclick="DimLevel100(\'plus\',', vpercent, ',', item.idx, ',', item.Protected, ')">'].join('');
var blindmin = ['<img src=icons/min.png vspace=4 hspace=4 width=30 onclick="SwitchToggle(', item.idx, ', \'On\',', txt_blind_up, ',', item.Protected, ')">'].join('');
}else{
var blindplus = ['<img src=icons/plus.png vspace=4 hspace=4 width=30 onclick="DimLevel100(\'plus\',', vpercent, ',', item.idx, ',', item.Protected, ')">'].join('');
var blindmin = ['<img src=icons/min.png vspace=4 hspace=4 width=30 onclick="DimLevel100(\'min\',', vpercent, ',', item.idx, ',', item.Protected, ')">'].join('');
}
vdata = [blindmin, blind7, blind8, blindplus].join('');
}