iRayanKhan / homebridge-tuya

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

Help! #40

Closed jamesscf closed 5 years ago

jamesscf commented 5 years ago

Hello, I really cannot get this to work at all. I’m more than happy to pay someone to write me a .json code with my devices (I’ll email you all the id’s and keys) I’m basically after a .jason file I can upload to my raspberry pi and it works. Thanks!

codetheweb commented 5 years ago

If you give some more detail we may be able to help.

Here's a complete sample config file with just the homebridge-tuya platform:

{
   "bridge":{
      "name":"Homebridge",
      "username":"CC:22:3D:E3:CE:30",
      "port":51826,
      "pin":"031-45-154"
   },
   "accessories":[

   ],
   "platforms":[
      {
         "platform":"TuyaPlatform",
         "name":"TuyaPlatform",
         "devices":[
            {
               "name":"Tuya Outlet Device 1",
               "id":"xxxxxxxxxxxxxxxxxxxx",
               "key":"xxxxxxxxxxxxxxxx"
            }
         ]
      }
   ]
}
jamesscf commented 5 years ago

Great thanks,

Here’s what I’ve tried but surely it needs to have a login for the Tuya app to link up with the devices correctly ? Thanks

{ "bridge": { "name": "SmartLife", "username": "1A:2B:3C:4D:5E:6F", "port": 43007, "pin": "031-45-154" }, "Accessories": [{ "Accessory": "TuyaOutlet", "name": "Chrismas Tree Lights", "devId": "05200016b4e62d171188", "localKey": "ed8eed71e04d9965", "ip": "192.168.1.210", "type": "generic" }] }

jamesscf commented 5 years ago

Ive just tried this config.json file...

{ "bridge": { "name": "Homebridge", "username": "CC:22:3D:E3:CE:30", "port": 51826, "pin": "031-45-154" }, "accessories": [

],
"platforms": [{
    "platform": "TuyaPlatform",
    "name": "TuyaPlatform",
    "devices": [{
        "name": "Tuya Outlet Device 1",
        "id": "05200016b4e62d171188",
        "key": "ed8eed71e04d9965"
    }]
}]

}

This is the result i get... pi@raspberrypi:~ $ homebridge [2019-1-17 17:37:42] Loaded config.json with 0 accessories and 1 platforms. [2019-1-17 17:37:42] --- [2019-1-17 17:37:43] Loaded plugin: homebridge-tuya [2019-1-17 17:37:43] Registering platform 'homebridge-tuya.TuyaPlatform' [2019-1-17 17:37:43] --- [2019-1-17 17:37:43] Loaded plugin: homebridge-tuya-lan [2019-1-17 17:37:43] Registering platform 'homebridge-tuya-lan.TuyaLan' [2019-1-17 17:37:43] --- [2019-1-17 17:37:43] Loading 1 platforms... [2019-1-17 17:37:43] [TuyaPlatform] Initializing TuyaPlatform platform... [2019-1-17 17:37:43] Loading 0 accessories... Load homebridge-tuya-lan.TuyaLan Setup Payload: X-HM://0023ISYWY67NM Scan this code with your HomeKit app on your iOS device to pair with Homebridge:

Or enter this code with your HomeKit app on your iOS device to pair with Homebridge:

┌────────────┐     
│ 031-45-154 │     
└────────────┘     

/usr/lib/node_modules/homebridge-tuya-lan/index.js:47 this.config.devices.forEach(device => { ^

TypeError: Cannot read property 'devices' of null at TuyaLan.discoverDevices (/usr/lib/node_modules/homebridge-tuya-lan/index.js:47:21) at API.TuyaLan.api.on (/usr/lib/node_modules/homebridge-tuya-lan/index.js:39:18) at emitNone (events.js:111:20) at API.emit (events.js:208:7) at Server.run (/usr/lib/node_modules/homebridge/lib/server.js:99:13) at module.exports (/usr/lib/node_modules/homebridge/lib/cli.js:45:10) at Object. (/usr/lib/node_modules/homebridge/bin/homebridge:17:22) at Module._compile (module.js:653:30) at Object.Module._extensions..js (module.js:664:10) at Module.load (module.js:5

any help is greatly appreciated, Thanks!

codetheweb commented 5 years ago

Hmm, that should work...

Try doing npm i homebridge-tuya -g once more to make sure you have the latest version, then delete the accessories/ and persist/ directories in your Homebridge config folder.

Then start Homebridge with DEBUG=* homebridge (to turn on more verbose output) once again and post the output.

jamesscf commented 5 years ago

Does there not need to be any kind of log in to link the app to homebridge? Also is that the only perameters I need to put into home bridge as well as the downloaded files? Is there any other code I need to ‘write’? Thanks

codetheweb commented 5 years ago

Sorry, not really understanding what you're asking...

You don't need to usually run Homebridge with the DEBUG environment variable set to *, but it's helpful for debugging (as the name suggests).

You may need to adjust a dps option for your device if it doesn't work properly, but we can iron that out later after Homebridge stops crashing on startup.

jamesscf commented 5 years ago

I’ve just factory set my raspberry pi and started again and it works, great thank you! How do I add the rest of my devices in the .json file? Thanks

jamesscf commented 5 years ago

This is now working. A full re installation of homebridge made it work after the code was corrected. Thank you!

codetheweb commented 5 years ago

Glad you got it working.

Let me know if you still need any help.