Leider komme ich nicht so oft dazu, mich um dieses Skript zu kümmern.
! ```
var path = 'javascript.'+instance+'.vis.'; // Pfad der String-Datenpunkte setVitoTimer var listh = ['setVitoTimer1hAn','setVitoTimer1hAus','setVitoTimer2hAn','setVitoTimer2hAus','setVitoTimer3hAn','setVitoTimer3hAus','setVitoTimer4hAn','setVitoTimer4hAus']; var listm = ['setVitoTimer1mAn','setVitoTimer1mAus','setVitoTimer2mAn','setVitoTimer2mAus','setVitoTimer3mAn','setVitoTimer3mAus','setVitoTimer4mAn','setVitoTimer4mAus']; var listb = ['setVitoTimerOK','setVitoTimerReset','setVitoTimerMo','setVitoTimerDi','setVitoTimerMi','setVitoTimerDo','setVitoTimerFr','setVitoTimerSa','setVitoTimerSo']; var timer1hAn = '--', timer1mAn = '--', timer1hAus = '--', timer1mAus = '--', timer1An = 1446, timer1Aus = 1446, timer1 = '1:An:--:-- Aus:--:--'; var timer2hAn = '--', timer2mAn = '--', timer2hAus = '--', timer2mAus = '--', timer2An = 1446, timer2Aus = 1446, timer2 = '2:An:--:-- Aus:--:--'; var timer3hAn = '--', timer3mAn = '--', timer3hAus = '--', timer3mAus = '--', timer3An = 1446, timer3Aus = 1446, timer3 = '3:An:--:-- Aus:--:--'; var timer4hAn = '--', timer4mAn = '--', timer4hAus = '--', timer4mAus = '--', timer4An = 1446, timer4Aus = 1446, timer4 = '4:An:--:-- Aus:--:--'; var singleDay = 'yes'; var trigger, len, i; ! //+++++ Datenpunkte setzen createState('vis.setVitoTimerBetriebsart', 0, { read: true, write: true, desc: 'vis.setVitoTimerBetriebsart', type: 'number', min: 0, max: 2, def: 0, states: '0:Heizen; 1:Warmwasser; 2:Zirkulation', }); ! createState('vis.setVitoTimerWochentage', 0, { read: true, write: true, desc: 'vis.setVitoTimerBetriebsart', type: 'number', min: 0, max: 3, def: 0, states: '0:einzeln; 1:Mo-So; 2:werktags; 3:Wochenende' }); ! len = listh.length; for(i = 0; i < len; i++){ createState('vis.'+listh[i], 0, { read: true, write: true, desc: 'vis.'+listh[i], type: 'number', min: 0, max: 24, def: 24, states: '0:00; 1:01; 2:02; 3:03; 4:04; 5:05; 6:06; 7:07; 8:08; 9:09; 10:10; 11:11; 12:12; 13:13; 14:14; 15:15; 16:16; 17:17; 18:18; 19:19; 20:20; 21:21; 22:22; 23:23; 24:--' }); } ! len = listm.length; for(i = 0; i < len; i++){ createState('vis.'+listm[i], 0, { read: true, write: true, desc: 'vis.'+listm[i], type: 'number', min: 0, max: 6, def: 6, states: '0:00; 1:10; 2:20; 3:30; 4:40; 5:50; 6:--' }); } ! len = listb.length; for(i = 0; i < len; i++){ createState('vis.'+listb[i], { read: true, write: true, desc: 'vis.'+listb[i], type: 'boolean', def: false }); } ! //+++++ Auswahl der Wochentage on({id:path+'setVitoTimerWochentage', change:'ne'}, function(obj){ switch(obj.state.val){ case 1: // Mo-So setState(path+'setVitoTimerMo', true); setState(path+'setVitoTimerDi', true); setState(path+'setVitoTimerMi', true); setState(path+'setVitoTimerDo', true); setState(path+'setVitoTimerFr', true); setState(path+'setVitoTimerSa', true); setState(path+'setVitoTimerSo', true); singleDay = 'no'; break; case 2: // werktags setState(path+'setVitoTimerMo', true); setState(path+'setVitoTimerDi', true); setState(path+'setVitoTimerMi', true); setState(path+'setVitoTimerDo', true); setState(path+'setVitoTimerFr', true); setState(path+'setVitoTimerSa', false); setState(path+'setVitoTimerSo', false); singleDay = 'no'; break; case 3: // Wochenende setState(path+'setVitoTimerMo', false); setState(path+'setVitoTimerDi', false); setState(path+'setVitoTimerMi', false); setState(path+'setVitoTimerDo', false); setState(path+'setVitoTimerFr', false); setState(path+'setVitoTimerSa', true); setState(path+'setVitoTimerSo', true); singleDay = 'no'; break; } }); ! /* var trigger = new RegExp(path+'setVitoTimer[MDFS]./r>); on({id:trigger, change:'ne'}, function(){ // einzelne Wochentage if(singleDay === 'yes'){ setState(path+'setVitoTimerWochentage', 0); } }); */ ! //+++++ Einstellung der Timer-Werte //----- Zeitraum Nr. 1 trigger = new RegExp(path+'setVitoTimer1+'); on({id:trigger, change:'ne'}, function(){ timer1hAn = getState(path+'setVitoTimer1hAn').val; timer1mAn = getState(path+'setVitoTimer1mAn').val; timer1hAus = getState(path+'setVitoTimer1hAus').val; timer1mAus = getState(path+'setVitoTimer1mAus').val; timer1An = 60*timer1hAn+timer1mAn; timer1Aus = 60*timer1hAus+timer1mAus; if(timer1An >= timer1Aus){ setState(path+'setVitoTimer1hAn', 24); setState(path+'setVitoTimer1mAn', 6); setState(path+'setVitoTimer1hAus', 24); setState(path+'setVitoTimer1mAus', 6); timer1hAn = '--'; timer1mAn = '--'; timer1hAus = '--'; timer1mAus = '--'; timer1An = 1446; timer1Aus = 1446; } switch(timer1hAn){case 0: timer1hAn = '00'; break; case 1: timer1hAn = '01'; break; case 2: timer1hAn = '02'; break; case 3: timer1hAn = '03'; break; case 4: timer1hAn = '04'; break; case 5: timer1hAn = '05'; break; case 6: timer1hAn = '06'; break; case 7: timer1hAn = '07'; break; case 8: timer1hAn = '08'; break; case 9: timer1hAn = '09'; break; } switch(timer1mAn){case 0: timer1mAn = '00'; break; case 1: timer1mAn = '10'; break; case 2: timer1mAn = '20'; break; case 3: timer1mAn = '30'; break; case 4: timer1mAn = '40'; break; case 5: timer1mAn = '50'; break; } switch(timer1hAus){case 0: timer1hAus = '00'; break; case 1: timer1hAus = '01'; break; case 2: timer1hAus = '02'; break; case 3: timer1hAus = '03'; break; case 4: timer1hAus = '04'; break; case 5: timer1hAus = '05'; break; case 6: timer1hAus = '06'; break; case 7: timer1hAus = '07'; break; case 8: timer1hAus = '08'; break; case 9: timer1hAus = '09'; break; } switch(timer1mAus){case 0: timer1mAus = '00'; break; case 1: timer1mAus = '10'; break; case 2: timer1mAus = '20'; break; case 3: timer1mAus = '30'; break; case 4: timer1mAus = '40'; break; case 5: timer1mAus = '50'; break; } timer1 = '1:An:'+timer1hAn+':'+timer1mAn+' Aus:'+timer1hAus+':'+timer1mAus; setState(path+'setVitoTimerOK', false); }); ! //----- Zeitraum Nr. 2 trigger = new RegExp(path+'setVitoTimer2+'); on({id:trigger, change:'ne'}, function(){ timer2hAn = getState(path+'setVitoTimer2hAn').val; timer2mAn = getState(path+'setVitoTimer2mAn').val; timer2hAus = getState(path+'setVitoTimer2hAus').val; timer2mAus = getState(path+'setVitoTimer2mAus').val; timer2An = 60*timer2hAn+timer2mAn; timer2Aus = 60*timer2hAus+timer2mAus; if((timer2An >= timer2Aus) || (timer1Aus >= timer2An)){ setState(path+'setVitoTimer2hAn', 24); setState(path+'setVitoTimer2mAn', 6); setState(path+'setVitoTimer2hAus', 24); setState(path+'setVitoTimer2mAus', 6); timer2hAn = '--'; timer2mAn = '--'; timer2hAus = '--'; timer2mAus = '--'; timer2An = 1446; timer2Aus = 1446; } switch(timer2hAn){case 0: timer2hAn = '00'; break; case 1: timer2hAn = '01'; break; case 2: timer2hAn = '02'; break; case 3: timer2hAn = '03'; break; case 4: timer2hAn = '04'; break; case 5: timer2hAn = '05'; break; case 6: timer2hAn = '06'; break; case 7: timer2hAn = '07'; break; case 8: timer2hAn = '08'; break; case 9: timer2hAn = '09'; break; } switch(timer2mAn){case 0: timer2mAn = '00'; break; case 1: timer2mAn = '10'; break; case 2: timer2mAn = '20'; break; case 3: timer2mAn = '30'; break; case 4: timer2mAn = '40'; break; case 5: timer2mAn = '50'; break; } switch(timer2hAus){case 0: timer2hAus = '00'; break; case 1: timer2hAus = '01'; break; case 2: timer2hAus = '02'; break; case 3: timer2hAus = '03'; break; case 4: timer2hAus = '04'; break; case 5: timer2hAus = '05'; break; case 6: timer2hAus = '06'; break; case 7: timer2hAus = '07'; break; case 8: timer2hAus = '08'; break; case 9: timer2hAus = '09'; break; } switch(timer2mAus){case 0: timer2mAus = '00'; break; case 1: timer2mAus = '10'; break; case 2: timer2mAus = '20'; break; case 3: timer2mAus = '30'; break; case 4: timer2mAus = '40'; break; case 5: timer2mAus = '50'; break; } timer2 = '2:An:'+timer2hAn+':'+timer2mAn+' Aus:'+timer2hAus+':'+timer2mAus; setState(path+'setVitoTimerOK', false); }); ! //----- Zeitraum Nr. 3 trigger = new RegExp(path+'setVitoTimer3+'); on({id:trigger, change:'ne'}, function(){ timer3hAn = getState(path+'setVitoTimer3hAn').val; timer3mAn = getState(path+'setVitoTimer3mAn').val; timer3hAus = getState(path+'setVitoTimer3hAus').val; timer3mAus = getState(path+'setVitoTimer3mAus').val; timer3An = 60*timer3hAn+timer3mAn; timer3Aus = 60*timer3hAus+timer3mAus; if((timer3An >= timer3Aus) || (timer1Aus >= timer3An) || (timer2Aus >= timer3An)){ setState(path+'setVitoTimer3hAn', 24); setState(path+'setVitoTimer3mAn', 6); setState(path+'setVitoTimer3hAus', 24); setState(path+'setVitoTimer3mAus', 6); timer3hAn = '--'; timer3mAn = '--'; timer3hAus = '--'; timer3mAus = '--'; timer3An = 1446; timer3Aus = 1446; } switch(timer3hAn){case 0: timer3hAn = '00'; break; case 1: timer3hAn = '01'; break; case 2: timer3hAn = '02'; break; case 3: timer3hAn = '03'; break; case 4: timer3hAn = '04'; break; case 5: timer3hAn = '05'; break; case 6: timer3hAn = '06'; break; case 7: timer3hAn = '07'; break; case 8: timer3hAn = '08'; break; case 9: timer3hAn = '09'; break; } switch(timer3mAn){case 0: timer3mAn = '00'; break; case 1: timer3mAn = '10'; break; case 2: timer3mAn = '20'; break; case 3: timer3mAn = '30'; break; case 4: timer3mAn = '40'; break; case 5: timer3mAn = '50'; break; } switch(timer3hAus){case 0: timer3hAus = '00'; break; case 1: timer3hAus = '01'; break; case 2: timer3hAus = '02'; break; case 3: timer3hAus = '03'; break; case 4: timer3hAus = '04'; break; case 5: timer3hAus = '05'; break; case 6: timer3hAus = '06'; break; case 7: timer3hAus = '07'; break; case 8: timer3hAus = '08'; break; case 9: timer3hAus = '09'; break; } switch(timer3mAus){case 0: timer3mAus = '00'; break; case 1: timer3mAus = '10'; break; case 2: timer3mAus = '20'; break; case 3: timer3mAus = '30'; break; case 4: timer3mAus = '40'; break; case 5: timer3mAus = '50'; break; } timer3 = '3:An:'+timer3hAn+':'+timer3mAn+' Aus:'+timer3hAus+':'+timer3mAus; setState(path+'setVitoTimerOK', false); }); ! //----- Zeitraum Nr. 4 trigger = new RegExp(path+'setVitoTimer4+'); on({id:trigger, change:'ne'}, function(){ timer4hAn = getState(path+'setVitoTimer4hAn').val; timer4mAn = getState(path+'setVitoTimer4mAn').val; timer4hAus = getState(path+'setVitoTimer4hAus').val; timer4mAus = getState(path+'setVitoTimer4mAus').val; timer4An = 60*timer4hAn+timer4mAn; timer4Aus = 60*timer4hAus+timer4mAus; if((timer4An >= timer4Aus) || (timer1Aus >= timer4An) || (timer2Aus >= timer4An) || (timer3Aus >= timer4An)){ setState(path+'setVitoTimer4hAn', 24); setState(path+'setVitoTimer4mAn', 6); setState(path+'setVitoTimer4hAus', 24); setState(path+'setVitoTimer4mAus', 6); timer4hAn = '--'; timer4mAn = '--'; timer4hAus = '--'; timer4mAus = '--'; timer4An = 1446; timer4Aus = 1446; } switch(timer4hAn){case 0: timer4hAn = '00'; break; case 1: timer4hAn = '01'; break; case 2: timer4hAn = '02'; break; case 3: timer4hAn = '03'; break; case 4: timer4hAn = '04'; break; case 5: timer4hAn = '05'; break; case 6: timer4hAn = '06'; break; case 7: timer4hAn = '07'; break; case 8: timer4hAn = '08'; break; case 9: timer4hAn = '09'; break; } switch(timer4mAn){case 0: timer4mAn = '00'; break; case 1: timer4mAn = '10'; break; case 2: timer4mAn = '20'; break; case 3: timer4mAn = '30'; break; case 4: timer4mAn = '40'; break; case 5: timer4mAn = '50'; break; } switch(timer4hAus){case 0: timer4hAus = '00'; break; case 1: timer4hAus = '01'; break; case 2: timer4hAus = '02'; break; case 3: timer4hAus = '03'; break; case 4: timer4hAus = '04'; break; case 5: timer4hAus = '05'; break; case 6: timer4hAus = '06'; break; case 7: timer4hAus = '07'; break; case 8: timer4hAus = '08'; break; case 9: timer4hAus = '09'; break; } switch(timer4mAus){case 0: timer4mAus = '00'; break; case 1: timer4mAus = '10'; break; case 2: timer4mAus = '20'; break; case 3: timer4mAus = '30'; break; case 4: timer4mAus = '40'; break; case 5: timer4mAus = '50'; break; } timer4 = '4:An:'+timer4hAn+':'+timer4mAn+' Aus:'+timer4hAus+':'+timer4mAus; setState(path+'setVitoTimerOK', false); }); ! //+++++ Zurücksetzen aller Timer-Werte mit Reset-Button on({id:path+'setVitoTimerReset', change:'any', val:'true'}, function(){ setState(path+'setVitoTimer1hAn', 24); setState(path+'setVitoTimer1mAn', 6); setState(path+'setVitoTimer1hAus', 24); setState(path+'setVitoTimer1mAus', 6); timer1hAn = '--'; timer1mAn = '--'; timer1hAus = '--'; timer1mAus = '--'; timer1An = 1446; timer1Aus = 1446; setState(path+'setVitoTimer2hAn', 24); setState(path+'setVitoTimer2mAn', 6); setState(path+'setVitoTimer2hAus', 24); setState(path+'setVitoTimer2mAus', 6); timer2hAn = '--'; timer2mAn = '--'; timer2hAus = '--'; timer2mAus = '--'; timer2An = 1446; timer2Aus = 1446; setState(path+'setVitoTimer3hAn', 24); setState(path+'setVitoTimer3mAn', 6); setState(path+'setVitoTimer3hAus', 24); setState(path+'setVitoTimer3mAus', 6); timer3hAn = '--'; timer3mAn = '--'; timer3hAus = '--'; timer3mAus = '--'; timer3An = 1446; timer3Aus = 1446; setState(path+'setVitoTimer4hAn', 24); setState(path+'setVitoTimer4mAn', 6); setState(path+'setVitoTimer4hAus', 24); setState(path+'setVitoTimer4mAus', 6); timer4hAn = '--'; timer4mAn = '--'; timer4hAus = '--'; timer4mAus = '--'; timer4An = 1446; timer4Aus = 1446; setState(path+'setVitoTimerOK', false); }); ! //+++++ Setzen der Timer-Werte mit OK-Button on({id:path+'setVitoTimerOK', change:'any', val:'true'}, function(){ if(timer1Aus > 0){ var service = getState(path+'setVitoTimerBetriebsart').val; log(service); log(timer1+' '+timer2+' '+timer3+' '+timer4); } });
! Zugegeben, es sieht ziemlich länglich aus. Wie das nachfolgende Video zeigt, scheint es aber größtenteils so zu funktionieren, wie ich mir das wünsche.
!
! Allerdings erhalte ich im Editor eine Warnung in Zeile 252 mit dem Hinweis: "Too many errors. (71% scanned)."
! Jemand eine Idee? Vielleicht der Hinweis, dass ich diese Meldung erst erhalten haben, nachdem ich die ganzen Switch-Cases einfügte. Gibt es da vielleicht eine Möglichkeit, mit einer Alternative zu "getState("...").val" direkt den Statuswert anstatt des Indexes zu erhalten? Also z.B. statt des Indizes "1" den zugehörigen Wert "01"?[/i][/i][/i][/i][/i][/i]