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 & exit
nohup node /etc/openhab2/scripts/tuya-mqtt/tuya-mqtt.js & exit
device id: 80401244cc50e3168f0f
localKey”:”04eb51fe119819dd
ip adres: 192.168.178.34
rule “Toggle Tuya light/switch on/off via MQTT”
when
Item tuya_light received command
then
switch(receivedCommand) {
case ON : actions.publishMQTT(“tuya/switch/80401244cc50e3168f0f/04eb51fe119819dd/192.168.178.34/command/on”,””)
case OFF : actions.publishMQTT(“tuya/switch/80401244cc50e3168f0f/04eb51fe119819dd/192.168.178.34/command/off”,””)
}
end
192.168.178.21
Tent
deviceid: 80401244cc50e3168f0f
localKey”:04eb51fe119819dd
devId”:”80401244cc50e3168f0f”
22d6c916de6e3cad
tuya/socket/60652064cc50e350a106/688487ae048fb983/192.168.178.21/command
tuya/socket/60652064cc50e350a106/688487ae048fb983/192.168.178.21/dps/2/command
192.168.178.34
deviceid: 60652064cc50e350a106
localKey”:”688487ae048fb983″
“devId”:”80401244cc50e3168f0f”
“localKey”:”22d6c916de6e3cad”
“devId”:”60652064cc50e350a106″
“localKey”:”688487ae048fb983″
Type switch : Test_Power_Switch “Test_Power_Switch” [ stateTopic=”tuya/socket/80401244cc50e3168f0f/04eb51fe119819dd/192.168.178.34/state”, commandTopic=”tuya/socket/80401244cc50e3168f0f/04eb51fe119819dd/192.168.178.34/command”, on=”1″, off=”0″ ]
Type switch : Test_Power_Switch_MQTT “Test_Power_Switch MQTT Channel” [ stateTopic=”tuya/socket/80401244cc50e3168f0f/04eb51fe119819dd/192.168.178.34/state”, commandTopic=”tuya/socket/80401244cc50e3168f0f/04eb51fe119819dd/192.168.178.34/command”, on=”{ \”dps\”: 1, \”set\”: true }”, off=”{ \”dps\”: 1, \”set\”: false }” ]
Type switch : Test_Power_Switch_GET_MQTT “Test_Power_Switch MQTT STATUS Channel” [ stateTopic=”tuya/socket/80401244cc50e3168f0f/04eb51fe119819dd/192.168.178.34/state”, commandTopic=”tuya/socket/80401244cc50e3168f0f/04eb51fe119819dd/192.168.178.34/command”, on=”{ \”schema\”: true }”, off=”{ \”schema\”: true }” ]
Lampen Terras 2:
tuya/socket/80401244cc50e3168f0f/04eb51fe119819dd/192.168.178.34/state
tuya/socket/80401244cc50e3168f0f/04eb51fe119819dd/192.168.178.34/command
deviceid: 80401244cc50e3168f0f
localKey: 04eb51fe119819dd
ipadres: 192.168.178.34
Fontein:
tuya/socket/80401244cc50e3168f0f/04eb51fe119819dd/192.168.178.34/state
tuya/socket/80401244cc50e3168f0f/04eb51fe119819dd/192.168.178.34/command
deviceid: 80401244cc50e3168f0f
localKey: 04eb51fe119819dd
ipadres: 192.168.178.34
COMMAND: ON={ \”dps\”: 2, \”set\”: true } / { \”dps\”: 2, \”set\”: false }
screen
node /etc/openhab2/scripts/tuya-mqtt/tuya-mqtt.js
CTRL-A then hit D
Reattach screen: screen -r
-ip 192.168.178.3 -id 80401244cc50e3168f0f -key 04eb51fe119819dd -set ‘{ “dps”:1, “set”: false }’
Lampen Terras 3:
tuya/socket/60652064cc50e350a106/688487ae048fb983/192.168.178.21/state
tuya/socket/60652064cc50e350a106/688487ae048fb983/192.168.178.21/command
COMMAND: ON / OFF
Tentverlichting
tuya/socket/60652064cc50e350a106/688487ae048fb983/192.168.178.21/state
tuya/socket/60652064cc50e350a106/688487ae048fb983/192.168.178.21/command
{ “dps”: 2, “set”: true }
deviceid: 60652064cc50e350a106
localKey: 688487ae048fb983
ipadres: 192.168.178.21
Configure channel
MQTT state topic
tuya/socket/80401244cc50e3168f0f/04eb51fe119819dd/192.168.178.34/dps/2
MQTT command topic
tuya/socket/80401244cc50e3168f0f/04eb51fe119819dd/192.168.178.34/command
Incoming value transformation
{ “dps”: 2, “set”: false }
Outgoing value format
{ “dps”: 2, “set”: true }
On/Open value
{ “dps”: 2, “set”: true }
Off/Closed value
{ “dps”: 2, “set”: false }