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

Missing motion sensor type #33

Closed
experimint opened this issue Dec 27, 2018 · 26 comments
Closed

Missing motion sensor type #33

experimint opened this issue Dec 27, 2018 · 26 comments

Comments

@experimint
Copy link

Hi there,

I've added my motion sensor to homebridge; thanks a lot for the detailed information provided in this repo :)
However; the device is registered as a 'general' type; I can set the device to be a 'power point', 'Light' or a 'fan' in it's homekit settings.

Is there a type I can register the device as, to let HomeKit see/use it as a sensor?

image

2018-12-27 17 46 29
2018-12-27 17 46 13
2018-12-27 17 45 56

@boatboy12
Copy link

boatboy12 commented Dec 29, 2018

I also have same question with a door sensor that uses the Tuya app. All my Tuya lights work fine but the sensor in my config.json file just returns an error and seems to get ignored, does not show up on homekit with all my Tuya lights. Hoping to be able to see status (open/close) of sensor on HomeKit.

@codetheweb
Copy link
Collaborator

I don't think the sensors will work properly, as other users have reported that sensor-type devices only connect to WiFi when their state is changed or at a static interval - so it's not possible to query them whenever. It may be possible to set up some kind of MITM MQTT thing to capture the updates, I'm not sure.

Sorry about that, but it's more a limitation of the device rather than a limitation of this plugin.

If you have any ideas for supporting sensors, I'm open to hearing them.

@NorthernMan54
Copy link
Contributor

Max,

I’m thinking that motion sensors and contact sensors should work really similar to my wifi dimmers, where they generate an event in real time for each change.

If the people that have these devices have some time collect logs etc we should be able to add them similar to the wifi dimmers.

@boatboy12
Copy link

I have a door sensor and am willing to help to further the cause. I’m a newbie and not quite sure how to “collect logs”. Can you point me in the right direction?

@experimint
Copy link
Author

I have a door sensor and am willing to help to further the cause. I’m a newbie and not quite sure how to “collect logs”. Can you point me in the right direction?

Same here!

@NorthernMan54
Copy link
Contributor

@boatboy12 @experimint Okay I'm assuming that these devices generate events on the local API the same as my wifi dimmers that generate events when the button on the switch is pressed or they are dimmed.

If they work the same as the dimmer, it is pretty straight forward to create them as Motion or contact device instead.

