10 € Wifi Plug als virtuelles Gerät in homee steuern

10€ WiFi-Steckdosen in homee – NodeRed Projekt

Günstige WLAN-Steckdosen /Plugs in homee einzubinden ist seit jeher immer mal wieder Thema. Im Bereich der anderen Funkstandards gibt es nicht immer gute Alternativen:

Zigbee: Funk ist mir zu störanfällig, die Osram Plugs sind günstig, aber sch****. Zwave: Da gibt es einige Möglichkeiten, allen voran Fibaro. Gerade günstig sind die nicht und mit der Zwave Zuverlässigkeit hapert es insbesondere in Gruppenschaltungen. Enocean: Nach dem Rückzug von Permundo ist die Auswahl doch sehr begrenzt und teuer ist Enocean sowieso immer.

Also was tun? WLAN-Steckdosen gibt es wie Sand am Meer, man braucht nur mal bei Amazon zu suchen. Von Design und Größe her, gibt es auch ansehnliche und kompakte Plug. Der Preis um 10 € ist top.

https://www.amazon.de/Steckdose-TECKIN-funktioniert-Steurung-überall/dp/B07HHFKWJJ/ref=sr_1_7?__mk_de_DE=ÅMÅŽÕÑ&crid=15UE6ENSHHODW&keywords=teckin+steckdose&qid=1560321474&s=gateway&sprefix=Teckin%2Caps%2C153&sr=8-7

Nach etwas Recherche, habe ich herausgefunden, dass viele dieser Firmen, die WLAN-Plugs anbieten (Gosund, BlitzWolf, Teckin, Meross, Homecube, usw.) die tuya Api verwenden.

Tollerweise gibt es in NodeRed einen node, der diese Api unterstüzt. https://flows.nodered.org/node/node-red-contrib-tuya-smart Es wird auch genau beschrieben, wie man an DeviceID und DeviceKey kommt (diese brauch man zur Ansteuerung).

Hat man schon einen Raspberry Pi mit NodeRed laufen, ist die ganze Sache relativ simple. Man benötigt für das unten genannte Vorgehen:

  • node-red-contrib-tuya-smart -> Einbindung der WLAN-Plugs in NodeRed
  • node-red-contrib-enocean -> virtuelle Enocean-Geräte in home (Danke an @micha und Holger-Will)
  • Enocean-Stick am Pi

A.) Erstellung virtueller Enocean-Geräte in homee:

Diese werden auf Basis von Nodon 1Relais (Enocean) erzeugt, die nur die Funktion on/off haben.

B.) Kopplung dieser Geräte mittel des enocean-js node (https://github.com/enocean-js/enocean-js/tree/master/packages/node-red-contrib-enocean) mit den Wifi Plugs.

[{"id":"1864b8bc.bea6df","type":"enocean-in","z":"f69976a2.324d7","serialport":"36056171.b343b6","name":"","x":430,"y":1700,"wires":[["d7988fb2.0398f8","7d66c9ca.e8a3d"]]},{"id":"d7988fb2.0398f8","type":"enocean-actor","z":"f69976a2.324d7","name":"Wifi_Plug","channel":"25","adt":true,"x":620,"y":1700,"wires":[["94205f49.04bf98","af2b7cbd.86ebe"],[]]},{"id":"214a5ba5.d5a61c","type":"inject","z":"f69976a2.324d7","name":"LRN CH25","topic":"","payload":"{\"type\":\"LRN\",\"eep\":\"d2-01-0f\",\"senderId\":\"0186fbde\",\"name\":\"Zentrale\"}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":440,"y":1760,"wires":[["d7988fb2.0398f8"]]},{"id":"af2b7cbd.86ebe","type":"function","z":"f69976a2.324d7","name":"Status an/aus","func":"const Enocean = global.get('Enocean')\nvar channel = 25\n\nvar tel1 = Enocean.RadioERP1.from(\"550009070156d20460e4050f13a40101ffffffff50001f\")\nvar tel2 = Enocean.RadioERP1.from(\"550009070156d2046080050f13a40101ffffffff52006e\")\ntel1.senderId = global.get(\"enocean-base-id\") + channel\ntel2.senderId = global.get(\"enocean-base-id\") + channel\n\nif ( msg.meta.payload === \"010001\"){\nreturn {payload: tel1.toString()};\n}\nif ( msg.meta.payload === \"010000\"){\nreturn {payload: tel2.toString()};\n}\n","outputs":1,"noerr":0,"x":900,"y":1660,"wires":[["e2ce1a2e.a5ee08"]]},{"id":"e2ce1a2e.a5ee08","type":"enocean-out","z":"f69976a2.324d7","serialport":"36056171.b343b6","name":"","logOutput":false,"x":1070,"y":1660,"wires":[[]]},{"id":"94205f49.04bf98","type":"function","z":"f69976a2.324d7","name":"","func":"if ( msg.meta.payload === \"010001\")\n{ return {payload:{\n        set: true\n    }}}\nif ( msg.meta.payload === \"010000\")\n{ return {payload:{\n        set: false\n    }}}","outputs":1,"noerr":0,"x":870,"y":1700,"wires":[["da4672f2.73d688"]]},{"id":"da4672f2.73d688","type":"tuya-smart","z":"f69976a2.324d7","deviceName":"Wifi_Plug","deviceIp":"XXX","deviceId":"XXX","deviceKey":"XXX","request":"{\"schema\": true}","pollingInterval":10,"x":1070,"y":1700,"wires":[[]]},{"id":"efcd093c.5b7378","type":"function","z":"f69976a2.324d7","name":"Nodon 1Relay","func":"const Enocean = global.get('Enocean')\nvar channel = 25\n\nvar tel = Enocean.RadioERP1.from(\"55000d0701fdd4a00146000f01d2050f13a40101ffffffff58004b\")\ntel.senderId = global.get(\"enocean-base-id\") + channel\n\nreturn {payload: tel.toString()}","outputs":1,"noerr":0,"x":680,"y":1540,"wires":[["1f9e1c34.640d54"]]},{"id":"6cac4252.64d4bc","type":"inject","z":"f69976a2.324d7","name":"Anlernen an homee","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":470,"y":1540,"wires":[["efcd093c.5b7378"]]},{"id":"1f9e1c34.640d54","type":"enocean-out","z":"f69976a2.324d7","serialport":"36056171.b343b6","name":"","logOutput":false,"x":850,"y":1540,"wires":[["dcb92fd0.3c8298"]]},{"id":"dcb92fd0.3c8298","type":"debug","z":"f69976a2.324d7","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":990,"y":1540,"wires":[]},{"id":"a7aa97a6.37b618","type":"comment","z":"f69976a2.324d7","name":"1. Anlernen virtueller Schalter","info":"In homee Anlernvorgang neues Enocean Gerät \nstarten (anderes Gerät).\n\nImmer einen neuen Channel vergeben.","x":160,"y":1540,"wires":[]},{"id":"d00cac3.34b1bd","type":"comment","z":"f69976a2.324d7","name":"2. Kopplung Actor Node + Wifi Plug","info":"Im Actor Node zuvor eingestellten Channel\neintragen und Haken setzen.\n\nIn der LRN Funktion muss noch die Sender ID\ngeändert werden.\n\nDazu am input node per debug (volle msg) diese\nauslesen, wenn der virtuelle Schalter geschaltet\nwird.\n\nLRN inject dann ausführen.","x":180,"y":1700,"wires":[]},{"id":"7d66c9ca.e8a3d","type":"debug","z":"f69976a2.324d7","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":560,"y":1640,"wires":[]},{"id":"4f5e33db.bd310c","type":"change","z":"f69976a2.324d7","name":"change payload","rules":[{"t":"move","p":"payload.data.dps.1","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":800,"y":1760,"wires":[["9ada5fd6.2510b"]]},{"id":"9ada5fd6.2510b","type":"function","z":"f69976a2.324d7","name":"Prüfen des Zustandes","func":"var nodeid = 403;  // node ID in homee des virtuellen Schalters\nvar attributid = 1463; // attribut ID in homee des virtuellen Schalters\nif (msg.payload === false)\n{return {payload: \"PUT:/nodes/\"+nodeid+\"/attributes/\"+attributid+\"?target_value=0\"}}\nif (msg.payload === true)\n{return {payload: \"PUT:/nodes/\"+nodeid+\"/attributes/\"+attributid+\"?target_value=1\"}}\n","outputs":1,"noerr":0,"x":1020,"y":1760,"wires":[["25f2dc5.239d724"]]},{"id":"25f2dc5.239d724","type":"link out","z":"f69976a2.324d7","name":"","links":["1f6d5452.168fbc"],"x":1175,"y":1760,"wires":[]},{"id":"172b9420.78f214","type":"tuya-smart","z":"f69976a2.324d7","deviceName":"Wifi_Plug","deviceIp":"XXX","deviceId":"XXX","deviceKey":"XXX","request":"{\"schema\": true}","pollingInterval":10,"x":620,"y":1760,"wires":[["4f5e33db.bd310c"]]},{"id":"36056171.b343b6","type":"enocean-config-node","z":"","serialport":"/dev/ttyUSB0"}]

Flow Info

Created 6 years, 3 months ago
Rating: not yet rated

Owner

Actions

Rate:

Node Types

Core
  • change (x1)
  • comment (x2)
  • debug (x2)
  • function (x4)
  • inject (x2)
  • link out (x1)
Other

Tags

  • homee
  • enocean-js
  • tuya
  • virtuelle_Geräte
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option