The script does want itΒ΄s meant to do.
All devices which are paired to the app are listed.
Great! So the basic communication is working! Now⦠Please take the output from the wizard and manually create the devices.conf - file in the tuya-mqtt folder. Paste the output from the wizard into the file and check if the structure looks like:
[
{
name: 'Tuya Device 1',
id: '86435357d8b123456789',
key: '8b2a69c9876543210'
},
{
name: 'Tuya Device 2',
id: 'eb532eea7d12345678abc',
key: '899810012345678'
}
]
If it looks ok, please start tuya-mqtt manually:
DEBUG=* node tuya-mqtt.js
Unfortunately the same Error.
Devices file not found!
tuya-mqtt:error SyntaxError: JSON5: invalid character βiβ at 9:5
tuya-mqtt:error at syntaxError (/usr/tuya-mqtt/node_modules/json5/lib/parse.js:1083:17)
tuya-mqtt:error at invalidChar (/usr/tuya-mqtt/node_modules/json5/lib/parse.js:1028:12)
tuya-mqtt:error at Object.afterPropertyValue (/usr/tuya-mqtt/node_modules/json5/lib/parse.js:654:15)
tuya-mqtt:error at Object.default (/usr/tuya-mqtt/node_modules/json5/lib/parse.js:146:37)
tuya-mqtt:error at lex (/usr/tuya-mqtt/node_modules/json5/lib/parse.js:78:42)
tuya-mqtt:error at Object.parse (/usr/tuya-mqtt/node_modules/json5/lib/parse.js:25:17)
tuya-mqtt:error at main (/usr/tuya-mqtt/tuya-mqtt.js:96:31)
tuya-mqtt:error at Object. (/usr/tuya-mqtt/tuya-mqtt.js:178:1)
tuya-mqtt:error at Module._compile (internal/modules/cjs/loader.js:778:30)
tuya-mqtt:error at Object.Module._extensionsβ¦js (internal/modules/cjs/loader.js:789:10) +0ms
tuya-mqtt:info Exit code: 1 +0ms
Oh hang on⦠I just tried on my system to rename the devices.conf and the error I get is:
Devices file not found!
tuya-mqtt:error Error: ENOENT: no such file or directory, open './devices.conf'
tuya-mqtt:error at Object.openSync (fs.js:476:3)
tuya-mqtt:error at Object.readFileSync (fs.js:377:35)
tuya-mqtt:error at main (/srv/openhab2-conf/scripts/tuya-mqtt/tuya-mqtt.js:95:28)
tuya-mqtt:error at Object.<anonymous> (/srv/openhab2-conf/scripts/tuya-mqtt/tuya-mqtt.js:178:1)
tuya-mqtt:error at Module._compile (internal/modules/cjs/loader.js:1063:30)
tuya-mqtt:error at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
tuya-mqtt:error at Module.load (internal/modules/cjs/loader.js:928:32)
tuya-mqtt:error at Function.Module._load (internal/modules/cjs/loader.js:769:14)
tuya-mqtt:error at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
tuya-mqtt:error at internal/main/run_main_module.js:17:47 +0ms
tuya-mqtt:info Exit code: 1 +0ms
You are getting an invalid character errorβ¦ Just to verify: Can you please navigate to your tuya-mqtt folder (from your output I guess itβs /usr/tuya-mqtt) and run:
git pull
followed by:
npm install
sudo git pull
Bereits aktuell.
pi@raspberrypi:/usr/tuya-mqtt $ sudo npm install
audited 322 packages in 10.347s
45 packages are looking for funding
run npm fund
for details
found 2 vulnerabilities (1 low, 1 high)
run npm audit fix
to fix them, or npm audit
for details
pi@raspberrypi:/usr/tuya-mqtt $ npmaudit
-bash: npmaudit: Kommando nicht gefunden.
pi@raspberrypi:/usr/tuya-mqtt $ nom audit
-bash: nom: Kommando nicht gefunden.
pi@raspberrypi:/usr/tuya-mqtt $ npm audit
=== npm audit security report ===
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Manual Review β
β Some vulnerabilities require your attention to resolve β
β β
β Visit xxxxxxxxxxxxxxxxxxxxxxxxx β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
βββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Low β Prototype Pollution β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Package β minimist β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Patched in β >=0.2.1 <1.0.0 || >=1.2.3 β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Dependency of β @tuyapi/cli β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Path β @tuyapi/cli > http-mitm-proxy > optimist > minimist β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β More info β https://npmjs.com/advisories/1179 β
βββββββββββββββββ΄βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
βββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β High β Prototype Pollution in node-forge β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Package β node-forge β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Patched in β >= 0.10.0 β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Dependency of β @tuyapi/cli β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Path β @tuyapi/cli > http-mitm-proxy > node-forge β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β More info β https://npmjs.com/advisories/1561 β
βββββββββββββββββ΄βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
found 2 vulnerabilities (1 low, 1 high) in 322 scanned packages
2 vulnerabilities require manual review. See the full report for details.
Hmβ¦ would you mind if you send me your devices.conf (without idβs and keys) via PM?
And can you please run:
sudo sed -n '9p' < devices.conf
in the tuya-mqtt directory and post the output here? I think I was able to reproduce your issueβ¦
[
{
name: βPB 1β,
id: β27384645f4cfa******β,
key: β6463c15290******β
},
{
name: βFenster Schlafzimmerβ
id: β13600724840d8e******β,
key: βfbfb5b3109******β
}
]
sudo sed -n β9pβ < devices.conf:
id: β13600724840d8e******β,
Ok, there is a comma missing at the end of:
name: 'Fenster Schlafzimmer'
ItΒ΄s running. Just a missing comma.
Thank you very much for your help and patience.
Glad it works now and good to know that I am not the only one who misses a comma from time to time
Sorry again for the lack of response in the last days/weeks!
Now my devices couldnΒ΄t be find. IΒ΄m going insane.
Did you open the app on your smartphone after you started tuya-mqtt?
Yes. Through the App iβm able to control the device.
Edit: One device has been found.
Please note that Tuyaβs API supports only 1 active connection. So if you open the app whilst tuya-mqtt is running, tuya-mqtt will lose the connectionβ¦ I only used the app to install the devices and since then I never openend it.
Can you please share which device has been found and which ones are missing?
Hi,
What changes are required to the above installation notes for OH3.
Example being, are the folder locations the same?
I havenβt tried it but it should work the same way. You can install tuya-mqtt wherever you want as the communication between OH and tuya-mqtt is done via the mqtt binding (which connects to mosquito).
Hi,
Iβm trying to run βtuya-cli wizardβ but Iβm getting the below debug response.
How do you give access to the API on a Pi?
sudo DEBUG=* tuya-cli wizard
Followed by putting in the three required codes
[
Error: you donβt have access to this API
at OpenAPI._client.got_1.default.extend.hooks.afterResponse (/usr/lib/node_modules/@tuyapi/cli/node_modules/@tuyapi/openapi/dist/api.js:73:31)
at EventEmitter. (/usr/lib/node_modules/@tuyapi/cli/node_modules/got/dist/source/as-promise.js:87:38)
at processTicksAndRejections (internal/process/task_queues.js:97:5),
Error: you donβt have access to this API
at OpenAPI._client.got_1.default.extend.hooks.afterResponse (/usr/lib/node_modules/@tuyapi/cli/node_modules/@tuyapi/openapi/dist/api.js:73:31)
at EventEmitter. (/usr/lib/node_modules/@tuyapi/cli/node_modules/got/dist/source/as-promise.js:87:38)
at processTicksAndRejections (internal/process/task_queues.js:97:5),
Error: you donβt have access to this API
at OpenAPI._client.got_1.default.extend.hooks.afterResponse (/usr/lib/node_modules/@tuyapi/cli/node_modules/@tuyapi/openapi/dist/api.js:73:31)
at EventEmitter. (/usr/lib/node_modules/@tuyapi/cli/node_modules/got/dist/source/as-promise.js:87:38)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
]
This happens most likely if you forgot to run
npm install
within the tuya-mqtt - directory. Can you please check?
Hi Flip,
The issue was in that I had not turned on the APIβs in the Tuya website. After doing this, the discovery worked.