iRayanKhan / homebridge-tuya

A Homebridge plugin to control Tuya devices locally.
MIT License
395 stars 165 forks source link

Issue with platform name and config.json setup #355

Open stauffes opened 2 years ago

stauffes commented 2 years ago

Checklist

Describe the bug I am able to install the plugin on a new bridge, however, the config.json file is pre-populated with two platforms named Tuya an d TuyaLan. The UI config only displays the platform Tuya and any added devices fall underneath this platform, however when I go to run the bridge, it is not able to find any devices because it is expecting them to be under the TuyaLan platform. I have tried to install this plugin on both my Pi and a hoobs running on a virtual ubuntu with the same effect. I have had some moderate luck manually configuring the config.json, however it is often overwritten when the bridge starts again with the same issue as before. Not sure I understand why the "Tuya" platform is being populated in the config.json file or why that is what is editable in the UI.

To Reproduce Install this plugin

Expected behavior I would expect the config.json file to only have one platform named TuyaLan and the UI to be able to edit devices within this platform.

Environment (please complete the following information):

iRayanKhan commented 2 years ago

Will be fixed in v2.1.0, thanks for reporting!

eshventures commented 2 years ago

I am encountering the same issue and unable to use the plug-in within Hoobs 4. It won't discover the devices. @stauffes - can you share what your work-around was in the config.json for the devices to be recognized? Thanks in advance for your help!

eshventures commented 2 years ago

I am encountering the same issue and unable to use the plug-in within Hoobs 4. It won't discover the devices. @stauffes - can you share what your work-around was in the config.json for the devices to be recognized? Thanks in advance for your help!

UPDATE: Played around with the code and got it working. Would be nice to see this updated in the next version though as per your comment, it will overwrite the code again on the bridge re-starting.

davidh2075 commented 1 year ago

Upgraded to HOOBS 4 and made the following changes to the code to get it working:

hoobs@hoobs:~ $ diff ./index_Tuya_SAVE.js /var/lib/hoobs/tuyabridge/node_modules/homebridge-tuya/index.js
27,28c27,28
< const PLUGIN_NAME = 'homebridge-tuya-lan';
< const PLATFORM_NAME = 'TuyaLan';
---
> const PLUGIN_NAME = 'homebridge-tuya';
> const PLATFORM_NAME = 'Tuya';
63c63
<     homebridge.registerPlatform(PLUGIN_NAME, PLATFORM_NAME, TuyaLan, true);
---
>     homebridge.registerPlatform(PLATFORM_NAME, TuyaLan, true);
hoobs@hoobs:~ $
05TEVE commented 8 months ago

This should now be fixed as per version 3.1.0. I updated the schema so that the existing configs from the previous versions would work without changes.

davidh2075 commented 8 months ago

Thank you!

davidh2075 commented 7 months ago

I just updated to 3.1.0 on HOOBS 4 and index.js has PLATFORM_NAME as TuyaLan, not Tuya:

const OilDiffuserAccessory = require('./lib/OilDiffuserAccessory');

const PLUGIN_NAME = 'homebridge-tuya';
const PLATFORM_NAME = 'TuyaLan';

const CLASS_DEF = {

The log file showed

17/02/2024, 07:37:24 Tuya Bridge Loaded plugin 'homebridge-tuya'
17/02/2024, 07:37:24 Tuya Bridge [ DEBUG ] Registering platform 'homebridge-tuya.TuyaLan'
17/02/2024, 07:37:24 Tuya Bridge Loading 2 platforms...
17/02/2024, 07:37:24 Tuya Bridge TuyaLan No devices found. Check that you have specified them in your config.json file.

I changed TuyaLan to Tuya in index.js, restarted the Tuya bridge, and all is OK.