Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Smart Video Doorbell (Wi-Fi) #15

Open
kgiori opened this issue Sep 12, 2020 · 8 comments
Open

Smart Video Doorbell (Wi-Fi) #15

kgiori opened this issue Sep 12, 2020 · 8 comments
Labels
discussion new device wontfix This will not be worked on

Comments

@kgiori
Copy link

kgiori commented Sep 12, 2020

The Home Assistant project and some other smart home gateways have managed to connect to the TUYA smart doorbell API, so I'm wondering if this add-on for the WebThings Gateway could be enhanced to include it. The device includes a motion sensor, IR and light sensors, a mic, speaker, video camera, and of course a doorbell (momentary push button).

And even if I tried to initially detect it as a switch, I am not sure what to fill in for "key (aka localKey)" on the configuration page for the add-on. I did put in the device id. But I don't see anything when I scan for devices. I would also have expected to have to fill in my email/passwd to connect via the API, but that information isn't in the add-on config.

Any thoughts, tips?

@kgiori
Copy link
Author

kgiori commented Sep 12, 2020

Progress -- I was able to figure out the "id" and "key" so that scan found my doorbell. However, it has no properties. So I guess that is the next thing to figure out.

@bewee
Copy link
Owner

bewee commented Sep 13, 2020

Hi,

nice to hear you successfully obtained your device's id and key values. So the first step is done already.

The Home Assistant project and some other smart home gateways have managed to connect to the TUYA smart doorbell API

As far as I know, tuya provides an own interface dedicated to Home Assistant. That's also why you can simply connect using your tuya credentials. I experimented a little taking advantage of this interface (have a look at this repository which utilizes the cloudtuya package instead of the tuyapi used in this project) as well but without overwhelming success. As far as I know this interfae is neither well documented nor very stable (though I would be quite happy being proved wrong there).

However, it has no properties

Could you please do the following:

  1. Go to the add-on settings and change the device type to (nothing)
  2. Also in the add-on settings, set the log level to debug
  3. After saving, have a look at the device. Does it show any properties now?
  4. Go to settings / developer / internal logs, choose the most recent one and provide it (or rather the lines of that file which were created by the tuya-adapter after the time of saving your add-on settings) to me

If you experience any problems doing so just reach back to me.

@kgiori
Copy link
Author

kgiori commented Sep 13, 2020

Hmmmm. Maybe I don't have the correct key value (see log). When leaving the device type undefined, it is added with no properties, actions, nor events. Log grepped for "tuya":

2020-09-13 10:55:40.657 INFO   : tuya-adapter: Opening database: /home/pi/.mozilla-iot/config/db.sqlite3
2020-09-13 10:55:41.071 INFO   : tuya-adapter: Loading add-on tuya-adapter from /home/pi/.mozilla-iot/addons/tuya-adapter
2020-09-13 10:55:41.152 INFO   : tuya-adapter: Initialize device: 6c4c2ddf17163d5ae7g9p3 type undefined
2020-09-13 10:55:41.154 INFO   : tuya-adapter: tuya-6c4c2ddf17163d5ae7g9p3 Initialize tuya device {"id":"6c4c2ddf17163d5ae7g9p3","name":"doorbell","key":"cxo5hjsicffllxmo"}
2020-09-13 10:55:41.155 INFO   : tuya-adapter: tuya-6c4c2ddf17163d5ae7g9p3 Loading ownconf undefined
2020-09-13 10:55:41.155 INFO   : tuya-adapter: tuya-6c4c2ddf17163d5ae7g9p3 No dps in ownconf. Initializing to empty object
2020-09-13 10:55:41.158 INFO   : tuya-adapter: Thing added tuya-6c4c2ddf17163d5ae7g9p3
2020-09-13 10:56:38.731 INFO   : tuya-adapter: Pairing started
2020-09-13 10:56:47.813 INFO   : date-time-adapter: AddonManagerProxy: recv: {'messageType': 8207, 'data': {'deviceId': 'tuya-6c4c2ddf17163d5ae7g9p3', 'device': {'title': 'doorbell', '@context': 'https://iot.mozilla.org/schemas', '@type': [], 'description': 'Tuya Device', 'href': '/things/tuya-6c4c2ddf17163d5ae7g9p3', 'properties': {}, 'actions': {}, 'events': {}, 'links': [{'rel': 'properties', 'href': '/things/tuya-6c4c2ddf17163d5ae7g9p3/properties'}, {'rel': 'actions', 'href': '/things/tuya-6c4c2ddf17163d5ae7g9p3/actions'}, {'rel': 'events', 'href': '/things/tuya-6c4c2ddf17163d5ae7g9p3/events'}, {'rel': 'alternate', 'mediaType': 'text/html', 'href': '/things/tuya-6c4c2ddf17163d5ae7g9p3'}], 'layoutIndex': 40, 'selectedCapability': 'Custom', 'iconHref': None}, 'adapterId': 'date-time-adapter', 'pluginId': 'date-time-adapter'}}
2020-09-13 10:56:47.815 INFO   : tuya-adapter: Thing saved tuya-6c4c2ddf17163d5ae7g9p3
2020-09-13 10:56:49.200 INFO   : tuya-adapter: tuya-6c4c2ddf17163d5ae7g9p3 Device found. Connecting...
2020-09-13 10:56:49.694 INFO   : tuya-adapter: Pairing cancelled
2020-09-13 10:56:50.935 INFO   : tuya-adapter: tuya-6c4c2ddf17163d5ae7g9p3 Connected!
2020-09-13 10:56:50.977 INFO   : tuya-adapter: tuya-6c4c2ddf17163d5ae7g9p3 Data ��?*���+��	[�����ѳ^�xO���
2020-09-13 10:56:50.980 INFO   : tuya-adapter: tuya-6c4c2ddf17163d5ae7g9p3 Stop!
2020-09-13 10:56:50.981 ERROR  : tuya-adapter: tuya-6c4c2ddf17163d5ae7g9p3 Device replied with  ��?*���+��	[�����ѳ^�xO���
2020-09-13 10:56:50.984 ERROR  : tuya-adapter: tuya-6c4c2ddf17163d5ae7g9p3 Please check your key value!
2020-09-13 10:56:50.987 INFO   : tuya-adapter: tuya-6c4c2ddf17163d5ae7g9p3 Data ��?*���+��	[�����ѳ^�xO���
2020-09-13 10:56:50.991 INFO   : tuya-adapter: tuya-6c4c2ddf17163d5ae7g9p3 Stop!
2020-09-13 10:56:50.994 ERROR  : tuya-adapter: tuya-6c4c2ddf17163d5ae7g9p3 Device replied with  ��?*���+��	[�����ѳ^�xO���
2020-09-13 10:56:50.997 ERROR  : tuya-adapter: tuya-6c4c2ddf17163d5ae7g9p3 Please check your key value!
2020-09-13 10:56:50.998 INFO   : tuya-adapter: Thing updated tuya-6c4c2ddf17163d5ae7g9p3
2020-09-13 11:01:44.763 ERROR  : tuya-adapter: tuya-6c4c2ddf17163d5ae7g9p3 Internal tuyapi error Error: Error from socket
2020-09-13 11:01:44.764 ERROR  : tuya-adapter:     at Socket.client.on.err (/home/pi/.mozilla-iot/addons/tuya-adapter/node_modules/tuyapi/index.js:330:30)
2020-09-13 11:01:44.764 ERROR  : tuya-adapter:     at Socket.emit (events.js:198:13)
2020-09-13 11:01:44.764 ERROR  : tuya-adapter:     at emitErrorNT (internal/streams/destroy.js:91:8)
2020-09-13 11:01:44.765 ERROR  : tuya-adapter:     at emitErrorAndCloseNT (internal/streams/destroy.js:59:3)
2020-09-13 11:01:44.765 ERROR  : tuya-adapter:     at process._tickCallback (internal/process/next_tick.js:63:19)
2020-09-13 11:01:44.766 INFO   : tuya-adapter: tuya-6c4c2ddf17163d5ae7g9p3 Disconnected!
2020-09-13 11:01:44.767 INFO   : tuya-adapter: tuya-6c4c2ddf17163d5ae7g9p3 Already dead

@bewee
Copy link
Owner

bewee commented Sep 14, 2020

Data ��?*���+�� [�����ѳ^�xO���

Hmm, this really looks a lot as if your device uses a completely different protocol than all the other ones supported by tuyapi. Honestly, "Please check your key value" gets logged whenever something is wrong with the data sent by the device. Here, this is definitely the case, but I guess it's all about the protocol and not a wrong key...

@kgiori
Copy link
Author

kgiori commented Sep 14, 2020

Unfortunately, I'm told this smart doorbell product does not support a local connection (see image from Tuya support). Does your Tuya add-on connect using a local API? Or does it use the cloud connection?

Screen Shot 2020-09-14 at 10 45 02 AM

@bewee
Copy link
Owner

bewee commented Sep 14, 2020

This add-on is based on the tuyapi, wich (as far as I know) only uses the local API. Home Assistant on the other hand (and therefore also cloudtuya as well as this project) use the could API. Therefore, you can just sign in with your e-mail address there instead of having to obtain the id and key values (which are used to find out the ip adress which is then used to communicate with the device locally - that's at least how I understand it). There is an open issue in the tuya repository that discusses using tuya cloud instead of local control: codetheweb/tuyapi#20

@kgiori
Copy link
Author

kgiori commented Sep 14, 2020

Therefore, you can just sign in with your e-mail address there instead of having to obtain the id and key values

Sign in? Do you mean I can put my email/pass for iot.tuya.com in the add-on configuration page, in the fields for id and key? I glanced at the other thread you linked to but it's rather confusing. Thanks much though for being so responsive and helpful!

For anyone else thinking of buying one of these smart doorbells, think hard. If I had known it wasn't possible to connect locally and avoid their cloud after discovery, there's no way I would have bought this thing... :(

@bewee
Copy link
Owner

bewee commented Sep 14, 2020

The tuyacolud-adapter is based on a Homeassistant interface. So yes, this one allows to sign in via e-mail + password. With this add-on, the connection to the device is running through the tuya cloud. But it is rather unstable and I only managed to add very basic functionality to this add-on. The linked add-on has a different configuration page than this add-on (since it works completely different). It does not allow you to enter id/key values there but you rather have to specify username, password, country code and region.

@bewee bewee added new device wontfix This will not be worked on labels Jan 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion new device wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants