{"id":27793,"date":"2019-09-17T10:09:29","date_gmt":"2019-09-17T09:09:29","guid":{"rendered":"http:\/\/192.168.178.50\/?p=27793"},"modified":"2020-01-15T09:50:31","modified_gmt":"2020-01-15T08:50:31","slug":"add-tuya-devices-to-openhab2","status":"publish","type":"post","link":"https:\/\/www.bleuanus.nl\/index.php\/2019\/09\/17\/add-tuya-devices-to-openhab2\/","title":{"rendered":"Add Tuya devices to Openhab2"},"content":{"rendered":"<p class=\"last-modified\">This post was most recently updated on January 15th, 2020<\/p>\n<p class=\"wp-block-paragraph\">Installation:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">node tuya-mqtt.js<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Run tya-mqtt in the background<br>\nnohup node tuya-mqtt.js &amp; exit<br>\nnohup node \/etc\/openhab2\/scripts\/tuya-mqtt\/tuya-mqtt.js &amp; exit<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">device id: 80401244cc50e3168f0f<br>\nlocalKey&#8221;:&#8221;04eb51fe119819dd<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">ip adres: 192.168.178.34<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">rule &#8220;Toggle Tuya light\/switch on\/off via MQTT&#8221;<br>\n    when<br>\n        Item tuya_light received command<br>\n    then<br>\n        switch(receivedCommand) {<br>\n            case ON : actions.publishMQTT(&#8220;tuya\/switch\/80401244cc50e3168f0f\/04eb51fe119819dd\/192.168.178.34\/command\/on&#8221;,&#8221;&#8221;)<br>\n            case OFF : actions.publishMQTT(&#8220;tuya\/switch\/80401244cc50e3168f0f\/04eb51fe119819dd\/192.168.178.34\/command\/off&#8221;,&#8221;&#8221;)<br>\n}<br>\nend<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">192.168.178.21<br>\nTent<br>\ndeviceid: 80401244cc50e3168f0f<br>\nlocalKey&#8221;:04eb51fe119819dd<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">devId&#8221;:&#8221;80401244cc50e3168f0f&#8221;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">22d6c916de6e3cad<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">tuya\/socket\/60652064cc50e350a106\/688487ae048fb983\/192.168.178.21\/command<br>\ntuya\/socket\/60652064cc50e350a106\/688487ae048fb983\/192.168.178.21\/dps\/2\/command<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">192.168.178.34<br>\ndeviceid: 60652064cc50e350a106<br>\nlocalKey&#8221;:&#8221;688487ae048fb983&#8243;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&#8220;devId&#8221;:&#8221;80401244cc50e3168f0f&#8221;<br>\n&#8220;localKey&#8221;:&#8221;22d6c916de6e3cad&#8221;<br>\n&#8220;devId&#8221;:&#8221;60652064cc50e350a106&#8243;<br>\n&#8220;localKey&#8221;:&#8221;688487ae048fb983&#8243;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Type    switch : Test_Power_Switch          &#8220;Test_Power_Switch&#8221;            [ stateTopic=&#8221;tuya\/socket\/80401244cc50e3168f0f\/04eb51fe119819dd\/192.168.178.34\/state&#8221;, commandTopic=&#8221;tuya\/socket\/80401244cc50e3168f0f\/04eb51fe119819dd\/192.168.178.34\/command&#8221;, on=&#8221;1&#8243;, off=&#8221;0&#8243; ]<br>\nType    switch : Test_Power_Switch_MQTT     &#8220;Test_Power_Switch MQTT Channel&#8221; [ stateTopic=&#8221;tuya\/socket\/80401244cc50e3168f0f\/04eb51fe119819dd\/192.168.178.34\/state&#8221;, commandTopic=&#8221;tuya\/socket\/80401244cc50e3168f0f\/04eb51fe119819dd\/192.168.178.34\/command&#8221;, on=&#8221;{ \\&#8221;dps\\&#8221;: 1, \\&#8221;set\\&#8221;: true }&#8221;, off=&#8221;{ \\&#8221;dps\\&#8221;: 1, \\&#8221;set\\&#8221;: false }&#8221; ]<br>\nType    switch : Test_Power_Switch_GET_MQTT &#8220;Test_Power_Switch MQTT STATUS Channel&#8221;      [ stateTopic=&#8221;tuya\/socket\/80401244cc50e3168f0f\/04eb51fe119819dd\/192.168.178.34\/state&#8221;, commandTopic=&#8221;tuya\/socket\/80401244cc50e3168f0f\/04eb51fe119819dd\/192.168.178.34\/command&#8221;, on=&#8221;{ \\&#8221;schema\\&#8221;: true }&#8221;, off=&#8221;{ \\&#8221;schema\\&#8221;: true }&#8221; ]<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Lampen Terras 2:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">tuya\/socket\/80401244cc50e3168f0f\/04eb51fe119819dd\/192.168.178.34\/state<br>\ntuya\/socket\/80401244cc50e3168f0f\/04eb51fe119819dd\/192.168.178.34\/command<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">deviceid: 80401244cc50e3168f0f<br>\nlocalKey: 04eb51fe119819dd<br>\nipadres: 192.168.178.34<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Fontein:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">tuya\/socket\/80401244cc50e3168f0f\/04eb51fe119819dd\/192.168.178.34\/state<br>\ntuya\/socket\/80401244cc50e3168f0f\/04eb51fe119819dd\/192.168.178.34\/command<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">deviceid: 80401244cc50e3168f0f<br>\nlocalKey: 04eb51fe119819dd<br>\nipadres: 192.168.178.34<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">COMMAND: ON={ \\&#8221;dps\\&#8221;: 2, \\&#8221;set\\&#8221;: true } \/ { \\&#8221;dps\\&#8221;: 2, \\&#8221;set\\&#8221;: false }<br>\nscreen<br>\nnode \/etc\/openhab2\/scripts\/tuya-mqtt\/tuya-mqtt.js<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>CTRL-A then hit D<\/p><\/blockquote>\n\n\n\n<p class=\"wp-block-paragraph\">Reattach screen: screen -r<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">-ip 192.168.178.3 -id 80401244cc50e3168f0f -key 04eb51fe119819dd -set \u2018{ \u201cdps\u201d:1, \u201cset\u201d: false }\u2019<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Lampen Terras 3:<br>\ntuya\/socket\/60652064cc50e350a106\/688487ae048fb983\/192.168.178.21\/state<br>\ntuya\/socket\/60652064cc50e350a106\/688487ae048fb983\/192.168.178.21\/command<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">COMMAND: ON \/ OFF<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Tentverlichting<br>\ntuya\/socket\/60652064cc50e350a106\/688487ae048fb983\/192.168.178.21\/state<br>\ntuya\/socket\/60652064cc50e350a106\/688487ae048fb983\/192.168.178.21\/command<br>\n{ &#8220;dps&#8221;: 2, &#8220;set&#8221;: true }<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">deviceid: 60652064cc50e350a106<br>\nlocalKey: 688487ae048fb983<br>\nipadres: 192.168.178.21<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Configure channel<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">MQTT state topic <br>\ntuya\/socket\/80401244cc50e3168f0f\/04eb51fe119819dd\/192.168.178.34\/dps\/2<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">MQTT command topic <br>\ntuya\/socket\/80401244cc50e3168f0f\/04eb51fe119819dd\/192.168.178.34\/command<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Incoming value transformation <br>\n{ &#8220;dps&#8221;: 2, &#8220;set&#8221;: false }<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Outgoing value format <br>\n{ &#8220;dps&#8221;: 2, &#8220;set&#8221;: true }<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">On\/Open value <br>\n{ &#8220;dps&#8221;: 2, &#8220;set&#8221;: true }<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Off\/Closed value <br>\n{ &#8220;dps&#8221;: 2, &#8220;set&#8221;: false }<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This post was most recently updated on January 15th, 2020 Installation: node tuya-mqtt.js Run tya-mqtt in the background nohup node tuya-mqtt.js &amp; exit nohup node \/etc\/openhab2\/scripts\/tuya-mqtt\/tuya-mqtt.js &amp; exit device id: 80401244cc50e3168f0f localKey&#8221;:&#8221;04eb51fe119819dd ip adres: 192.168.178.34 rule &#8220;Toggle Tuya light\/switch on\/off via MQTT&#8221; when Item tuya_light received command then switch(receivedCommand) { case ON : actions.publishMQTT(&#8220;tuya\/switch\/80401244cc50e3168f0f\/04eb51fe119819dd\/192.168.178.34\/command\/on&#8221;,&#8221;&#8221;) case [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-27793","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.bleuanus.nl\/index.php\/wp-json\/wp\/v2\/posts\/27793","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.bleuanus.nl\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bleuanus.nl\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bleuanus.nl\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bleuanus.nl\/index.php\/wp-json\/wp\/v2\/comments?post=27793"}],"version-history":[{"count":1,"href":"https:\/\/www.bleuanus.nl\/index.php\/wp-json\/wp\/v2\/posts\/27793\/revisions"}],"predecessor-version":[{"id":27794,"href":"https:\/\/www.bleuanus.nl\/index.php\/wp-json\/wp\/v2\/posts\/27793\/revisions\/27794"}],"wp:attachment":[{"href":"https:\/\/www.bleuanus.nl\/index.php\/wp-json\/wp\/v2\/media?parent=27793"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bleuanus.nl\/index.php\/wp-json\/wp\/v2\/categories?post=27793"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bleuanus.nl\/index.php\/wp-json\/wp\/v2\/tags?post=27793"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}