thirug010 / Virtual-Tasmota-for-Tuya-api-devices

New Tuya firmware (1.0.7, 2.0, 3.3..) updates disable the OTA Flashing options at the moment, This feature allows you to use the non flashed Tuya devices as tasmota device along with tasmota flashed devices, most of the tasmota features is virtually available and it can be expanded.
MIT License
16 stars 0 forks source link

using an existing MQTT server #6

Open mijnmodelbaan opened 5 years ago

mijnmodelbaan commented 5 years ago

Hi,

I would like to use my existing MQTT server (mosquitto) with your program. Is this possible and if yes, how do I accomplish that? I'm not really Raspberry/Linux savvy so I need some guidance in this.

I already tried to put the IP number of my server in Utility.js, but then I get the following error:

~/Virtual-Tasmota-for-Tuya-api-devices $ nodemon --ext rs tuya_api_mqtt.js [nodemon] 1.19.1 [nodemon] to restart at any time, enter rs [nodemon] watching: . [nodemon] starting node tuya_api_mqtt.js Web Server Running on Port 8082 CDN Running on Port 2362 events.js:174 throw er; // Unhandled 'error' event ^

Error: Connection refused: Not authorized at MqttClient._handleConnack (/home/pi/Virtual-Tasmota-for-Tuya-api-devices/node_modules/mqtt/lib/client.js:1076:15) at MqttClient._handlePacket (/home/pi/Virtual-Tasmota-for-Tuya-api-devices/node_modules/mqtt/lib/client.js:365:12) at work (/home/pi/Virtual-Tasmota-for-Tuya-api-devices/node_modules/mqtt/lib/client.js:283:12) at Writable.writable._write (/home/pi/Virtual-Tasmota-for-Tuya-api-devices/node_modules/mqtt/lib/client.js:294:5) at doWrite (/home/pi/Virtual-Tasmota-for-Tuya-api-devices/node_modules/readable-stream/lib/_stream_writable.js:428:64) at writeOrBuffer (/home/pi/Virtual-Tasmota-for-Tuya-api-devices/node_modules/readable-stream/lib/_stream_writable.js:417:5) at Writable.write (/home/pi/Virtual-Tasmota-for-Tuya-api-devices/node_modules/readable-stream/lib/_stream_writable.js:334:11) at Socket.ondata (_stream_readable.js:709:20) at Socket.emit (events.js:198:13) at addChunk (_stream_readable.js:288:12) Emitted 'error' event at: at MqttClient._handleConnack (/home/pi/Virtual-Tasmota-for-Tuya-api-devices/node_modules/mqtt/lib/client.js:1078:10) at MqttClient._handlePacket (/home/pi/Virtual-Tasmota-for-Tuya-api-devices/node_modules/mqtt/lib/client.js:365:12) [... lines matching original stack trace ...] at addChunk (_stream_readable.js:288:12) [nodemon] app crashed - waiting for file changes before starting...

I would like to use my existing MQTT server as there are other devices and programs using it.

Thanks for a reply.

thirug010 commented 5 years ago

Sorry for the Delay I was out of station.

I am using "mosquitto" myself it is working just fine. I will check and update you

thirug010 commented 5 years ago

@mijnmodelbaan,

I guess your configued Mqtt as secure connection mode, I have updated the code to use username, password for mqtt server.

Get latest and update the mqtt server config and let me know, check on the mqtt server you should see vir_tasmota_001 client connected

Update the following MQttserver information in the "Utility.js"

mijnmodelbaan commented 5 years ago

Hi, Thanks for your answer and effort and I'll give it a try. Is the client name 'vir_tasmota_001' mandatory or can I change it ? BR//Willem.

thirug010 commented 5 years ago

@mijnmodelbaan,

you can change it will be use to display on mosquitte server as client "youname" connect with ip address that is all. this is to identify your client connect by default it will named as nodejs_somerandom numbers

thirug010 commented 5 years ago

@mijnmodelbaan, Any update ?

mijnmodelbaan commented 5 years ago

No update, yet. Very busy with other stuff, it'll have to wait.