Skip to content

JavaScript

Hilfe für Skripterstellung mit JavaScript

2.5k Topics 49.0k Posts

NEWS

  • Windrichtung kommt mit 0-5V an soll in Windrichtung N/S/W/O

    javascript
    12
    0 Votes
    12 Posts
    803 Views
    SchmakusS
    Wieso überhaupt ein script und nicht einen echten Alias mit einer read formel? val <= 0.4658 ? 'SÜD' : val <= 1.0908 ? 'SÜD-WEST' : val <= 1.7158 ? 'WEST' : val <= 2.3407 ? 'NORD-WEST' : val <= 2.9658 ? 'NORD' : val <= 3.5908 ? 'NORD-OST' : val <= 3.9158 ? 'OST' : val <= 4.5408 ? 'SÜD-OST' : val <= 5.0000 ? 'SÜD' : 'SÜD';
  • Skriptlogik mit internen Variablen aufbauen, oder getState?

    18
    0 Votes
    18 Posts
    2k Views
    T
    @miniblister Das sieht gut aus. Aber datapoint würde ich noch einen weniger generischen namen geben.
  • Beispiel zu onLog() und Frage zu der Nutzung von on...(...)

    3
    0 Votes
    3 Posts
    170 Views
    MartinPM
    So, das ist nun meine Lösung... var LastLogMessageReceived = (new Date().getTime()); onLog('warn', data => { // console.log('Following warn message: ' + data.message + "from: " + data.from); if((data.from == 'ical.0') && (data.severity == 'warn')) { let myActTime = new Date().getTime(); // Auswertung von data.message if ((myActTime - LastLogMessageReceived)> 2700000) { // 2 700 000 ms = 45 min (check ical settings for fitting timeout limit, 30 min ical interval -> 45 min timeout) sendTo("email", "send", { text: (['ical Adapter meldet Warnung ', data.message].join('')), to: 'xxxxxxxxxxxxxxxxx, subject: 'Ical-Alarm!' }); } LastLogMessageReceived = myActTime; } }); Schickt zwar keine OK-Mail, wenn wieder alles funktioniert, aber das ist erstmal nicht so wichtig denke ich ...
  • Script für eine Regel auf der Jarvis Oberfläche

    7
    0 Votes
    7 Posts
    577 Views
    J
    @gelberlemmy ich habe mir ein blockly gebaut mit dem ich mir alle 10 Schichten, aber nur maximal alle 10 Minuten, ein aktuelles Bild mit der Info über die aktuelle Schichthöhe und der gesamten Schichten per Telegram zuschicken lasse. Vllt. hilft es dir Spoiler <xml xmlns="https://developers.google.com/blockly/xml"> <variables> <variable id="b`Ni%Tozvg/NGlwc`OHx">timer</variable> <variable id="-x2Ff8hq5IHG@NX-jVLz">layerhoehe</variable> <variable type="timeout" id="timeout3">timeout3</variable> </variables> <block type="variables_set" id="liZJ71RrA3fHYv;P5lJ~" x="-2987" y="1063"> <field name="VAR" id="b`Ni%Tozvg/NGlwc`OHx">timer</field> <value name="VALUE"> <block type="logic_boolean" id="W6`A6BBf-*s5C~c58Nfk"> <field name="BOOL">FALSE</field> </block> </value> <next> <block type="variables_set" id="V/e#S0`W-!3~0,W`rtSz"> <field name="VAR" id="-x2Ff8hq5IHG@NX-jVLz">layerhoehe</field> <value name="VALUE"> <block type="math_number" id="}E*(+.v=@KU04pFNCx(K"> <field name="NUM">0</field> </block> </value> <next> <block type="on" id="iwhUf}7|Or]/p,7,UOIU"> <field name="OID">octoprint.0.plugins.displayLayerProgress.layer.current</field> <field name="CONDITION">ne</field> <field name="ACK_CONDITION"></field> <statement name="STATEMENT"> <block type="controls_if" id="^=A!LDGc0(OOq{,WrFE^" disabled="true"> <mutation elseif="1"></mutation> <value name="IF0"> <block type="logic_compare" id="_.W%S6u%M8h|b]1LvYBM"> <field name="OP">GTE</field> <value name="A"> <block type="on_source" id="V.+{F,UEP0=_.T^ja?Rx"> <field name="ATTR">state.val</field> </block> </value> <value name="B"> <block type="math_number" id="fkloJ,PkI.Kwh(QWl]|c"> <field name="NUM">9</field> </block> </value> </block> </value> <statement name="DO0"> <block type="control" id="8|]+Di_$a3-F.N8;$*;4"> <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation> <field name="OID">octoprint.0.command.custom</field> <field name="WITH_DELAY">FALSE</field> <value name="VALUE"> <block type="text" id="5]@Xk+?od2!K@TuEL*OJ"> <field name="TEXT">M0</field> </block> </value> </block> </statement> <value name="IF1"> <block type="logic_compare" id="lAJWB$63p73F)^AGTbzn"> <field name="OP">GTE</field> <value name="A"> <block type="on_source" id="B[{{1aPBm,jBvo~jtJ;h"> <field name="ATTR">state.val</field> </block> </value> <value name="B"> <block type="math_number" id="T)Kg#~@Y|(gf1q_9fUL!"> <field name="NUM">11</field> </block> </value> </block> </value> <statement name="DO1"> <block type="control" id="O+sm3EI0iJ/lvgpr;]]G"> <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation> <field name="OID">octoprint.0.command.custom</field> <field name="WITH_DELAY">FALSE</field> <value name="VALUE"> <block type="text" id="~40gEB;?})@6,6TuIxhP"> <field name="TEXT">M0</field> </block> </value> </block> </statement> <next> <block type="controls_if" id="WSo[PhN^`Oq6v/vv[S|6"> <value name="IF0"> <block type="logic_compare" id="vZ1ZJvfgzvIaj2y`7$bM"> <field name="OP">GTE</field> <value name="A"> <block type="math_arithmetic" id="X0QRQiy,uzyX(!i|t;B1"> <field name="OP">MINUS</field> <value name="A"> <shadow type="math_number" id="F%`T2w}Y3^}?ru=E.O$j"> <field name="NUM">1</field> </shadow> <block type="on_source" id="C[Jyw_4i-{5GhVIB%M,3"> <field name="ATTR">state.val</field> </block> </value> <value name="B"> <shadow type="math_number" id="i`!EWQx@t5u!qw.{L-p0"> <field name="NUM">1</field> </shadow> <block type="variables_get" id="sU!#!|^6~!:$%.R=u[+s"> <field name="VAR" id="-x2Ff8hq5IHG@NX-jVLz">layerhoehe</field> </block> </value> </block> </value> <value name="B"> <block type="math_number" id="TZF(PsCCzUULbp[j(@MH"> <field name="NUM">10</field> </block> </value> </block> </value> <statement name="DO0"> <block type="variables_set" id="0Sd84r9|:r9oD,wMZe17"> <field name="VAR" id="-x2Ff8hq5IHG@NX-jVLz">layerhoehe</field> <value name="VALUE"> <block type="on_source" id="W%LDq}MSKM3o{MT5=Bq5"> <field name="ATTR">state.val</field> </block> </value> <next> <block type="controls_if" id="[Ge36]/-G)I?H?Yoj#fB"> <value name="IF0"> <block type="logic_negate" id="v#MeqL*TL??2.Z}WMkgA"> <value name="BOOL"> <block type="get_value" id="JO`GM@yc*OO8*`:3|zxU"> <field name="ATTR">val</field> <field name="OID">0_userdata.0.imBüro</field> </block> </value> </block> </value> <statement name="DO0"> <block type="controls_if" id="Prbp;E}sl~P75Af0/JY1"> <value name="IF0"> <block type="logic_operation" id="r+#:bcVhBUZ,A).6}#K5" inline="false"> <field name="OP">AND</field> <value name="A"> <block type="logic_compare" id="%ox*pThh0zWaAsvDp0x="> <field name="OP">EQ</field> <value name="A"> <block type="get_value" id="Dg,nqcxK9na6IY/nz()_"> <field name="ATTR">val</field> <field name="OID">javascript.0.schalfen</field> </block> </value> <value name="B"> <block type="math_number" id="tRjV!-kcavt{Q*!=qI}u"> <field name="NUM">0</field> </block> </value> </block> </value> <value name="B"> <block type="logic_negate" id="GeBtsn!K$-MQZ$VtDMI("> <value name="BOOL"> <block type="variables_get" id="M|/@+5S!:0UmdfVLkH]n"> <field name="VAR" id="b`Ni%Tozvg/NGlwc`OHx">timer</field> </block> </value> </block> </value> </block> </value> <statement name="DO0"> <block type="telegram" id="!^1(jOOe62o6FQ;nizqE"> <field name="INSTANCE"></field> <field name="LOG"></field> <field name="SILENT">FALSE</field> <field name="PARSEMODE">default</field> <field name="ESCAPING">FALSE</field> <field name="DISABLE_WEB_PAGE_PREVIEW">FALSE</field> <value name="MESSAGE"> <shadow type="text" id="#zrF6Y=c`wybO0n,PP@E"> <field name="TEXT">text</field> </shadow> <block type="text_join" id="[h[CBx{{!j}9IEikkKf9"> <mutation items="13"></mutation> <value name="ADD0"> <block type="text" id="s!K4kinlUF7Wnr1Jj]s+"> <field name="TEXT">Momentane Schichthöhe:</field> </block> </value> <value name="ADD1"> <block type="text_newline" id="=J:=+WJiy!,n2S6Ti,Bz"> <field name="Type">\n</field> </block> </value> <value name="ADD2"> <block type="get_value" id="LFsI|+#?sXG0*Qb`,hI4"> <field name="ATTR">val</field> <field name="OID">octoprint.0.plugins.displayLayerProgress.layer.current</field> </block> </value> <value name="ADD3"> <block type="text" id="Ic13AeC*;a?Gp}Vl]*hv"> <field name="TEXT"> von </field> </block> </value> <value name="ADD4"> <block type="get_value" id="xCk,7i2x?${~v5l#ZoJM"> <field name="ATTR">val</field> <field name="OID">octoprint.0.plugins.displayLayerProgress.layer.total</field> </block> </value> <value name="ADD5"> <block type="text" id="o{:6V{BKnL]^!RINV9V?"> <field name="TEXT"> Schichten</field> </block> </value> <value name="ADD6"> <block type="text_newline" id="8AnckRNa/@A)I({:2%3O"> <field name="Type">\n</field> </block> </value> <value name="ADD7"> <block type="get_value" id="TAB`Qj.qa/uzApWECCpD"> <field name="ATTR">val</field> <field name="OID">octoprint.0.printjob.progress.completion</field> </block> </value> <value name="ADD8"> <block type="text" id="x{}xya5L5MwmHr*|s9N#"> <field name="TEXT">% fertig gestellt</field> </block> </value> <value name="ADD9"> <block type="text_newline" id="SC~-n9J/q%@Fr_6a;#xr"> <field name="Type">\n</field> </block> </value> <value name="ADD10"> <block type="text" id="!vQ}RbJ-YTn71ps43[0E"> <field name="TEXT">Geschätzte Restzeit:</field> </block> </value> <value name="ADD11"> <block type="text_newline" id="LKUag;17IUMCPoK@VObY"> <field name="Type">\n</field> </block> </value> <value name="ADD12"> <block type="get_value" id=",iU/:+gF+CtEO@^4rLbk"> <field name="ATTR">val</field> <field name="OID">octoprint.0.printjob.progress.printtimeLeftFormat</field> </block> </value> </block> </value> <next> <block type="exec" id="Q%.+UAgMkWBG2+4(;E|M"> <mutation xmlns="http://www.w3.org/1999/xhtml" with_statement="true"></mutation> <field name="WITH_STATEMENT">TRUE</field> <field name="LOG">debug</field> <value name="COMMAND"> <shadow type="text" id="f:W)ej0T0P)?wV/0AF!9"> <field name="TEXT">wget -q -O /home/pi/pictures/octoprint.snap.jpg "http://192.168.178.37/webcam/?action=snapshot"</field> </shadow> </value> <statement name="STATEMENT"> <block type="telegram" id="X4uk?iU9AL,+=Ub8-!{5"> <field name="INSTANCE">.0</field> <field name="LOG">debug</field> <field name="SILENT">FALSE</field> <field name="PARSEMODE">default</field> <field name="ESCAPING">FALSE</field> <field name="DISABLE_WEB_PAGE_PREVIEW">FALSE</field> <value name="MESSAGE"> <shadow type="text" id=":^gzF@/rGK6L3RKr2wGQ"> <field name="TEXT">/home/pi/pictures/octoprint.snap.jpg</field> </shadow> </value> </block> </statement> <next> <block type="variables_set" id="]m)84sib]x/FW!lO^Z;S"> <field name="VAR" id="b`Ni%Tozvg/NGlwc`OHx">timer</field> <value name="VALUE"> <block type="logic_boolean" id="[C)@XDJE6E#NHG!_y6jO"> <field name="BOOL">TRUE</field> </block> </value> <next> <block type="timeouts_settimeout" id="}^`dwU{93HQZ32{]Mv-+"> <field name="NAME">timeout3</field> <field name="DELAY">10</field> <field name="UNIT">min</field> <statement name="STATEMENT"> <block type="variables_set" id="yITI@8eLFO:.g-HsJk_["> <field name="VAR" id="b`Ni%Tozvg/NGlwc`OHx">timer</field> <value name="VALUE"> <block type="logic_boolean" id="lin{J9-uv?=rKE6b~F^,"> <field name="BOOL">FALSE</field> </block> </value> </block> </statement> </block> </next> </block> </next> </block> </next> </block> </statement> </block> </statement> </block> </next> </block> </statement> </block> </next> </block> </statement> </block> </next> </block> </next> </block> </xml>
  • [gelöst] Drei Dimmer ein Licht

    26
    0 Votes
    26 Posts
    2k Views
    paul53P
    @jack sagte: Wo kann man genauer nachlesen In der Funktions-Doku @jack sagte in Drei Z-Wave Dimmer "ein" Zigbee Licht: Passt so? So machen einzelne Trigger wenig Sinn, sondern nur dann, wenn sie unterschiedlich wirken sollen. @jack sagte in [gelöst] Drei Dimmer ein Licht: waren wohl am Anfang die fehlenden Klammern bei den if-Bedingungen... Nein, wenn man mehrere Trigger verwendet, muss idSrc global deklariert werden, was es in meinem ersten Post nicht war.
  • [Gelöst] MQTT SENSOR String in einzelne Werte zerlegen

    11
    1
    0 Votes
    11 Posts
    852 Views
    haselchenH
    @magicfriend-0 Alles klar. Danke fürs Feedback. Dann ist der Weg natürlich logisch :+1:
  • Homematic HM-LC-Sw1-DR mit Einschaltdauer triggern

    6
    0 Votes
    6 Posts
    380 Views
    HomoranH
    @smartstuffcoyote sagte in Homematic HM-LC-Sw1-DR mit Einschaltdauer triggern: So angewandt funktioniert es so ist es ja auch in CCU Programmen vorgesehen.
  • Skript für Türöffner löst nicht aus

    5
    0 Votes
    5 Posts
    214 Views
    P
    Wenn im Beispiel fetch() genutzt wird, könnte man das evtl. auch hier nutzen. Oder per execute ein curl oder wget absckicken. Die Antwort der API könnte auch hinweisgebend sein.
  • Löschscript für alte Messwerte ? (influxdb)

    1
    0 Votes
    1 Posts
    127 Views
    No one has replied
  • [gelöst] Wert als Zahl schreiben statt als string

    2
    0 Votes
    2 Posts
    207 Views
    bahnuhrB
    @claus1985-0 parseInt parseFloat Number Es gibt mehrere Möglichkeiten, je nachdem wie der String aussieht. Hast du mal gegoogelt: [image: 1705221528285-24116483-89d0-4fc3-bc2e-e1d9b464ff51-image.png] gleich der 1. Beitrag zeigt dir dies.
  • Objektdaten eines States per JavaScript ändern / Name ändern

    5
    0 Votes
    5 Posts
    290 Views
    T
    @ofri2607 sagte in Objektdaten eines States per JavaScript ändern / Name ändern: @mbartsch So wie im Link von @paul53 gezeigt, sollte es eigentlich so auch funktionieren: log (TestObject); extendObject('zigbee.0.xxx', {common: {name: "Neuer Name"}}); Das ist auch zu bevorzugen, weil man weniger kaputt machen kann.
  • [Gelöst] Werte aus Objektattributen in ein Array packen?

    5
    1
    0 Votes
    5 Posts
    495 Views
    I
    @paul53 Ok, danke. Also eine Liste und kein Array, daher mein Verständnisproblem :)
  • Wert aus function zurückgeben

    Moved
    9
    0 Votes
    9 Posts
    634 Views
    haus-automatisierungH
    @wierer-sigi Wäre noch schön, wenn Du den Downvote in der ersten Antwort von @OliverIO entfernst :) Oder wofür ist der? Gerne hilfreiche Beiträge bewerten...
  • (erledigt) Kommentar in JSON String

    13
    0 Votes
    13 Posts
    10k Views
    mcm1957M
    @ubecker Das erste Bild zeig JSON Daten an. Die zeichnen sich durch key:wert Paare aus. https://de.wikipedia.org/wiki/JavaScript_Object_Notation "Echtes" JSON Format kennt keine Kommentare. Das neuere Format JSON5 kennt Kommentare - benötigt aber naturgemäß JSON5 fähige Parser. ARRAYs sind ein Sprachelelement von Javascript. https://www.w3schools.com/js/js_arrays.asp
  • javascript - Error install "basic-ftp"

    javascript
    6
    1
    0 Votes
    6 Posts
    187 Views
    GlasfaserG
    @bahnuhr die obere Meldung ist Werbung :) im Sinne ... zb. har-validator usw .... https://forum.iobroker.net/post/1108222
  • Mehrere Abfragen auf einmal abfragen

    1
    0 Votes
    1 Posts
    83 Views
    No one has replied
  • iobroker als websocket client nutzen

    javascript
    3
    0 Votes
    3 Posts
    652 Views
    OliverIOO
    @cruunnerr Und was kommt beim Event ‚error‘ ? Kannst du mal den Inhalt des kompletten error Objekts posten? Kannst du mal den npmjs link des packets posten?
  • [Vorlage] Solaredge Wechselrichter

    9
    0 Votes
    9 Posts
    28k Views
    B
    Bin weiter. Das Script geht, aber mit einem Akku passen die Werte bei mir nur am Ende eines Tages. Anscheinend wird die Ladung in der Web-App sofort und in der API erst nach Entladung in der Gesamtsumme angezeigt.
  • Hilfe bei JavaScript-Funktion createUserStates()

    4
    0 Votes
    4 Posts
    328 Views
    T
    @woupi https://github.com/ioBroker/ioBroker.javascript/blob/master/docs/en/javascript.md#createstate
  • [gelöst] Script läuft nicht mehr.... DOMParser

    20
    0 Votes
    20 Posts
    1k Views
    ofri2607O
    @tcfigge Perfekt :-) hatte befürchtet, dass beim DOMParser mehr anzugreifen wäre.

497

Online

32.7k

Users

82.4k

Topics

1.3m

Posts