NEWS
[Script] Eieruhr
-
Hab mal wieder was gebastelt. Da ich unter Anderem auch ein Tab, in der Küche zu hängen habe, dachte ich mir, da wär doch eine Eieruhr ganz praktisch.
Man kann die Eigröße und den Gargrad auswählen, das Script errechnet daraus die Garzeit.
Wenn die Zeit abgelaufen ist, wird ein State gesetzt, der wiederum mit beliebigen Aktionen verknüppert werden kann.
ein paar kleinere Fehler sind bestimmt drin, ma kieken
Anbei das Script und ein Widget zum Testen:
// Eieruhr dna909 (heinbloed@nu-is-en.de) // ************************************************************************** // v0.1 initial // v0.2 Erweiterung Eitemperatur + Gewicht // v0.3 Formel Garzeit angepasst (13.10.2017) // ************************************************************************** // // Datenpunkte: // // start: true/false // Stop: true/false // fertig: true/false //Wert für viele tolle Dinge // Haerte: "w","m","h" //weich,medium,hart // Groesse: "s","m","l","xl" //Eigröße // Timer: "mm:ss" // Reset: true/false // Gewicht: g //Eigewicht // Temperatur: °C //Eitemperatur // Switch: true/false //true=nach Größe ; false=nach Gewicht /////////////////////////////////////////////////////////////////////////////// // Datenpunkte var instanz = "javascript.0"; var objekt = "Eieruhr"; var start = instanz+"."+objekt+"."+"start"; var fertig = instanz+"."+objekt+"."+"fertig"; var haerte = instanz+"."+objekt+"."+"Haerte"; var groesse = instanz+"."+objekt+"."+"Groesse"; var stop = instanz+"."+objekt+"."+"Stop"; var timer = instanz+"."+objekt+"."+"Timer"; var reset = instanz+"."+objekt+"."+"Reset"; var gewicht = instanz+"."+objekt+"."+"Gewicht"; var temp = instanz+"."+objekt+"."+"Temperatur"; /////////////////////////////////////////////////////////////////////////////// var SiedePunkt=100; //Siedepunkt Wasser var InnenTemp=[62,68,82]; //Kerntemperatur Eigelb (weich,medium,hart) var TempStart=7; //Eitemperatur var EiGroesse=[50,60,70,80]; //S,M,L,XL-Eigewicht /////////////////////////////////////////////////////////////////////////////// //// Initialwerte haerte_math=InnenTemp[0]; gewicht_math=EiGroesse[1]; /////////////////////////////////////////////////////////////////////////////// on({id: new RegExp( groesse +"|"+ haerte +"|"+ temp +"|"+ gewicht) , change: "ne"}, function (obj) { switch (getState(haerte).val) { case "w": haerte_math=InnenTemp[0]; break; case "m": haerte_math=InnenTemp[1]; break; case "h": haerte_math=InnenTemp[2]; break; case "": console.log("error"); break; } if (getState(gewicht).val < EiGroesse[1]){ setState(groesse, "s"); }else{ if ((getState(gewicht).val >= EiGroesse[1]) && (getState(gewicht).val < EiGroesse[2])) { setState(groesse,"m"); }else{ if ((getState(gewicht).val >= EiGroesse[2]) && (getState(gewicht).val < EiGroesse[3])) { setState(groesse,"l"); }else{ if ((getState(gewicht).val >= EiGroesse[3])) { setState(groesse,"xl"); } } } } TempStart=(getState(temp).val); gewicht_math=(getState(gewicht).val); timer1(); }); on({id: start, change: "ne"}, function (obj) { if (getState(start).val === true) { setState(fertig, false); setState(reset, false); setState(stop, false); interval = setInterval(countdown, 1000); } }); on({id: reset, change: "ne"}, function (obj) { if (getState(reset).val ===true) { clearInterval(interval); setState(start, false); setState(fertig, false); setState(reset, false); setState(stop, false); timer1(); } }); /// Berechnung der Kochzeit /////////////////////////////////////////////////// function timer1() { ze1 = 0.517*Math.pow(gewicht_math, 2/3)*Math.log (0.76*((SiedePunkt - TempStart)/(SiedePunkt-haerte_math))); ze2 = Math.round(ze1 * 60); // Kochzeit in Sekunden minuten=Math.floor(ze2/60); // Minuten sekunden=ze2 - (minuten*60); // Sekunden if (minuten < 10){ fz_m="0"; } else { fz_m=""; } if (sekunden < 10){ fz_s="0"; }else { fz_s=""; } zeit= fz_m + minuten.toString() + ":" + fz_s + sekunden.toString(); setState(timer, zeit); } // Countdown function countdown() { if (ze2 > 0 ) { if (getState(stop).val ===false) { ze2--; minuten=Math.floor(ze2/60); // Minuten sekunden=ze2 - (minuten*60); // Sekunden } if (minuten < 10){ fz_m="0"; } else { fz_m=""; } if (sekunden < 10){ fz_s="0"; }else { fz_s=""; } zeit= fz_m + minuten.toString() + ":" + fz_s + sekunden.toString(); setState(timer, zeit); } else { clearInterval(interval); setState(start, false); setState(fertig, true); setStateDelayed(fertig, false, 60000, true); } } // Datenpunkte erzeugen function createStates () { createState(start, false, { name: 'Eieruhr starten', desc: 'Eieruhr starten', type: 'boolean', role: 'state', unit: '' }); createState(fertig, false, { name: 'Eieruhr fertig', desc: 'Eieruhr fertig', type: 'boolean', role: 'state', unit: '' }); createState(haerte, "w", { name: 'Eierhärte', desc: 'Eierhärte', type: 'String', role: 'value', unit: '' }); createState(groesse, "m", { name: 'Eiergröße', desc: 'Eiergröße', type: 'string', role: 'value', unit: '' }); createState(stop, false, { name: 'Eieruhr fertig', desc: 'Eieruhr fertig', type: 'boolean', role: 'state', unit: '' }); createState(timer, "00:00", { name: 'Timer', desc: 'Timer', type: 'string', role: 'value', unit: '' }); createState(reset, false, { name: 'Eieruhr reset', desc: 'Eieruhr reset', type: 'boolean', role: 'state', unit: '' }); createState(gewicht, 50, { name: 'Eigewicht', desc: 'Eigewicht', type: 'number', role: 'value', unit: 'g' }); createState(temp, 0, { name: 'Eitemperatur', desc: 'Eitemperatur', type: 'number', role: 'value', unit: '°C' }); } /////////////////////////////////////////////////////////////////////////////// createStates(); setTimeout(timer1,1000);
Widget:
[{"tpl":"tplValueString","data":{"oid":"javascript.0.Eieruhr.Timer","g_fixed":false,"g_visibility":false,"g_css_font_text":true,"g_css_background":false,"g_css_shadow_padding":false,"g_css_border":false,"g_gestures":false,"g_signals":true,"g_last_change":false,"visibility-cond":"==","visibility-val":1,"visibility-groups-action":"hide","signals-cond-0":"==","signals-val-0":true,"signals-icon-0":"/icons-icons8/objects/black/Empty Hourglass Filled.png","signals-icon-size-0":"78","signals-blink-0":true,"signals-horz-0":"-4","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-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,"signals-oid-0":"javascript.0.Eieruhr.fertig"},"style":{"left":"80px","top":"30px","width":"297px","height":"99px","text-align":"center","text-shadow":"","font-family":"Arimo-Bold","font-size":"72px"},"widgetSet":"basic"},{"tpl":"tplJquiRadioList","data":{"oid":"javascript.0.Eieruhr.Haerte","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","values":"h;m;w","texts":"hart;mittel;weich","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-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},"style":{"left":"80px","top":"130px"},"widgetSet":"jqui"},{"tpl":"tplJquiRadioList","data":{"oid":"javascript.0.Eieruhr.Groesse","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","values":"s;m;l;xl","texts":"S;M;L;XL","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-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},"style":{"left":"100px","top":"400px"},"widgetSet":"jqui"},{"tpl":"tplJquiButtonState","data":{"oid":"javascript.0.Eieruhr.start","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","buttontext":"START","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-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,"no_style":false,"value":"true"},"style":{"left":"50px","top":"480px"},"widgetSet":"jqui"},{"tpl":"tplJquiButtonState","data":{"oid":"javascript.0.Eieruhr.Stop","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","buttontext":"STOP","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-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,"no_style":false,"value":"true"},"style":{"left":"190px","top":"480px"},"widgetSet":"jqui"},{"tpl":"tplJquiButtonState","data":{"oid":"javascript.0.Eieruhr.Reset","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","buttontext":"RESET","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-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,"no_style":false,"value":"true"},"style":{"left":"320px","top":"480px"},"widgetSet":"jqui"},{"tpl":"tplHqCircle","data":{"g_fixed":false,"g_visibility":false,"g_css_font_text":true,"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","oid":"javascript.0.Eieruhr.Temperatur","min":"3","max":"30","digits":"0","step":"1","is_comma":"true","displayPrevious":"true","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-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,"unit":"°C","caption":"Eitemperatur","cursor":"","thickness":"","linecap":false,"angleOffset":"0","oid-battery":"javascript.0.android.Galaxy S7edge.Battery_SoC","descriptionLeft":"Eitemperatur"},"style":{"left":"50px","top":"220px","width":"150px","height":"150px","color":"#FFFFFF","text-align":"center","font-family":"Arimo-Bold","font-size":"12px"},"widgetSet":"hqwidgets"},{"tpl":"tplHqCircle","data":{"g_fixed":false,"g_visibility":false,"g_css_font_text":true,"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","oid":"javascript.0.Eieruhr.Gewicht","min":"40","max":"90","digits":"0","step":"1","is_comma":"true","displayPrevious":"true","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-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,"unit":"g","caption":"Eigewicht","cursor":"","thickness":"","linecap":false,"angleOffset":"0","oid-battery":"javascript.0.android.Galaxy S7edge.Battery_SoC","descriptionLeft":"Eigewicht"},"style":{"left":"270px","top":"220px","width":"150px","height":"150px","color":"#FFFFFF","text-align":"center","font-family":"Arimo-Bold","font-size":"12px"},"widgetSet":"hqwidgets"}]
mfg dna909
-
Super Idee!
hatte mir auch etwas ähnliches gebastelt.
In deinem Script fehlen zwei Semikolons.
Hinter:
var instanz = "javascript.0";
var objekt = "Eieruhr";
Hat er jedenfalls bei mir beanstandet.
Wichtig wäre auch noch gut zu wissen, ob du die Eier ins kalte Wasser legst oder erst dem kochenden Wasser hinzu gibst.
-
Super Idee!
hatte mir auch etwas ähnliches gebastelt.
In deinem Script fehlen zwei Semikolons.
Hinter:
var instanz = "javascript.0";
var objekt = "Eieruhr";
Hat er jedenfalls bei mir beanstandet.
Wichtig wäre auch noch zu wissen, ob du die Eier ins kalte Wasser legst oder erst dem kochenden Wasser hinzu gibst. `
Hallöle,
natürlich ins kochende Wasser. ioBroker weiß ja nicht, wann das Wasser kocht :lol:
Das mit den Semikolons pass ich gleich an.
Gruß
dna909
-
Wichtig ist auch welche Temperatur die Eier beim Reinlegen ins Wasser haben..
Zimmer- oder Kühlschranktemperatur..?
Gruß
-
Werde das Script die Tage noch erweitern.
Im Script sind die Temperaturen ja hinterlegt.
Bei mir kommen die Eier gewöhnlich aus dem Kühlschrank.
dna909
-
Aber, man kann ja auf Start drücken wenn das Wasser kocht!
-
So funktioniert auch eine klassische Eieruhr [emoji4]
dna909
-
Habe das Script mal etwas erweitert/verbessert.
Die Berechnung erfolgt jetzt anhand des Gewichts. Berücksichtigung findet auch die Temperatur des Ei´s.
Das neue Script versteckt sich im ersten Beitrag.
P.S.: Widget ist auch angepasst
mfg
dna909
-
Hi,
ich bekomme beim Script folgende Fehlermeldung:
javascript.0 script.js.common.Eieruhr compile failed: SyntaxError: Unexpected token var
Und das Widget sieht unvollständig aus (oberer Bereich fehlt?):
Jemand eine Lösung für mich?
Danke euch und Grüße, Thorsten
-
Da hat der Fehlerteufel zugeschlagen. Hab die falsche Version erwischt.
Eine Zeile enthielt "var const=…", das gibt natürlich einen Compile-Error.
Script sollte jetzt wieder funktionieren.
Das Widget sieht unvollständig aus, weil der Datenpunkt für den Timer noch fehlt. Der wird ja vom Script erzeugt, aber durch den Fehler funktioniert das natürlich nicht.
Somit wird da dann auch nichts angezeigt.
Am Besten einfach nochmal probieren
mfg
dna909
-
Hallo dna909,
cooles Skript, funktioniert wunderbar. Vielen Dank dafür.
Ich lasse mir per Blockly nach Wunsch meine aktuelle Zimmertemperatur oder Kühlschranktemperatur in das Skript (bzw. Variable) eintragen, erhöht den Komfort nochmals ein bisschen.
Gruß, Marwin
-
Kein Problem
mfg
dna909
-
Hallo @dna909, funktioniert das Script bei dir noch ohne Weiteres? Bei mir wird per Javascript schon nicht mehr das "Eieruhr"-Objekt unter javascript angelegt. Danke.
-
-
Danke für deine schnelle Rückmeldung @dna909
- es werden garkeine Objekte / Datenpunkte unter Javascript.0 angelegt
- als Fehlermeldung erhalte ich im Script nun eher sporadisch folgendes:
22:01:47.246 error javascript.0 (1412) script.js.common.Eieruhr compile failed: at script.js.common.Eieruhr:22
Mein Script:
// Eieruhr dna909 (heinbloed@nu-is-en.de) // ************************************************************************** // v0.1 initial // v0.2 Erweiterung Eitemperatur + Gewicht // v0.3 Formel Garzeit angepasst (13.10.2017) // ************************************************************************** // // Datenpunkte: // // start: true/false // Stop: true/false // fertig: true/false //Wert für viele tolle Dinge // Haerte: "w","m","h" //weich,medium,hart // Groesse: "s","m","l","xl" //Eigröße // Timer: "mm:ss" // Reset: true/false // Gewicht: g //Eigewicht // Temperatur: °C //Eitemperatur // Switch: true/false //true=nach Größe ; false=nach Gewicht /////////////////////////////////////////////////////////////////////////////// ! // Datenpunkte ! var instanz = "javascript.0"; var objekt = "Eieruhr"; ! var start = instanz+"."+objekt+"."+"start"; var fertig = instanz+"."+objekt+"."+"fertig"; var haerte = instanz+"."+objekt+"."+"Haerte"; var groesse = instanz+"."+objekt+"."+"Groesse"; var stop = instanz+"."+objekt+"."+"Stop"; var timer = instanz+"."+objekt+"."+"Timer"; var reset = instanz+"."+objekt+"."+"Reset"; var gewicht = instanz+"."+objekt+"."+"Gewicht"; var temp = instanz+"."+objekt+"."+"Temperatur"; ! /////////////////////////////////////////////////////////////////////////////// var SiedePunkt=100; //Siedepunkt Wasser var InnenTemp=[62,68,82]; //Kerntemperatur Eigelb (weich,medium,hart) var TempStart=7; //Eitemperatur var EiGroesse=[50,60,70,80]; //S,M,L,XL-Eigewicht ! /////////////////////////////////////////////////////////////////////////////// ! //// Initialwerte ! haerte_math=InnenTemp[0]; gewicht_math=EiGroesse[1]; ! /////////////////////////////////////////////////////////////////////////////// ! on({id: new RegExp( groesse +"|"+ haerte +"|"+ temp +"|"+ gewicht) , change: "ne"}, function (obj) { switch (getState(haerte).val) { case "w": haerte_math=InnenTemp[0]; break; case "m": haerte_math=InnenTemp[1]; break; case "h": haerte_math=InnenTemp[2]; break; case "": console.log("error"); break; } ! if (getState(gewicht).val < EiGroesse[1]){ setState(groesse, "s"); }else{ if ((getState(gewicht).val >= EiGroesse[1]) && (getState(gewicht).val < EiGroesse[2])) { setState(groesse,"m"); }else{ if ((getState(gewicht).val >= EiGroesse[2]) && (getState(gewicht).val < EiGroesse[3])) { setState(groesse,"l"); }else{ if ((getState(gewicht).val >= EiGroesse[3])) { setState(groesse,"xl"); } } } } TempStart=(getState(temp).val); gewicht_math=(getState(gewicht).val); ! timer1(); ! }); ! on({id: start, change: "ne"}, function (obj) { if (getState(start).val === true) { setState(fertig, false); setState(reset, false); setState(stop, false); interval = setInterval(countdown, 1000); } }); ! on({id: reset, change: "ne"}, function (obj) { if (getState(reset).val ===true) { clearInterval(interval); setState(start, false); setState(fertig, false); setState(reset, false); setState(stop, false); timer1(); } }); ! /// Berechnung der Kochzeit /////////////////////////////////////////////////// ! function timer1() { ze1 = 0.517*Math.pow(gewicht_math, 2/3)*Math.log (0.76*((SiedePunkt - TempStart)/(SiedePunkt-haerte_math))); ze2 = Math.round(ze1 * 60); // Kochzeit in Sekunden minuten=Math.floor(ze2/60); // Minuten sekunden=ze2 - (minuten*60); // Sekunden ! if (minuten < 10){ fz_m="0"; } else { fz_m=""; } if (sekunden < 10){ fz_s="0"; }else { fz_s=""; } zeit= fz_m + minuten.toString() + ":" + fz_s + sekunden.toString(); setState(timer, zeit); ! } ! // Countdown ! function countdown() { if (ze2 > 0 ) { if (getState(stop).val ===false) { ze2--; minuten=Math.floor(ze2/60); // Minuten sekunden=ze2 - (minuten*60); // Sekunden } if (minuten < 10){ fz_m="0"; } else { fz_m=""; } if (sekunden < 10){ fz_s="0"; }else { fz_s=""; } zeit= fz_m + minuten.toString() + ":" + fz_s + sekunden.toString(); setState(timer, zeit); } else { clearInterval(interval); setState(start, false); setState(fertig, true); setStateDelayed(fertig, false, 60000, true); } } ! // Datenpunkte erzeugen ! function createStates () { createState(start, false, { name: 'Eieruhr starten', desc: 'Eieruhr starten', type: 'boolean', role: 'state', unit: '' }); createState(fertig, false, { name: 'Eieruhr fertig', desc: 'Eieruhr fertig', type: 'boolean', role: 'state', unit: '' }); createState(haerte, "w", { name: 'Eierhärte', desc: 'Eierhärte', type: 'String', role: 'value', unit: '' }); ! createState(groesse, "m", { name: 'Eiergröße', desc: 'Eiergröße', type: 'string', role: 'value', unit: '' }); ! createState(stop, false, { name: 'Eieruhr fertig', desc: 'Eieruhr fertig', type: 'boolean', role: 'state', unit: '' }); createState(timer, "00:00", { name: 'Timer', desc: 'Timer', type: 'string', role: 'value', unit: '' }); ! createState(reset, false, { name: 'Eieruhr reset', desc: 'Eieruhr reset', type: 'boolean', role: 'state', unit: '' }); ! createState(gewicht, 50, { name: 'Eigewicht', desc: 'Eigewicht', type: 'number', role: 'value', unit: 'g' }); createState(temp, 0, { name: 'Eitemperatur', desc: 'Eitemperatur', type: 'number', role: 'value', unit: '°C' }); ! } ! /////////////////////////////////////////////////////////////////////////////// ! createStates(); setTimeout(timer1,1000); ! ````
-
Okay liebe Eierliebhaber inklusive @dna909
Problem ausfindig gemacht: zu Beginn der Zeilen 21 / 22 und 24 befanden sich Zeichen, die zumindest bei mir das Erstellen der Datenpunkte unterbunden hatten.
Folgendes, leicht angepasstes Script klappt bei mir im Jahre 2020:
// Eieruhr dna909 (heinbloed@nu-is-en.de) // ************************************************************************** // v0.1 initial // v0.2 Erweiterung Eitemperatur + Gewicht // v0.3 Formel Garzeit angepasst (13.10.2017) // ************************************************************************** // // Datenpunkte: // // start: true/false // Stop: true/false // fertig: true/false //Wert für viele tolle Dinge // Haerte: "w","m","h" //weich,medium,hart // Groesse: "s","m","l","xl" //Eigröße // Timer: "mm:ss" // Reset: true/false // Gewicht: g //Eigewicht // Temperatur: °C //Eitemperatur // Switch: true/false //true=nach Größe ; false=nach Gewicht /////////////////////////////////////////////////////////////////////////////// // Datenpunkte var instanz = "javascript.0"; var objekt = "Eieruhr"; var start = instanz+"."+objekt+"."+"start"; var fertig = instanz+"."+objekt+"."+"fertig"; var haerte = instanz+"."+objekt+"."+"Haerte"; var groesse = instanz+"."+objekt+"."+"Groesse"; var stop = instanz+"."+objekt+"."+"Stop"; var timer = instanz+"."+objekt+"."+"Timer"; var reset = instanz+"."+objekt+"."+"Reset"; var gewicht = instanz+"."+objekt+"."+"Gewicht"; var temp = instanz+"."+objekt+"."+"Temperatur"; /////////////////////////////////////////////////////////////////////////////// var SiedePunkt=100; //Siedepunkt Wasser var InnenTemp=[62,68,82]; //Kerntemperatur Eigelb (weich,medium,hart) var TempStart=7; //Eitemperatur var EiGroesse=[50,60,70,80]; //S,M,L,XL-Eigewicht /////////////////////////////////////////////////////////////////////////////// //// Initialwerte haerte_math=InnenTemp[0]; gewicht_math=EiGroesse[1]; /////////////////////////////////////////////////////////////////////////////// on({id: new RegExp( groesse +"|"+ haerte +"|"+ temp +"|"+ gewicht) , change: "ne"}, function (obj) { switch (getState(haerte).val) { case "w": haerte_math=InnenTemp[0]; break; case "m": haerte_math=InnenTemp[1]; break; case "h": haerte_math=InnenTemp[2]; break; case "": console.log("error"); break; } if (getState(gewicht).val < EiGroesse[1]){ setState(groesse, "s"); }else{ if ((getState(gewicht).val >= EiGroesse[1]) && (getState(gewicht).val < EiGroesse[2])) { setState(groesse,"m"); }else{ if ((getState(gewicht).val >= EiGroesse[2]) && (getState(gewicht).val < EiGroesse[3])) { setState(groesse,"l"); }else{ if ((getState(gewicht).val >= EiGroesse[3])) { setState(groesse,"xl"); } } } } TempStart=(getState(temp).val); gewicht_math=(getState(gewicht).val); timer1(); }); on({id: start, change: "ne"}, function (obj) { if (getState(start).val === true) { setState(fertig, false); setState(reset, false); setState(stop, false); interval = setInterval(countdown, 1000); } }); on({id: reset, change: "ne"}, function (obj) { if (getState(reset).val ===true) { clearInterval(interval); setState(start, false); setState(fertig, false); setState(reset, false); setState(stop, false); timer1(); } }); /// Berechnung der Kochzeit /////////////////////////////////////////////////// function timer1() { ze1 = 0.517*Math.pow(gewicht_math, 2/3)*Math.log (0.76*((SiedePunkt - TempStart)/(SiedePunkt-haerte_math))); ze2 = Math.round(ze1 * 60); // Kochzeit in Sekunden minuten=Math.floor(ze2/60); // Minuten sekunden=ze2 - (minuten*60); // Sekunden if (minuten < 10){ fz_m="0"; } else { fz_m=""; } if (sekunden < 10){ fz_s="0"; }else { fz_s=""; } zeit= fz_m + minuten.toString() + ":" + fz_s + sekunden.toString(); setState(timer, zeit); } // Countdown function countdown() { if (ze2 > 0 ) { if (getState(stop).val ===false) { ze2--; minuten=Math.floor(ze2/60); // Minuten sekunden=ze2 - (minuten*60); // Sekunden } if (minuten < 10){ fz_m="0"; } else { fz_m=""; } if (sekunden < 10){ fz_s="0"; }else { fz_s=""; } zeit= fz_m + minuten.toString() + ":" + fz_s + sekunden.toString(); setState(timer, zeit); } else { clearInterval(interval); setState(start, false); setState(fertig, true); setStateDelayed(fertig, false, 60000, true); } } // Datenpunkte erzeugen function createStates () { createState(start, false, { name: 'Eieruhr starten', desc: 'Eieruhr starten', type: 'boolean', role: 'state', unit: '' }); createState(fertig, false, { name: 'Eieruhr fertig', desc: 'Eieruhr fertig', type: 'boolean', role: 'state', unit: '' }); createState(haerte, "w", { name: 'Eierhärte', desc: 'Eierhärte', type: 'String', role: 'value', unit: '' }); createState(groesse, "m", { name: 'Eiergröße', desc: 'Eiergröße', type: 'string', role: 'value', unit: '' }); createState(stop, false, { name: 'Eieruhr fertig', desc: 'Eieruhr fertig', type: 'boolean', role: 'state', unit: '' }); createState(timer, "00:00", { name: 'Timer', desc: 'Timer', type: 'string', role: 'value', unit: '' }); createState(reset, false, { name: 'Eieruhr reset', desc: 'Eieruhr reset', type: 'boolean', role: 'state', unit: '' }); createState(gewicht, 50, { name: 'Eigewicht', desc: 'Eigewicht', type: 'number', role: 'value', unit: 'g' }); createState(temp, 0, { name: 'Eitemperatur', desc: 'Eitemperatur', type: 'number', role: 'value', unit: '°C' }); } /////////////////////////////////////////////////////////////////////////////// createStates(); setTimeout(timer1,1000);
Danke für das schöne Script @dna909
-
@Bostil Das lag scheinbar daran, das bei der Umstellung der Forensoftware das Script falsch formatiert wurde. Irgendwie stimmten da die Tags nicht mehr. Habe das aber im ersten Beitrag angepasst.
Gruß
dna909
-
@dna909
Leider nicht angepasst.
Die Zeichen ">!" sind immer noch drin! -
-
@Negalein
Jupp passt jetzt