To test this working theory out, please change your config.json to have the device be a dimmer, see the config example in the README ( don't worry about the options section, as we need to determine what they are ).

Then run homebridge with the -D command line option, ie homebridge -D, this will enable enhanced debugging output, and have the device generate an event ( ie open the door or trigger a motion event ). ( Don't worry about discovering or adding devices in the Home app etc as we only are interested in the device communications )

What I'm interested in is the output from these lines in the code

https://github.com/codetheweb/homebridge-tuya/blob/966b0216a8224b54b36f575bc3155f6209a99959/lib/dimmer.js#L47

and

https://github.com/codetheweb/homebridge-tuya/blob/966b0216a8224b54b36f575bc3155f6209a99959/lib/dimmer.js#L63

If these are generated when an event occurs, it should be straight forward to add them

Also, if you could supply the output from the script in issue #16 that will help as well, but it is only needed if they generate events.

@experimint
Copy link
Author

I've got my sensor configed as follows:

{
      "name": "Motion Sensor configed as dimmer",
      "id": "1884811884f3eb2fffa7",
      "key": "bf6c41a32e572851",
      "ip": "192.168.178.150",
     "type": "dimmer"
    }

And when I run homebridge -D TuyaPlatform logs the following:

[2018-12-31 16:27:44] [TuyaPlatform] Initializing TuyaPlatform platform...

A couple of these:

[2018-12-31 16:27:44] [TuyaPlatform] Configuring cached accessory: [Beweegingssensor Aanrecht] 1884811884f3eb2fffa7 5c603697-5fee-4b16-b2de-77d970e9908a
[2018-12-31 16:27:44] [TuyaPlatform] {"displayName":"Beweegingssensor Aanrecht","UUID":"5c603697-5fee-4b16-b2de-77d970e9908a","category":7,"services":[{"UUID":"0000003E-0000-1000-8000-0026BB765291","iid":null,"characteristics":[{"displayName":"Identify","UUID":"00000014-0000-1000-8000-0026BB765291","iid":null,"value":false,"status":null,"eventOnlyCharacteristic":false,"props":{"format":"bool","unit":null,"minValue":null,"maxValue":null,"minStep":null,"perms":["pw"]},"subscriptions":0,"_events":{},"_eventsCount":1},{"displayName":"Manufacturer","UUID":"00000020-0000-1000-8000-0026BB765291","iid":null,"value":"Default-Manufacturer","status":null,"eventOnlyCharacteristic":false,"props":{"format":"string","unit":null,"minValue":null,"maxValue":null,"minStep":null,"perms":["pr"]},"subscriptions":0,"_events":{},"_eventsCount":1},{"displayName":"Model","UUID":"00000021-0000-1000-8000-0026BB765291","iid":null,"value":"Default-Model","status":null,"eventOnlyCharacteristic":false,"props":{"format":"string","unit":null,"minValue":null,"maxValue":null,"minStep":null,"perms":["pr"]},"subscriptions":0,"_events":{},"_eventsCount":1},{"displayName":"Name","UUID":"00000023-0000-1000-8000-0026BB765291","iid":null,"value":"Beweegingssensor Aanrecht","status":null,"eventOnlyCharacteristic":false,"props":{"format":"string","unit":null,"minValue":null,"maxValue":null,"minStep":null,"perms":["pr"]},"subscriptions":0,"_events":{},"_eventsCount":1},{"displayName":"Serial Number","UUID":"00000030-0000-1000-8000-0026BB765291","iid":null,"value":"Default-SerialNumber","status":null,"eventOnlyCharacteristic":false,"props":{"format":"string","unit":null,"minValue":null,"maxValue":null,"minStep":null,"perms":["pr"]},"subscriptions":0,"_events":{},"_eventsCount":1},{"displayName":"Firmware Revision","UUID":"00000052-0000-1000-8000-0026BB765291","iid":null,"value":"","status":null,"eventOnlyCharacteristic":false,"props":{"format":"string","unit":null,"minValue":null,"maxValue":null,"minStep":null,"perms":["pr"]},"subscriptions":0,"_events":{},"_eventsCount":1}],"optionalCharacteristics":[],"isHiddenService":false,"isPrimaryService":false,"linkedServices":[]},{"displayName":"Beweegingssensor Aanrecht","UUID":"00000047-0000-1000-8000-0026BB765291","iid":null,"characteristics":[{"displayName":"Name","UUID":"00000023-0000-1000-8000-0026BB765291","iid":null,"value":"Beweegingssensor Aanrecht","status":null,"eventOnlyCharacteristic":false,"props":{"format":"string","unit":null,"minValue":null,"maxValue":null,"minStep":null,"perms":["pr"]},"subscriptions":0,"_events":{},"_eventsCount":1},{"displayName":"On","UUID":"00000025-0000-1000-8000-0026BB765291","iid":null,"value":false,"status":null,"eventOnlyCharacteristic":false,"props":{"format":"bool","unit":null,"minValue":null,"maxValue":null,"minStep":null,"perms":["pr","pw","ev"]},"subscriptions":0,"_events":{},"_eventsCount":1},{"displayName":"Outlet In Use","UUID":"00000026-0000-1000-8000-0026BB765291","iid":null,"value":false,"status":null,"eventOnlyCharacteristic":false,"props":{"format":"bool","unit":null,"minValue":null,"maxValue":null,"minStep":null,"perms":["pr","ev"]},"subscriptions":0,"_events":{},"_eventsCount":1}],"optionalCharacteristics":[],"isHiddenService":false,"isPrimaryService":false,"linkedServices":[]},{"displayName":"Beweegingssensor Aanrecht","UUID":"00000043-0000-1000-8000-0026BB765291","iid":null,"characteristics":[{"displayName":"Name","UUID":"00000023-0000-1000-8000-0026BB765291","iid":null,"value":"Beweegingssensor Aanrecht","status":null,"eventOnlyCharacteristic":false,"props":{"format":"string","unit":null,"minValue":null,"maxValue":null,"minStep":null,"perms":["pr"]},"subscriptions":0,"_events":{},"_eventsCount":1},{"displayName":"On","UUID":"00000025-0000-1000-8000-0026BB765291","iid":null,"value":false,"status":null,"eventOnlyCharacteristic":false,"props":{"format":"bool","unit":null,"minValue":null,"maxValue":null,"minStep":null,"perms":["pr","pw","ev"]},"subscriptions":0,"_events":{},"_eventsCount":1},{"displayName":"Brightness","UUID":"00000008-0000-1000-8000-0026BB765291","iid":null,"value":0,"status":null,"eventOnlyCharacteristic":false,"props":{"format":"int","unit":"percentage","minValue":0,"maxValue":100,"minStep":1,"perms":["pr","pw","ev"]},"subscriptions":0,"_events":{},"_eventsCount":1}],"optionalCharacteristics":[],"isHiddenService":false,"isPrimaryService":false,"linkedServices":[]}],"reachable":false,"context":{"deviceId":"1884811884f3eb2fffa7"},"_associatedPlugin":"homebridge-tuya","_associatedPlatform":"TuyaPlatform"}
[2018-12-31 16:27:44] [TuyaPlatform] didFinishLaunching
[2018-12-31 16:27:44] [TuyaPlatform] Device has IP: 192.168.178.150
[2018-12-31 16:27:44] [TuyaPlatform] New Device Online: Motion Sensor configed as dimmer (1884811884f3eb2fffa7)
[2018-12-31 16:27:44] [TuyaPlatform] Adding: Motion Sensor configed as dimmer (dimmer / 1884811884f3eb2fffa7)
[2018-12-31 16:27:44] [TuyaPlatform] Existing Accessory found [Motion Sensor configed as dimmer] [1884811884f3eb2fffa7] [33654b79-4c02-4a16-9eb2-82904d9f3512]

And then I keep getting:

 [TuyaPlatform] ERROR: not responding Motion Sensor configed as dimmer

Hope this helps :)

@NorthernMan54
Copy link
Contributor

NorthernMan54 commented Dec 31, 2018 via email

@experimint
Copy link
Author

Does the Tuya Api supports sensors at all?

@experimint
Copy link
Author

Does the Tuya Api supports sensors at all?

Couldn't find a list of supported devices in their documentation

@NorthernMan54
Copy link
Contributor

NorthernMan54 commented Dec 31, 2018 via email

@experimint
Copy link
Author

Got some photo's of the box it came in; may they be of some use

2018-12-31 17 42 26
2018-12-31 17 42 22
2018-12-31 17 42 16
2018-12-31 17 42 09
2018-12-31 17 42 03

@boatboy12
Copy link

boatboy12 commented Dec 31, 2018 via email

@codetheweb
Copy link
Collaborator

@experimint @boatboy12 are either of you able to send me a Wireshark log of your sensor reacting to a change in state and/or communicating with the app?

@boatboy12
Copy link

boatboy12 commented Dec 31, 2018 via email

@NorthernMan54
Copy link
Contributor

Okay, please share what you can find out.

@experimint
Copy link
Author

If Wireshark logs are still needed, I can try to provide them. If someone could guide me through the process of retrieving them (I've never used Wireshark before); I'd be happy to help :)

@boatboy12
Copy link

boatboy12 commented Jan 6, 2019 via email

@codetheweb
Copy link
Collaborator

@boatboy12 if you open the Tuya app it shows the device's IP address on the details page.

@experimint
Copy link
Author

The issue is closed, but I do not understand why. It seems that there are still possibilities to get this to work. Hi all, I'm still very keen to help! Thanks

@boatboy12
Copy link

boatboy12 commented Feb 6, 2019 via email

@boatboy12
Copy link

The IP address is the first thing I looked for after doing the scan but it did not show up in the list of IP's in the source or destination column. I only see the sensor MAC address in a "DHCP Request" and a "DHCP Discover", if that means anything.
I tried a scan again and the only think that consistently reads via the sensor MAC address is a "DHCP Request Transaction ID xxxxxxxxxx" and a "DHCP Discover Transaction ID xxxxxxxxxxx". Source IP is 0.0.0.0 and destination is 255.255.255.255

@codetheweb
Copy link
Collaborator

@boatboy12 sounds like your router or some other device on your network is trying to find the sensor's IP; doesn't mean much unfortunately.

@experimint I'm happy to reopen it if more information is given that allows me to implement it.

From what I've heard so far, it sounds like these sensors only contact the cloud API (which this library is not equipped to deal with).

If you want to do some more tinkering, you may want to take a look at this project. I believe it allows you to capture requests to Tuya's cloud services.

@experimint
Copy link
Author

Thanks for your insights and advice, @codetheweb
It seems that I've reached my tech-limits with this project. Custom firmware and wireshark are things I'd like to learn more about. But I'm afraid I do not have the time for such adventures at the moment. I'll keep a watchful eye on new developments regarding homebridge and tuya. Thanks everyone!
If I can help anybody in the future regarding this subject; I have a sensor to spare and I could send it out to you.

@codetheweb
Copy link
Collaborator

Sorry I couldn't help more, @experimint.

Someone else has created a schematic of a Tuya water detection sensor, and it appears it only turns on when it detects a change in state. I suspect something similar is happening with yours.

@jeylites
Copy link

jeylites commented Oct 10, 2020

Hi guys,

I'm planing to get a some motion & contact sensors. Has anyone got this working in 2020?

What will be the best option to go with WIFI or Zigbee?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants