NEWS
[Gelöst] Funktion mit der man Eingangswert multiplizieren kann
-
Hallo ich bin neu hier im Forum und bei der Benutzung mit Node-Red.
Ich würde mir gerne mein Eingangswert *10 multiplizieren und wenn es geht noch das Ergebnis auf ganze Zahlen runden. Vor das ganze muss allerdings auch noch ein TargetPosition damit die Homekit-node das ganze auch erkennt.Das habe ich schon hin bekommen. Die Funktion sieht momentan so aus :
{"TargetPosition": {{payload}}}
Wäre toll wenn mir jemand helfen könnte!
Gruß Tobi
-
Hallo Tobi,
ich habe es mir wie folgt zusammenkopier
Vielleicht hilft dir das.
im function Node musst du natürlich noch
var preis = 0.2418
gegen
var preis = 10 tauschen
[ { "id": "f040aeb7.c0f", "type": "debug", "z": "54dc610c.f1c2c", "name": "", "active": false, "console": "false", "complete": "payload", "x": 828.0002593994141, "y": 1208.0002346038818, "wires": [] }, { "id": "cdc81735.b67048", "type": "function", "z": "54dc610c.f1c2c", "name": "Verbraucht mit Preis multiplizieren", "func": "\nvar preis = 0.2418;\n\n//ausgabe = in float wandeln mal variable auf 2 Stellen nachkomma\nmsg.payload = (parseFloat(msg.payload) * preis) .toFixed(2);\n\n\nreturn msg;", "outputs": 1, "noerr": 0, "x": 542.0001602172852, "y": 1215.3334112167358, "wires": [ [ "f040aeb7.c0f", "641cf068.a19c9" ] ] }, { "id": "9c88ec54.6fcd3", "type": "inject", "z": "54dc610c.f1c2c", "name": "", "topic": "", "payload": "true", "payloadType": "bool", "repeat": "60", "crontab": "", "once": false, "x": 118.00003814697266, "y": 1219.6667432785034, "wires": [ [ "c8b3a4ed.fe1a98" ] ] }, { "id": "c8b3a4ed.fe1a98", "type": "ioBroker get", "z": "54dc610c.f1c2c", "name": "Zahelerstand_Strom_heute", "topic": "admin.0.Eigene_Objekte.Verbrauch.Zahelerstand_Strom_heute", "attrname": "payload", "payloadType": "value", "x": 281.0001220703125, "y": 1278.3334064483643, "wires": [ [ "cdc81735.b67048" ] ] }, { "id": "641cf068.a19c9", "type": "ioBroker out", "z": "54dc610c.f1c2c", "name": "Zaelherstand_Strom_heute_EURO", "topic": "admin.0.Eigene_Objekte.Verbrauch.Zaelherstand_Strom_heute_EURO", "ack": "false", "autoCreate": "false", "x": 779.0000228881836, "y": 1278.0000839233398, "wires": [] }, { "id": "e7f4b902.0c1ef8", "type": "comment", "z": "54dc610c.f1c2c", "name": "Tagesverbrauch in EURO ermitteln", "info": "", "x": 179.99996948242188, "y": 1172.3332934379578, "wires": [] } ]
-
Super hat funktioniert ! Danke!