AMoo-Miki / homebridge-tuya-lan

Homebridge plugin for IoT devices that use Tuya Smart's platform
MIT License
203 stars 51 forks source link

Error on start #74

Open xoniq opened 5 years ago

xoniq commented 5 years ago

I keep getting this error when starting Homebridge:

/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:98:13)
    at module.exports (/usr/lib/node_modules/homebridge/lib/cli.js:43:10)
    at Object.<anonymous> (/usr/lib/node_modules/homebridge/bin/homebridge:17:22)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)

I tried debugging the index.js with console.logs, and this.config is not being set.

Zer0x00 commented 5 years ago

Had the same problem for couple of hours since yesterday. My problem was probably a misconfigured config.json (diffchecked it but found no valid difference) Also uninstalled homebridge-tuya-lan and homebridge.

Could you post yours or try by removing yours and creating it from scratch with https://raw.githubusercontent.com/nfarina/homebridge/master/config-sample.json

xoniq commented 5 years ago

Replaced it with the web version instead of directly via lan.

AMoo-Miki commented 5 years ago

That indicates that the plugin didn't get the config block it was expecting. Can you post your entire config block please? Black out your keys though.

xoniq commented 5 years ago

More info here:

https://github.com/codetheweb/tuyapi/issues/246

Seems TuyApi is not compatible with my device yet.

AMoo-Miki commented 5 years ago

I scrolled through that issue: the "json obj data unvalid" is a problem that Tuya's own iOS app hasn't solved yet. I have reached out to them and will check as soon as a new version of their app is released. I have thrown in some logic to avoid having the plugin die due to it.

Please give the latest rc release a shot by doing npm i -g homebridge-tuya-lan@rc. It includes logic to understand this newer API.

The Setup Instructions have changed in case you need to obtain a fresh id and key.

xdmate commented 5 years ago

Ah, I'm having this issue as well. TypeError: Cannot read property 'devices' of null

AMoo-Miki commented 5 years ago

@xdmate that error is an indicator of a bad config file.

xdmate commented 5 years ago

Could you take a look at this and tell me if its okay? https://pastebin.com/PVmHRLiJ

I only removed my key, id and rtsp stream to post it. Sorry if it's something super basic, I'm still really new at this. D:

AMoo-Miki commented 5 years ago

The problem is that TuyaLan block has been added under cameras. If you are having trouble with the editor, email me your config and I will correct it and send it back.

config problem

xdmate commented 5 years ago

What is your email? Do you just want in plain text, or a pastebin link?

I'm having trouble figuring out how to move the block and make it properly work. I think actually seeing it corrected would help me better understand/learn. I feel like a total noob right now, but I appreciate the help. :)

AMoo-Miki commented 5 years ago

Sent you the fixed file.

By the way, if you ever get stuck, you can visualize your JSON at JSON Editor Online or JSON Formatter.

AMoo-Miki commented 5 years ago

Note to self: @xdmate is using HOOBS and will need a release to be able to update.