RaspberryPiWorkshopEinsteiger

Aus FabLab Rothenburg
Version vom 22. Januar 2016, 22:26 Uhr von Jochen (Diskussion | Beiträge) (Die Seite wurde neu angelegt: „Ein paar Informationen zum Raspberry Pi Workshop für Einsteiger. Node-RED Flow Lichtschalter: <pre> [{"id":"48a6df2a.b7592","type":"function","z":"cce966b8.…“)
(Unterschied) ← Nächstältere Version | Aktuelle Version (Unterschied) | Nächstjüngere Version → (Unterschied)
Zur Navigation springen Zur Suche springen

Ein paar Informationen zum Raspberry Pi Workshop für Einsteiger.

Node-RED Flow

Lichtschalter:

[{"id":"48a6df2a.b7592","type":"function","z":"cce966b8.331698","name":"Lichtschalter","func":"context.state = context.state || 0;\n//nachricht = Object.create(msg);\n//schalter = Object.create(msg);\n\nif (msg.payload.state) {\n    if (msg.payload.state == \"toggle\") {\n        (context.state == 0) ? context.state = 1 : context.state = 0;\n    }\n    if (msg.payload.state == \"on\") {\n        context.state = 0;\n    }\n    if (msg.payload.state == \"off\") {\n        context.state = 1;\n    }\n}\nif (context.state == 0)\n    msg.text = \"on\"\nif (context.state == 1)\n    msg.text = \"off\"\nmsg.payload = context.state;\n\nreturn msg;","outputs":"1","noerr":0,"x":439,"y":441,"wires":[["a0846992.5f7b98","d861ecaa.279e1","24b4eac5.db4b16"]]}]